You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Loan Broker Example

This example shows how to use Camel to implement the EIP's loan broker example.

The example has two versions, one is queue version which leverages the message queue to combinate the credit agency and bank loan quote processing and it uses the InOnly exchage pattern; the other is web service version which shows how to integrate the credit agency and bank web services together and it uses the InOut exchange pattern.

Implementation with message queue (JMS)

The queue version of loan broker is based on the Camel-JMS component, and it shows how to using the message queue to connect the different service models (such as the credit agency , and banks).

The example should run if you type
mvn exec:java -PQueue.LoanBroker
mvn exec:java -PQueue.Client

To stop the example hit ctrl + c

let's take a look how this service modules are put together.

Error formatting macro: snippet: java.lang.NullPointerException

The CreditAgency , Bank and Translator are all the implementation of Processor interface. We implement the business logicals in the void process(Exchange exchange) method.

CreditAgency

Error formatting macro: snippet: java.lang.NullPointerException

Bank

Error formatting macro: snippet: java.lang.NullPointerException

Translator

Error formatting macro: snippet: java.lang.NullPointerException

You may found we set a custom aggregation strategy to find out the lowest loan rate from bank response message.

Error formatting macro: snippet: java.lang.NullPointerException

We start the loan broker after we start up the ActiveMq broker and the connection factory of Camel-JMS component.

Error formatting macro: snippet: java.lang.NullPointerException

Now we can send the request from client

Error formatting macro: snippet: java.lang.NullPointerException

Here is how we pull the response message

Error formatting macro: snippet: java.lang.NullPointerException
  • No labels