1 配置效果图
2 配置文件
<!--
The main loanbroker flow that:
i) Receives a customer request
ii) Performs a lookup of the customer credit profile using a component binding
iii) Determines the bank that should be used to request quotes
iv) Sends the request to the selected banks and aggregates responses
v) Selects the lowest quote from the list of quotes
vi) Returns the response to the client
-->
<flow name="loadbroker-sync">
<http:inbound-endpoint exchange-pattern="request-response" address="http://0.0.0.0:11081" doc:name="HTTP"/>
<http:body-to-parameter-map-transformer doc:name="Body to Parameter Map"/>
<choice doc:name="Choice">
<when expression="!(payload\['name'\] == null || payload\['ssn'\] == null || payload\['amount'\] == null || payload\['term'\]==null)">
<expression-component doc:name="create customer request">
<!\[CDATA\[
import org.mule.example.loanbroker.message.CustomerQuoteRequest;
import org.mule.example.loanbroker.model.Customer;
payload = new CustomerQuoteRequest(
new Customer(payload\['name'\], Integer.parseInt(payload\['ssn'\])),
Integer.parseInt(payload\['amount'\]),
Integer.parseInt(payload\['term'\])
);
\]\]>
</expression-component>
<enricher source="#\[payload\]" target="flowVars\['creditProfile'\]" doc:name="Enricher with creditProfile">
<!--
功能: 根据CustomerQuoteRequest中的Customer,调用CreditAgencyService服务,取得该客户的信用信息CreditProfile
输入payload类型:CustomerQuoteRequest
返回消息负载类型:CreditProfile - 放入流变量creditProfile中
-->
<flow-ref name="lookupCustomerCreditProfile" doc:name="lookupCustomerCreditProfile"/>
</enricher>
<enricher source="#\[payload\]" target="#\[flowVars\['bankURIs'\]\]" doc:name="Enricher with banks">
<!--
功能:根据CustomerQuoteRequest中的loanAmount,
输入消息负载类型:CustomerQuoteRequest
返回消息负载类型:数组
-->
<flow-ref name="lookupBanks" doc:name="lookupBanks"/>
</enricher>
<set-variable variableName="quotes" value="#\[new java.util.LinkedList()\]" doc:name="create empty quotes"/>
<!-- 迭代bankURIs(ArrayList)数组 -->
<foreach collection="#\[flowVars\['bankURIs'\]\]" doc:name="Foreach">
<logger message="bankURI: #\[payload\]" level="INFO" doc:name="Test"/>
<enricher target="#\[quotes.add($)\]" doc:name="Message Enricher">
<!--
输入消息负载类型是:http://localhost:10080/mule/TheBank1
返回类型是:LoanQuote - Bank #1, rate: 6.159007229611378
把当前返回的LoanQuote放到quotes列表中
-->
<flow-ref name="lookupLoanQuote" doc:name="lookupLoanQuote"/>
</enricher>
</foreach>
<!--
输入消息负载类型:CustomerQuoteRequest
返回消息负载类型:为利率最低的那个LoanQuote
-->
<flow-ref name="findLowestLoanQuote" doc:name="findLowestLoanQuote"/>
<object-to-string-transformer doc:name="Object to String"/>
</when>
<otherwise>
<expression-component doc:name="Expression"><!\[CDATA\[payload = 'Error: incomplete request'\]\]></expression-component>
</otherwise>
</choice>
<catch-exception-strategy doc:name="Catch Exception Strategy">
<set-payload value="Error processing loan request" doc:name="Set error message"/>
</catch-exception-strategy>
</flow>
<sub-flow name="lookupCustomerCreditProfile">
<!-- lookupCustomerCreditProfile input: org.mule.example.loanbroker.message.CustomerQuoteRequest@16d9b56 -->
<logger message="lookupCustomerCreditProfile input: #\[payload\]" level="INFO" doc:name="input"/>
<set-payload value="#\[payload.customer\]" doc:name="customer"/>
<processor-chain doc:name="Processor Chain">
<cxf:jaxws-client operation="getCreditProfile" serviceClass="org.mule.example.loanbroker.creditagency.CreditAgencyService" doc:name="CXF"/>
<http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="18080" path="mule/TheCreditAgencyService" method="POST" doc:name="HTTP"/>
</processor-chain>
<!-- lookupCustomerCreditProfile end payload type: creditScore: 300, creditHistory: 1 - CreditProfile -->
<logger message="lookupCustomerCreditProfile output: #\[payload.getClass()\] - #\[payload\]" level="INFO" doc:name="output"/>
</sub-flow>
<!-- 取得Bank的URIs -->
<sub-flow name="lookupBanks">
<logger message="Banks to contact beginning: #\[payload\]" level="INFO" doc:name="banks"/>
<choice doc:name="Choice">
<when expression="payload.getLoanAmount() >= 20000">
<expression-component doc:name="Bank1, Bank2">
<!\[CDATA\[payload = \[
new java.net.URI('http://localhost:10080/mule/TheBank1'),
new java.net.URI('http://localhost:20080/mule/TheBank2')
\]\]\]>
</expression-component>
</when>
<when expression="payload.getLoanAmount() >= 10000 && payload.getLoanAmount() <= 1999">
<expression-component doc:name="Bank3, Bank4">
<!\[CDATA\[payload = \[
new java.net.URI('http://localhost:30080/mule/TheBank3'),
new java.net.URI('http://localhost:40080/mule/TheBank4')
\]\]\]>
</expression-component>
</when>
<otherwise>
<expression-component doc:name="Bank5">
<!\[CDATA\[payload = \[
new java.net.URI('http://localhost:50080/mule/TheBank5')
\]\]\]>
</expression-component>
</otherwise>
</choice>
<!--
出去时payload的类型 一个数组(lookupBanks ouput: class java.util.ArrayList)
Banks to contact: \[http://localhost:10080/mule/TheBank1, http://localhost:20080/mule/TheBank2\]
-->
<logger message="lookupBanks ouput: #\[payload.getClass()\] - #\[payload\]" level="INFO" doc:name="output"/>
</sub-flow>
<sub-flow name="lookupLoanQuote">
<!--
lookupLoanQuote input: class java.net.URI - http://localhost:10080/mule/TheBank1 输入的类型是一个java.net.URI
-->
<logger message="lookupLoanQuote input: #\[payload.getClass()\] - #\[payload\]" level="INFO" doc:name="input"/>
<set-variable variableName="bankUri" value="#\[payload\]" doc:name="bankUri"/>
<expression-component doc:name="create LoanBrokerLoanRequest">
<!\[CDATA\[
import org.mule.example.loanbroker.message.LoanBrokerQuoteRequest;
LoanBrokerQuoteRequest bqr = new LoanBrokerQuoteRequest();
bqr.setCreditProfile(flowVars\['creditProfile'\]);
payload = (Object) bqr; //此次表明,payload就是一个Object类型的引用,所以进来是引用的是java.net.URI,出去时引用的是LoanBrokerQuoteRequest
\]\]>
</expression-component>
<processor-chain doc:name="Processor Chain">
<cxf:jaxws-client operation="getLoanQuote" serviceClass="org.mule.example.loanbroker.bank.BankService" doc:name="getLoanQuote"/>
<http:outbound-endpoint exchange-pattern="request-response"
address="http://#\[flowVars\['bankUri'\].getHost()\]:#\[flowVars\['bankUri'\].getPort()\]#\[flowVars\['bankUri'\].getPath()\]" doc:name="HTTP"/>
</processor-chain>
<logger message="LoanQuote from #\[flowVars\['bankUri'\]\]: #\[payload\]" level="INFO" doc:name="quote"/>
<logger message="lookupLoanQuote output: #\[payload.getClass()\] - #\[payload\]" level="INFO" doc:name="output"/>
</sub-flow>
<sub-flow name="findLowestLoanQuote">
<logger message="findLowestLoanQuote input: #\[payload\]" level="INFO" doc:name="input"/>
<expression-component doc:name="Expression">
<!\[CDATA\[
import org.mule.example.loanbroker.model.LoanQuote;
LoanQuote lowestQuote = null;
for (Object current : (List) flowVars\['quotes'\])
{
LoanQuote loanQuote = (LoanQuote) current;
if (lowestQuote == null)
lowestQuote = loanQuote;
else if (loanQuote.getInterestRate() < lowestQuote.getInterestRate())
lowestQuote = loanQuote;
}
payload = lowestQuote;
\]\]>
</expression-component>
<logger message="findLowestLoanQuote output: #\[payload.getClass()\] - #\[payload\]" level="INFO" doc:name="output" />
</sub-flow>
<!--
模拟的一些服务
-->
<flow name="TheCreditAgencyService">
<http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:18080/mule/TheCreditAgencyService" doc:name="HTTP"/>
<cxf:jaxws-service serviceClass="org.mule.example.loanbroker.creditagency.CreditAgencyService" doc:name="SOAP"/>
<component doc:name="Java">
<singleton-object class="org.mule.example.loanbroker.creditagency.DefaultCreditAgency"/>
</component>
</flow>
<flow name="Bank1Flow">
<http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:10080/mule/TheBank1" doc:name="HTTP"/>
<cxf:jaxws-service serviceClass="org.mule.example.loanbroker.bank.BankService" doc:name="SOAP"/>
<component doc:name="Bank1">
<singleton-object class="org.mule.example.loanbroker.bank.Bank">
<property key="bankName" value="Bank #1" />
</singleton-object>
</component>
</flow>
<flow name="Bank2Flow">
<http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:20080/mule/TheBank2" doc:name="HTTP"/>
<cxf:jaxws-service serviceClass="org.mule.example.loanbroker.bank.BankService" doc:name="SOAP"/>
<component doc:name="Bank2">
<singleton-object class="org.mule.example.loanbroker.bank.Bank">
<property key="bankName" value="Bank #2" />
</singleton-object>
</component>
</flow>
<flow name="Bank3Flow">
<http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:30080/mule/TheBank3" doc:name="HTTP"/>
<cxf:jaxws-service serviceClass="org.mule.example.loanbroker.bank.BankService" doc:name="SOAP"/>
<component doc:name="Bank3">
<singleton-object class="org.mule.example.loanbroker.bank.Bank">
<property key="bankName" value="Bank #3" />
</singleton-object>
</component>
</flow>
<flow name="Bank4Flow">
<http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:40080/mule/TheBank4" doc:name="HTTP"/>
<cxf:jaxws-service serviceClass="org.mule.example.loanbroker.bank.BankService" doc:name="SOAP"/>
<component doc:name="Bank4">
<singleton-object class="org.mule.example.loanbroker.bank.Bank">
<property key="bankName" value="Bank #4" />
</singleton-object>
</component>
</flow>
<flow name="Bank5Flow">
<http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:50080/mule/TheBank5" doc:name="HTTP"/>
<cxf:jaxws-service serviceClass="org.mule.example.loanbroker.bank.BankService" doc:name="SOAP"/>
<component doc:name="Bank5">
<singleton-object class="org.mule.example.loanbroker.bank.Bank">
<property key="bankName" value="Bank #5" />
</singleton-object>
</component>
</flow>
3 相关类文件
1)http://0.0.0.0:11081入站端点请求处理相关类 CustomerQuoteRequest和Customer
CustomerQuoteRequest类
package org.mule.example.loanbroker.message;
import java.io.Serializable;
import org.mule.example.loanbroker.model.Customer;
public class CustomerQuoteRequest implements Serializable {
/\*\*
\*
\*/
private static final long serialVersionUID = 2449671876064808042L;
private Customer customer;
private double loanAmount;
private int loanDuration;
public CustomerQuoteRequest() {}
public CustomerQuoteRequest(Customer customer, double loanAmount, int loanDuration) {
this.customer = customer;
this.loanAmount = loanAmount;
this.loanDuration = loanDuration;
}
public Customer getCustomer() {
return customer;
}
public void setCustomer(Customer customer) {
this.customer = customer;
}
public double getLoanAmount() {
return loanAmount;
}
public void setLoanAmount(double loanAmount) {
this.loanAmount = loanAmount;
}
public int getLoanDuration() {
return loanDuration;
}
public void setLoanDuration(int loanDuration) {
this.loanDuration = loanDuration;
}
}
Customer
package org.mule.example.loanbroker.model;
import java.io.Serializable;
public class Customer implements Serializable {
/\*\*
\*
\*/
private static final long serialVersionUID = 3102974874591789911L;
private String name;
private int ssn;
public Customer() {}
public Customer(String name, int ssn) {
this.name = name;
this.ssn = ssn;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getSsn() {
return ssn;
}
public void setSsn(int ssn) {
this.ssn = ssn;
}
}
2)http://localhost:18080/mule/TheCreditAgencyService 端点的 信用代理服务相关类 CreditAgencyService, DefaultCreditAgency 和 CreditProfile
CreditAgencyService
package org.mule.example.loanbroker.creditagency;
import javax.jws.WebService;
import org.mule.example.loanbroker.model.CreditProfile;
import org.mule.example.loanbroker.model.Customer;
/**
* 该服务为客户提供信用查询
*
*/
@WebService
public interface CreditAgencyService {
CreditProfile getCreditProfile(Customer customer);
}
DefaultCreditAgency
package org.mule.example.loanbroker.creditagency;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.mule.example.loanbroker.model.CreditProfile;
import org.mule.example.loanbroker.model.Customer;
public class DefaultCreditAgency implements CreditAgencyService {
private static final Log logger = LogFactory.getLog(DefaultCreditAgency.class);
@Override
public CreditProfile getCreditProfile(Customer customer) {
CreditProfile cp = new CreditProfile();
cp.setCreditHistory(getCreditHistoryLength(customer.getSsn()));
cp.setCreditScore(getCreditScore(customer.getSsn()));
return cp;
}
/\*\*
\* 随机生成一个信用历史时间
\* @param ssn
\* @return
\*/
protected int getCreditHistoryLength(int ssn) {
int credit\_history\_length;
credit\_history\_length = (int) Math.random() \* 19 + 1;
return credit\_history\_length;
}
/\*\*
\* 随机生成一个信用评分
\* @param ssn
\* @return
\*/
protected int getCreditScore(int ssn) {
int credit\_score;
double rand = Math.random();
credit\_score = (int) (rand \* 600 + 300);
logger.info("----------------- " + "ssn\[" + ssn + "\]" + " 信用计算---------------------");
logger.info(String.format("%.2f", rand) + " \* 600 + 300 = " + credit\_score);
return credit\_score;
}
}
CreditProfile
package org.mule.example.loanbroker.model;
import java.io.Serializable;
public class CreditProfile implements Serializable {
/\*\*
\*
\*/
private static final long serialVersionUID = -875718927687611982L;
private int creditScore;
private int creditHistory;
public CreditProfile() {}
public CreditProfile(int creditScore, int creditHistory) {
this.creditScore = creditScore;
this.creditHistory = creditHistory;
}
public int getCreditScore() {
return creditScore;
}
public void setCreditScore(int creditScore) {
this.creditScore = creditScore;
}
public int getCreditHistory() {
return creditHistory;
}
public void setCreditHistory(int creditHistory) {
this.creditHistory = creditHistory;
}
public String toString() {
return "creditScore: " + creditScore + ", creditHistory: " + creditHistory;
}
}
5)在http://localhost:10080/mule/TheBank1, http://localhost:20080/mule/TheBank2, …., http://localhost:50080/mule/TheBank5端点 提供 银行贷款服务的相关类
BankService
package org.mule.example.loanbroker.bank;
import javax.jws.WebService;
import org.mule.example.loanbroker.message.LoanBrokerQuoteRequest;
import org.mule.example.loanbroker.model.LoanQuote;
@WebService
public interface BankService {
LoanQuote getLoanQuote(LoanBrokerQuoteRequest request);
}
Bank
package org.mule.example.loanbroker.bank;
import java.io.Serializable;
import java.util.Arrays;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.mule.example.loanbroker.message.LoanBrokerQuoteRequest;
import org.mule.example.loanbroker.model.LoanQuote;
/**
* 功能描述:
* 每个银行对客户分3级:
* 铂金用户(信用评分:700 ~ xxx) -- 利率最低
* 黄金用户(信用评分:500 ~ 700)--
* 基本用户(信用评分: 0 ~ 500) -- 利率最高
*/
public class Bank implements Serializable, BankService {
private static final long serialVersionUID = 3581465484941524150L;
private static final int PLATINUM\_PROFILE\_INDEX = 0;
private static final int GOLD\_PROFILE\_INDEX = 1;
private static final int BASIC\_PROFILE\_INDEX = 2;
protected static final Log logger = LogFactory.getLog(Bank.class);
private String bankName;
private final double\[\] rates;
public Bank() {
rates = new double\[\] {
Math.random() \* 10,
Math.random() \* 10,
Math.random() \* 10 };
Arrays.sort(rates);
}
@Override
public LoanQuote getLoanQuote(LoanBrokerQuoteRequest request) {
logger.info("-------------------- 调用 BankService(" + bankName + ")服务 ---------------");
logger.info("该行提供的利率为: " + rates\[0\] + ", " + rates\[1\] + ", " + rates\[2\]);
LoanQuote quote = new LoanQuote();
quote.setBankName(bankName);
//获得信用评分
int creditScore = request.getCreditProfile().getCreditScore();
logger.info("此次请求的信用评分creditScore:" + creditScore);
quote.setInterestRate(getCreditScoreRate(creditScore));
logger.info("Returning Rate is: " + quote);
logger.info("-------------------------------------------------------------");
return quote;
}
/\*\*
\* 依据信用评分判断出贷款利率
\* @param creditScore
\* @return
\*/
private double getCreditScoreRate(int creditScore) {
int index;
if (creditScore < 500) {
index = BASIC\_PROFILE\_INDEX;
logger.info("为基本客户");
}
else if (creditScore < 700) {
index = GOLD\_PROFILE\_INDEX;
logger.info("为黄金客户");
}
else {
index = PLATINUM\_PROFILE\_INDEX;
logger.info("为铂金客户");
}
return rates\[index\];
}
public String getBankName() {
return bankName;
}
public void setBankName(String bankName) {
this.bankName = bankName;
}
}
LoanQuote
package org.mule.example.loanbroker.model;
import java.io.Serializable;
public class LoanQuote implements Serializable {
/\*\*
\*
\*/
private static final long serialVersionUID = -6113408134263802670L;
private String bankName;
private double interestRate = 0;
public LoanQuote() {}
public String getBankName() {
return bankName;
}
public void setBankName(String bankName) {
this.bankName = bankName;
}
public double getInterestRate() {
return interestRate;
}
public void setInterestRate(double interestRate) {
this.interestRate = interestRate;
}
public String toString() {
return bankName + ", rate: " + interestRate;
}
}
4 测试
5 输出日志分析
[06-23 12:05:43] INFO DefaultMuleApplication [main]:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[06-23 12:05:46] INFO AutoConfigurationBuilder [main]: Configured Mule using "org.mule.config.spring.SpringXmlConfigurationBuilder" with configuration resource(s): "[ConfigResource{resourceName='D:\AnypointStudio\workspace\.mule\apps\loanbroker-simple\loanbroker-simple.xml'}]"
[06-23 12:05:46] INFO AutoConfigurationBuilder [main]: Configured Mule using "org.mule.config.builders.AutoConfigurationBuilder" with configuration resource(s): "[ConfigResource{resourceName='D:\AnypointStudio\workspace\.mule\apps\loanbroker-simple\loanbroker-simple.xml'}]"
[06-23 12:05:46] INFO DefaultMuleApplication [main]: Monitoring for hot-deployment: D:\AnypointStudio\workspace\.mule\apps\loanbroker-simple\loanbroker-simple.xml
[06-23 12:05:46] INFO DefaultMuleApplication [main]:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[06-23 12:05:46] INFO HttpConnector [main]: Starting: HttpConnector
{
name=connector.http.mule.default
lifecycle=initialise
this=4bd2df
numberOfConcurrentTransactedReceivers=4
createMultipleTransactedReceivers=true
connected=true
supportedProtocols=[http]
serviceOverrides=
}
[06-23 12:05:46] INFO AbstractLifecycleManager [main]: Starting connector: connector.http.mule.default 启动http连接器
[06-23 12:05:46] INFO AbstractLifecycleManager [main]: Starting model: _muleSystemModel 启动mule系统模型
启动流服务loadbroker-sync
[06-23 12:05:46] INFO FlowConstructLifecycleManager [main]: Starting flow: loadbroker-sync
[06-23 12:05:46] INFO SedaStageLifecycleManager [main]: Starting service: loadbroker-sync.stage1
[06-23 12:05:46] INFO HttpConnector [main]: Registering listener: loadbroker-sync on endpointUri: http://0.0.0.0:11081
[06-23 12:05:46] INFO DefaultTransportServiceDescriptor [main]: Loading default response transformer: org.mule.transport.http.transformers.MuleMessageToHttpResponse
[06-23 12:05:46] INFO AbstractLifecycleManager [main]: Initialising: 'null'. Object is: HttpMessageReceiver HTTP消息接收者没有名字,初始化名字为'null'的HTTP消息接受者
[06-23 12:05:46] INFO HttpMessageReceiver [main]: Connecting clusterizable message receiver
[06-23 12:05:46] INFO AbstractLifecycleManager [main]: Starting: 'null'. Object is: HttpMessageReceiver 启动名字为'null'的HTTP消息接收者
[06-23 12:05:46] INFO HttpMessageReceiver [main]: Starting clusterizable message receiver
启动流服务TheCreditAgencyService
[06-23 12:05:46] INFO FlowConstructLifecycleManager [main]: Starting flow: TheCreditAgencyService
[06-23 12:05:46] INFO SedaStageLifecycleManager [main]: Starting service: TheCreditAgencyService.stage1
[06-23 12:05:46] INFO ComponentLifecycleManager [main]: Starting component: component.8626349
[06-23 12:05:46] INFO HttpConnector [main]: Registering listener: TheCreditAgencyService on endpointUri: http://localhost:18080/mule/TheCreditAgencyService
[06-23 12:05:46] INFO DefaultTransportServiceDescriptor [main]: Loading default response transformer: org.mule.transport.http.transformers.MuleMessageToHttpResponse
[06-23 12:05:46] INFO AbstractLifecycleManager [main]: Initialising: 'null'. Object is: HttpMessageReceiver
[06-23 12:05:46] INFO HttpMessageReceiver [main]: Connecting clusterizable message receiver
[06-23 12:05:46] INFO AbstractLifecycleManager [main]: Starting: 'null'. Object is: HttpMessageReceiver
[06-23 12:05:46] INFO HttpMessageReceiver [main]: Starting clusterizable message receiver
启动流服务Bank1Flow
[06-23 12:05:46] INFO FlowConstructLifecycleManager [main]: Starting flow: Bank1Flow
[06-23 12:05:46] INFO SedaStageLifecycleManager [main]: Starting service: Bank1Flow.stage1
[06-23 12:05:46] INFO ComponentLifecycleManager [main]: Starting component: component.2709710
[06-23 12:05:46] INFO HttpConnector [main]: Registering listener: Bank1Flow on endpointUri: http://localhost:10080/mule/TheBank1
[06-23 12:05:46] INFO DefaultTransportServiceDescriptor [main]: Loading default response transformer: org.mule.transport.http.transformers.MuleMessageToHttpResponse
[06-23 12:05:46] INFO AbstractLifecycleManager [main]: Initialising: 'null'. Object is: HttpMessageReceiver
[06-23 12:05:46] INFO HttpMessageReceiver [main]: Connecting clusterizable message receiver
[06-23 12:05:46] INFO AbstractLifecycleManager [main]: Starting: 'null'. Object is: HttpMessageReceiver
[06-23 12:05:46] INFO HttpMessageReceiver [main]: Starting clusterizable message receiver
[06-23 12:05:46] INFO FlowConstructLifecycleManager [main]: Starting flow: Bank2Flow
[06-23 12:05:46] INFO SedaStageLifecycleManager [main]: Starting service: Bank2Flow.stage1
[06-23 12:05:46] INFO ComponentLifecycleManager [main]: Starting component: component.18460269
[06-23 12:05:46] INFO HttpConnector [main]: Registering listener: Bank2Flow on endpointUri: http://localhost:20080/mule/TheBank2
[06-23 12:05:46] INFO DefaultTransportServiceDescriptor [main]: Loading default response transformer: org.mule.transport.http.transformers.MuleMessageToHttpResponse
[06-23 12:05:46] INFO AbstractLifecycleManager [main]: Initialising: 'null'. Object is: HttpMessageReceiver
[06-23 12:05:46] INFO HttpMessageReceiver [main]: Connecting clusterizable message receiver
[06-23 12:05:46] INFO AbstractLifecycleManager [main]: Starting: 'null'. Object is: HttpMessageReceiver
[06-23 12:05:46] INFO HttpMessageReceiver [main]: Starting clusterizable message receiver
[06-23 12:05:46] INFO FlowConstructLifecycleManager [main]: Starting flow: Bank3Flow
[06-23 12:05:46] INFO SedaStageLifecycleManager [main]: Starting service: Bank3Flow.stage1
[06-23 12:05:46] INFO ComponentLifecycleManager [main]: Starting component: component.25069616
[06-23 12:05:46] INFO HttpConnector [main]: Registering listener: Bank3Flow on endpointUri: http://localhost:30080/mule/TheBank3
[06-23 12:05:46] INFO DefaultTransportServiceDescriptor [main]: Loading default response transformer: org.mule.transport.http.transformers.MuleMessageToHttpResponse
[06-23 12:05:46] INFO AbstractLifecycleManager [main]: Initialising: 'null'. Object is: HttpMessageReceiver
[06-23 12:05:46] INFO HttpMessageReceiver [main]: Connecting clusterizable message receiver
[06-23 12:05:46] INFO AbstractLifecycleManager [main]: Starting: 'null'. Object is: HttpMessageReceiver
[06-23 12:05:46] INFO HttpMessageReceiver [main]: Starting clusterizable message receiver
[06-23 12:05:46] INFO FlowConstructLifecycleManager [main]: Starting flow: Bank4Flow
[06-23 12:05:46] INFO SedaStageLifecycleManager [main]: Starting service: Bank4Flow.stage1
[06-23 12:05:46] INFO ComponentLifecycleManager [main]: Starting component: component.16222959
[06-23 12:05:46] INFO HttpConnector [main]: Registering listener: Bank4Flow on endpointUri: http://localhost:40080/mule/TheBank4
[06-23 12:05:46] INFO DefaultTransportServiceDescriptor [main]: Loading default response transformer: org.mule.transport.http.transformers.MuleMessageToHttpResponse
[06-23 12:05:46] INFO AbstractLifecycleManager [main]: Initialising: 'null'. Object is: HttpMessageReceiver
[06-23 12:05:46] INFO HttpMessageReceiver [main]: Connecting clusterizable message receiver
[06-23 12:05:46] INFO AbstractLifecycleManager [main]: Starting: 'null'. Object is: HttpMessageReceiver
[06-23 12:05:46] INFO HttpMessageReceiver [main]: Starting clusterizable message receiver
[06-23 12:05:46] INFO FlowConstructLifecycleManager [main]: Starting flow: Bank5Flow
[06-23 12:05:46] INFO SedaStageLifecycleManager [main]: Starting service: Bank5Flow.stage1
[06-23 12:05:46] INFO ComponentLifecycleManager [main]: Starting component: component.24429866
[06-23 12:05:46] INFO HttpConnector [main]: Registering listener: Bank5Flow on endpointUri: http://localhost:50080/mule/TheBank5
[06-23 12:05:46] INFO DefaultTransportServiceDescriptor [main]: Loading default response transformer: org.mule.transport.http.transformers.MuleMessageToHttpResponse
[06-23 12:05:46] INFO AbstractLifecycleManager [main]: Initialising: 'null'. Object is: HttpMessageReceiver
[06-23 12:05:46] INFO HttpMessageReceiver [main]: Connecting clusterizable message receiver
[06-23 12:05:46] INFO AbstractLifecycleManager [main]: Starting: 'null'. Object is: HttpMessageReceiver
[06-23 12:05:46] INFO HttpMessageReceiver [main]: Starting clusterizable message receiver
[06-23 12:05:46] INFO DefaultMuleApplication [main]: Reload interval: 3000
[06-23 12:05:46] INFO WrapperManagerAgent [main]: This JVM hasn't been launched by the wrapper, the agent will not run.
[06-23 12:05:46] INFO JmxAgent [main]: Attempting to register service with name: 注册流服务TheCreditAgencyService
Mule.loanbroker-simple:type=Endpoint,service="TheCreditAgencyService",connector=connector.http.mule.default,name="endpoint.http.localhost.18080.mule.TheCreditAgencyService"
[06-23 12:05:46] INFO JmxAgent [main]: Registered Endpoint Service with name:
Mule.loanbroker-simple:type=Endpoint,service="TheCreditAgencyService",connector=connector.http.mule.default,name="endpoint.http.localhost.18080.mule.TheCreditAgencyService"
[06-23 12:05:46] INFO JmxAgent [main]: Attempting to register service with name:
Mule.loanbroker-simple:type=Endpoint,service="Bank3Flow",connector=connector.http.mule.default,name="endpoint.http.localhost.30080.mule.TheBank3"
[06-23 12:05:46] INFO JmxAgent [main]: Registered Endpoint Service with name:
Mule.loanbroker-simple:type=Endpoint,service="Bank3Flow",connector=connector.http.mule.default,name="endpoint.http.localhost.30080.mule.TheBank3"
[06-23 12:05:46] INFO JmxAgent [main]: Attempting to register service with name: Mule.loanbroker-simple:type=Endpoint,service="Bank4Flow",connector=connector.http.mule.default,name="endpoint.http.localhost.40080.mule.TheBank4"
[06-23 12:05:46] INFO JmxAgent [main]: Registered Endpoint Service with name: Mule.loanbroker-simple:type=Endpoint,service="Bank4Flow",connector=connector.http.mule.default,name="endpoint.http.localhost.40080.mule.TheBank4"
[06-23 12:05:46] INFO JmxAgent [main]: Attempting to register service with name: Mule.loanbroker-simple:type=Endpoint,service="Bank5Flow",connector=connector.http.mule.default,name="endpoint.http.localhost.50080.mule.TheBank5"
[06-23 12:05:46] INFO JmxAgent [main]: Registered Endpoint Service with name: Mule.loanbroker-simple:type=Endpoint,service="Bank5Flow",connector=connector.http.mule.default,name="endpoint.http.localhost.50080.mule.TheBank5"
[06-23 12:05:46] INFO JmxAgent [main]: Attempting to register service with name: Mule.loanbroker-simple:type=Endpoint,service="Bank1Flow",connector=connector.http.mule.default,name="endpoint.http.localhost.10080.mule.TheBank1"
[06-23 12:05:46] INFO JmxAgent [main]: Registered Endpoint Service with name: Mule.loanbroker-simple:type=Endpoint,service="Bank1Flow",connector=connector.http.mule.default,name="endpoint.http.localhost.10080.mule.TheBank1"
[06-23 12:05:46] INFO JmxAgent [main]: Attempting to register service with name: Mule.loanbroker-simple:type=Endpoint,service="Bank2Flow",connector=connector.http.mule.default,name="endpoint.http.localhost.20080.mule.TheBank2"
[06-23 12:05:46] INFO JmxAgent [main]: Registered Endpoint Service with name: Mule.loanbroker-simple:type=Endpoint,service="Bank2Flow",connector=connector.http.mule.default,name="endpoint.http.localhost.20080.mule.TheBank2"
[06-23 12:05:46] INFO JmxAgent [main]: Attempting to register service with name: 注册流服务loadbroker-sync
Mule.loanbroker-simple:type=Endpoint,service="loadbroker-sync",connector=connector.http.mule.default,name="endpoint.http.0.0.0.0.11081"
[06-23 12:05:46] INFO JmxAgent [main]: Registered Endpoint Service with name:
Mule.loanbroker-simple:type=Endpoint,service="loadbroker-sync",connector=connector.http.mule.default,name="endpoint.http.0.0.0.0.11081"
[06-23 12:05:46] INFO JmxAgent [main]: Registered Connector Service with name: 注册连接器服务connector.http.mule.default.1
Mule.loanbroker-simple:type=Connector,name="connector.http.mule.default.1"
[06-23 12:05:46] INFO DefaultMuleContext [main]:
**********************************************************************
* Application: loanbroker-simple *
* OS encoding: GBK, Mule encoding: UTF-8 *
* *
* Agents Running: *
* JMX Agent *
**********************************************************************
[06-23 12:05:46] INFO MuleDeploymentService [main]:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
**********************************************************************
* - - + APPLICATION + - - * - - + STATUS + - - *
**********************************************************************
* loanbroker-simple * DEPLOYED *
**********************************************************************
[06-23 12:05:46] INFO MuleDeploymentService [main]:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[06-23 12:05:49] INFO DefaultTransportServiceDescriptor [[loanbroker-simple].connector.http.mule.default.receiver.08]: Loading default outbound transformer: org.mule.transport.http.transformers.ObjectToHttpClientMethodRequest
[06-23 12:05:49] INFO DefaultTransportServiceDescriptor [[loanbroker-simple].connector.http.mule.default.receiver.08]: Loading default response transformer: org.mule.transport.http.transformers.MuleMessageToHttpResponse
[06-23 12:05:49] INFO DefaultTransportServiceDescriptor [[loanbroker-simple].connector.http.mule.default.receiver.08]: Loading default outbound transformer: org.mule.transport.http.transformers.ObjectToHttpClientMethodRequest
[06-23 12:05:49] INFO AbstractLifecycleManager [[loanbroker-simple].connector.http.mule.default.receiver.08]: Initialising: 'connector.http.mule.default.dispatcher.4887456'. Object is: HttpClientMessageDispatcher
[06-23 12:05:49] INFO AbstractLifecycleManager [[loanbroker-simple].connector.http.mule.default.receiver.08]: Starting: 'connector.http.mule.default.dispatcher.4887456'. Object is: HttpClientMessageDispatcher
调用子流lookupCustomerCreditProfile的日志输出
[06-23 12:05:49] INFO LoggerMessageProcessor [[loanbroker-simple].connector.http.mule.default.receiver.08]: lookupCustomerCreditProfile input: org.mule.example.loanbroker.message.CustomerQuoteRequest@e9c2fd
[06-23 12:05:49] INFO DefaultCreditAgency [[loanbroker-simple].connector.http.mule.default.receiver.09]: ----------------- ssn[1234] 信用计算---------------------
[06-23 12:05:49] INFO DefaultCreditAgency [[loanbroker-simple].connector.http.mule.default.receiver.09]: 0.51 * 600 + 300 = 607
[06-23 12:05:49] INFO LoggerMessageProcessor [[loanbroker-simple].connector.http.mule.default.receiver.08]: lookupCustomerCreditProfile output: class org.mule.example.loanbroker.model.CreditProfile - creditScore: 607, creditHistory: 1
调用子流lookupBanks的日志输出
[06-23 12:05:49] INFO LoggerMessageProcessor [[loanbroker-simple].connector.http.mule.default.receiver.08]: Banks to contact beginning: org.mule.example.loanbroker.message.CustomerQuoteRequest@e9c2fd
[06-23 12:05:49] INFO LoggerMessageProcessor [[loanbroker-simple].connector.http.mule.default.receiver.08]: lookupBanks ouput: class java.util.ArrayList - [http://localhost:10080/mule/TheBank1, http://localhost:20080/mule/TheBank2]
当前迭代的bankURL
[06-23 12:05:49] INFO LoggerMessageProcessor [[loanbroker-simple].connector.http.mule.default.receiver.08]: bankURI: http://localhost:10080/mule/TheBank1
以当前迭代bankURL为输入消息负载,调用子流lookupLoanQuote
[06-23 12:05:49] INFO LoggerMessageProcessor [[loanbroker-simple].connector.http.mule.default.receiver.08]: lookupLoanQuote input: class java.net.URI - http://localhost:10080/mule/TheBank1
[06-23 12:05:49] INFO DefaultTransportServiceDescriptor [[loanbroker-simple].connector.http.mule.default.receiver.08]: Loading default outbound transformer: org.mule.transport.http.transformers.ObjectToHttpClientMethodRequest
[06-23 12:05:49] INFO DefaultTransportServiceDescriptor [[loanbroker-simple].connector.http.mule.default.receiver.08]: Loading default response transformer: org.mule.transport.http.transformers.MuleMessageToHttpResponse
[06-23 12:05:49] INFO DefaultTransportServiceDescriptor [[loanbroker-simple].connector.http.mule.default.receiver.08]: Loading default outbound transformer: org.mule.transport.http.transformers.ObjectToHttpClientMethodRequest
[06-23 12:05:49] INFO AbstractLifecycleManager [[loanbroker-simple].connector.http.mule.default.receiver.08]: Initialising: 'connector.http.mule.default.dispatcher.24609463'. Object is: HttpClientMessageDispatcher
[06-23 12:05:49] INFO AbstractLifecycleManager [[loanbroker-simple].connector.http.mule.default.receiver.08]: Starting: 'connector.http.mule.default.dispatcher.24609463'. Object is: HttpClientMessageDispatcher
[06-23 12:05:49] INFO Bank [[loanbroker-simple].connector.http.mule.default.receiver.09]: -------------------- 调用 BankService(Bank #1)服务 ---------------
[06-23 12:05:49] INFO Bank [[loanbroker-simple].connector.http.mule.default.receiver.09]: 该行提供的利率为: 1.3555978615889497, 3.120721438085554, 3.6467680827751336
[06-23 12:05:49] INFO Bank [[loanbroker-simple].connector.http.mule.default.receiver.09]: 此次请求的信用评分creditScore:607
[06-23 12:05:49] INFO Bank [[loanbroker-simple].connector.http.mule.default.receiver.09]: 为黄金客户
[06-23 12:05:49] INFO Bank [[loanbroker-simple].connector.http.mule.default.receiver.09]: Returning Rate is: Bank #1, rate: 3.120721438085554
[06-23 12:05:49] INFO Bank [[loanbroker-simple].connector.http.mule.default.receiver.09]: -------------------------------------------------------------
[06-23 12:05:49] INFO LoggerMessageProcessor [[loanbroker-simple].connector.http.mule.default.receiver.08]: LoanQuote from http://localhost:10080/mule/TheBank1: Bank #1, rate: 3.120721438085554
[06-23 12:05:49] INFO LoggerMessageProcessor [[loanbroker-simple].connector.http.mule.default.receiver.08]: lookupLoanQuote output: class org.mule.example.loanbroker.model.LoanQuote - Bank #1, rate: 3.120721438085554
当前迭代的bankURL
[06-23 12:05:49] INFO LoggerMessageProcessor [[loanbroker-simple].connector.http.mule.default.receiver.08]: bankURI: http://localhost:20080/mule/TheBank2
以当前迭代bankURL为输入消息负载,调用子流lookupLoanQuote
[06-23 12:05:49] INFO LoggerMessageProcessor [[loanbroker-simple].connector.http.mule.default.receiver.08]: lookupLoanQuote input: class java.net.URI - http://localhost:20080/mule/TheBank2
[06-23 12:05:49] INFO DefaultTransportServiceDescriptor [[loanbroker-simple].connector.http.mule.default.receiver.08]: Loading default outbound transformer: org.mule.transport.http.transformers.ObjectToHttpClientMethodRequest
[06-23 12:05:49] INFO DefaultTransportServiceDescriptor [[loanbroker-simple].connector.http.mule.default.receiver.08]: Loading default response transformer: org.mule.transport.http.transformers.MuleMessageToHttpResponse
[06-23 12:05:49] INFO DefaultTransportServiceDescriptor [[loanbroker-simple].connector.http.mule.default.receiver.08]: Loading default outbound transformer: org.mule.transport.http.transformers.ObjectToHttpClientMethodRequest
[06-23 12:05:49] INFO AbstractLifecycleManager [[loanbroker-simple].connector.http.mule.default.receiver.08]: Initialising: 'connector.http.mule.default.dispatcher.13026502'. Object is: HttpClientMessageDispatcher
[06-23 12:05:49] INFO AbstractLifecycleManager [[loanbroker-simple].connector.http.mule.default.receiver.08]: Starting: 'connector.http.mule.default.dispatcher.13026502'. Object is: HttpClientMessageDispatcher
[06-23 12:05:49] INFO Bank [[loanbroker-simple].connector.http.mule.default.receiver.09]: -------------------- 调用 BankService(Bank #2)服务 ---------------
[06-23 12:05:49] INFO Bank [[loanbroker-simple].connector.http.mule.default.receiver.09]: 该行提供的利率为: 4.414272738125696, 8.167077378604374, 8.318685247739264
[06-23 12:05:49] INFO Bank [[loanbroker-simple].connector.http.mule.default.receiver.09]: 此次请求的信用评分creditScore:607
[06-23 12:05:49] INFO Bank [[loanbroker-simple].connector.http.mule.default.receiver.09]: 为黄金客户
[06-23 12:05:49] INFO Bank [[loanbroker-simple].connector.http.mule.default.receiver.09]: Returning Rate is: Bank #2, rate: 8.167077378604374
[06-23 12:05:49] INFO Bank [[loanbroker-simple].connector.http.mule.default.receiver.09]: -------------------------------------------------------------
[06-23 12:05:49] INFO LoggerMessageProcessor [[loanbroker-simple].connector.http.mule.default.receiver.08]: LoanQuote from http://localhost:20080/mule/TheBank2: Bank #2, rate: 8.167077378604374
[06-23 12:05:49] INFO LoggerMessageProcessor [[loanbroker-simple].connector.http.mule.default.receiver.08]: lookupLoanQuote output: class org.mule.example.loanbroker.model.LoanQuote - Bank #2, rate: 8.167077378604374
调用子流findLowestLoanQuote选择利率最低的LoanQuote贷款方案
[06-23 12:05:49] INFO LoggerMessageProcessor [[loanbroker-simple].connector.http.mule.default.receiver.08]: findLowestLoanQuote input: org.mule.example.loanbroker.message.CustomerQuoteRequest@e9c2fd
[06-23 12:05:49] INFO LoggerMessageProcessor [[loanbroker-simple].connector.http.mule.default.receiver.08]: findLowestLoanQuote output: class org.mule.example.loanbroker.model.LoanQuote - Bank #1, rate: 3.120721438085554
手机扫一扫
移动阅读更方便
你可能感兴趣的文章