Last active
February 10, 2016 13:18
-
-
Save noorulhaq/b13a19b9054941985109 to your computer and use it in GitHub Desktop.
Best loan quotation problem solution using spring integration scatter-gather EIP pattern.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<beans xmlns="http://www.springframework.org/schema/beans" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns:int="http://www.springframework.org/schema/integration" | |
xmlns:int-scripting="http://www.springframework.org/schema/integration/scripting" | |
xmlns:stream="http://www.springframework.org/schema/integration/stream" | |
xmlns:context="http://www.springframework.org/schema/context" | |
xmlns:task="http://www.springframework.org/schema/task" | |
xsi:schemaLocation="http://www.springframework.org/schema/beans | |
http://www.springframework.org/schema/beans/spring-beans.xsd | |
http://www.springframework.org/schema/context | |
http://www.springframework.org/schema/context/spring-context.xsd | |
http://www.springframework.org/schema/integration | |
http://www.springframework.org/schema/integration/spring-integration.xsd | |
http://www.springframework.org/schema/integration/stream | |
http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd | |
http://www.springframework.org/schema/integration/scripting | |
http://www.springframework.org/schema/integration/scripting/spring-integration-scripting.xsd | |
http://www.springframework.org/schema/task | |
http://www.springframework.org/schema/task/spring-task.xsd"> | |
<int:gateway service-interface="com.spintegration.test.scatter.gather.service.BestQuotationSearchService" default-request-channel="ch1" default-reply-timeout="1000"/> | |
<int:channel id="ch1"/> | |
<int:scatter-gather input-channel="ch1" scatter-channel="scatter_channel" gather-channel="ch2" output-channel="quotations_result_channel" gather-timeout="3000" requires-reply="false"> | |
<int:gatherer release-strategy-expression="size()==2"/> | |
</int:scatter-gather> | |
<int:channel id="quotations_result_channel"/> | |
<int:transformer input-channel="quotations_result_channel"> | |
<int-scripting:script lang="javascript"> | |
<![CDATA[ | |
(function(){ | |
var indexRate = 10000; | |
for(i=0; i<payload.size(); i++){ | |
if(indexRate > payload.get(i)) | |
indexRate = payload.get(i); | |
} | |
return indexRate; | |
})(); | |
]]> | |
</int-scripting:script> | |
</int:transformer> | |
<int:publish-subscribe-channel id="scatter_channel" apply-sequence="true" task-executor="taskExecutor"/> | |
<int:channel id="ch2"/> | |
<!-- Exemplary quotation services --> | |
<int:transformer input-channel="scatter_channel" expression="payload * 0.03" output-channel="ch2"/> | |
<int:transformer input-channel="scatter_channel" expression="payload * 0.02" output-channel="ch2"/> | |
<task:executor id="taskExecutor" queue-capacity="2" pool-size="2-2"/> | |
</beans> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface BestQuotationSearchService { | |
public Double findBestQuotation(Double loanAmount); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17:09:44.822 DEBUG [main][org.springframework.integration.handler.ScatterGatherHandler] org.springframework.integration.handler.ScatterGatherHandler#0 received message: GenericMessage [payload=100.0, headers={timestamp=1425733784821, id=3b1f485d-3718-c330-e55c-14887068ee09, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@12420d74, replyChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@12420d74}] | |
17:09:44.826 DEBUG [main][org.springframework.integration.channel.DefaultHeaderChannelRegistry] Registered org.springframework.integration.channel.QueueChannel@56849d45 as 5c6f9dd4-8774-4ca3-824f-3419fcd13ec8:1 | |
17:09:44.828 DEBUG [taskExecutor-1][org.springframework.integration.transformer.MessageTransformingHandler] org.springframework.integration.transformer.MessageTransformingHandler@43b69758 received message: GenericMessage [payload=100.0, headers={timestamp=1425733784827, id=c5c01189-cc0b-ac17-8bc1-06f5c7d4dffd, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@12420d74, gatherResultChannel=5c6f9dd4-8774-4ca3-824f-3419fcd13ec8:1, correlationId=20e8f205-c3c1-db17-fc14-3acb7f7314e1, replyChannel=ch2, sequenceSize=2, sequenceNumber=1}] | |
17:09:44.828 DEBUG [main][org.springframework.integration.channel.PublishSubscribeChannel] postSend (sent=true) on channel 'scatter_channel', message: GenericMessage [payload=100.0, headers={timestamp=1425733784826, id=20e8f205-c3c1-db17-fc14-3acb7f7314e1, gatherResultChannel=5c6f9dd4-8774-4ca3-824f-3419fcd13ec8:1, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@12420d74, replyChannel=ch2}] | |
17:09:44.828 DEBUG [taskExecutor-1][org.springframework.beans.factory.support.DefaultListableBeanFactory] Returning cached instance of singleton bean 'integrationEvaluationContext' | |
17:09:44.828 DEBUG [taskExecutor-2][org.springframework.integration.transformer.MessageTransformingHandler] org.springframework.integration.transformer.MessageTransformingHandler@29a69136 received message: GenericMessage [payload=100.0, headers={timestamp=1425733784827, id=87496b13-ec4d-00a6-884b-2d3a69f9edf6, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@12420d74, gatherResultChannel=5c6f9dd4-8774-4ca3-824f-3419fcd13ec8:1, correlationId=20e8f205-c3c1-db17-fc14-3acb7f7314e1, replyChannel=ch2, sequenceSize=2, sequenceNumber=2}] | |
17:09:44.828 DEBUG [taskExecutor-2][org.springframework.beans.factory.support.DefaultListableBeanFactory] Returning cached instance of singleton bean 'integrationEvaluationContext' | |
17:09:44.829 DEBUG [taskExecutor-1][org.springframework.integration.aggregator.AggregatingMessageHandler] org.springframework.integration.handler.ScatterGatherHandler#0.gatherer received message: GenericMessage [payload=3.0, headers={timestamp=1425733784829, id=5201ab00-d1de-477f-c2dd-97635f21db04, gatherResultChannel=5c6f9dd4-8774-4ca3-824f-3419fcd13ec8:1, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@12420d74, replyChannel=ch2, correlationId=20e8f205-c3c1-db17-fc14-3acb7f7314e1, sequenceSize=2, sequenceNumber=1}] | |
17:09:44.829 DEBUG [taskExecutor-2][org.springframework.integration.aggregator.AggregatingMessageHandler] org.springframework.integration.handler.ScatterGatherHandler#0.gatherer received message: GenericMessage [payload=2.0, headers={timestamp=1425733784829, id=0223fe83-8619-5340-a0ac-de9a6e02f587, gatherResultChannel=5c6f9dd4-8774-4ca3-824f-3419fcd13ec8:1, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@12420d74, replyChannel=ch2, correlationId=20e8f205-c3c1-db17-fc14-3acb7f7314e1, sequenceSize=2, sequenceNumber=2}] | |
17:09:44.829 DEBUG [taskExecutor-1][org.springframework.integration.aggregator.AbstractCorrelatingMessageHandler] Handling message with correlationKey [20e8f205-c3c1-db17-fc14-3acb7f7314e1]: GenericMessage [payload=3.0, headers={timestamp=1425733784829, id=5201ab00-d1de-477f-c2dd-97635f21db04, gatherResultChannel=5c6f9dd4-8774-4ca3-824f-3419fcd13ec8:1, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@12420d74, replyChannel=ch2, correlationId=20e8f205-c3c1-db17-fc14-3acb7f7314e1, sequenceSize=2, sequenceNumber=1}] | |
17:09:44.829 DEBUG [taskExecutor-2][org.springframework.integration.aggregator.AbstractCorrelatingMessageHandler] Handling message with correlationKey [20e8f205-c3c1-db17-fc14-3acb7f7314e1]: GenericMessage [payload=2.0, headers={timestamp=1425733784829, id=0223fe83-8619-5340-a0ac-de9a6e02f587, gatherResultChannel=5c6f9dd4-8774-4ca3-824f-3419fcd13ec8:1, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@12420d74, replyChannel=ch2, correlationId=20e8f205-c3c1-db17-fc14-3acb7f7314e1, sequenceSize=2, sequenceNumber=2}] | |
17:09:44.831 DEBUG [taskExecutor-1][org.springframework.integration.channel.DirectChannel] postSend (sent=true) on channel 'ch2', message: GenericMessage [payload=3.0, headers={timestamp=1425733784829, id=5201ab00-d1de-477f-c2dd-97635f21db04, gatherResultChannel=5c6f9dd4-8774-4ca3-824f-3419fcd13ec8:1, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@12420d74, replyChannel=ch2, correlationId=20e8f205-c3c1-db17-fc14-3acb7f7314e1, sequenceSize=2, sequenceNumber=1}] | |
17:09:44.831 DEBUG [taskExecutor-2][org.springframework.integration.aggregator.AbstractCorrelatingMessageHandler] Completing group with correlationKey [20e8f205-c3c1-db17-fc14-3acb7f7314e1] | |
17:09:44.832 DEBUG [taskExecutor-2][org.springframework.integration.channel.DefaultHeaderChannelRegistry] Retrieved org.springframework.integration.channel.QueueChannel@56849d45 with 5c6f9dd4-8774-4ca3-824f-3419fcd13ec8:1 | |
17:09:44.832 DEBUG [taskExecutor-2][org.springframework.integration.channel.QueueChannel] postSend (sent=true) on channel 'org.springframework.integration.channel.QueueChannel@56849d45', message: GenericMessage [payload=[3.0, 2.0], headers={timestamp=1425733784831, id=45680b20-ae71-1454-3359-23c3be318efa, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@12420d74, gatherResultChannel=5c6f9dd4-8774-4ca3-824f-3419fcd13ec8:1, correlationId=20e8f205-c3c1-db17-fc14-3acb7f7314e1, replyChannel=ch2, sequenceSize=2, sequenceNumber=2}] | |
17:09:44.832 DEBUG [main][org.springframework.integration.channel.QueueChannel] postReceive on channel 'org.springframework.integration.channel.QueueChannel@56849d45', message: GenericMessage [payload=[3.0, 2.0], headers={timestamp=1425733784831, id=45680b20-ae71-1454-3359-23c3be318efa, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@12420d74, gatherResultChannel=5c6f9dd4-8774-4ca3-824f-3419fcd13ec8:1, correlationId=20e8f205-c3c1-db17-fc14-3acb7f7314e1, replyChannel=ch2, sequenceSize=2, sequenceNumber=2}] | |
17:09:44.832 DEBUG [taskExecutor-2][org.springframework.integration.channel.DirectChannel] postSend (sent=true) on channel 'ch2', message: GenericMessage [payload=2.0, headers={timestamp=1425733784829, id=0223fe83-8619-5340-a0ac-de9a6e02f587, gatherResultChannel=5c6f9dd4-8774-4ca3-824f-3419fcd13ec8:1, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@12420d74, replyChannel=ch2, correlationId=20e8f205-c3c1-db17-fc14-3acb7f7314e1, sequenceSize=2, sequenceNumber=2}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment