spring.loan.broker
spring.loan.broker copied to clipboard
spring.loan.broker
Spring loan broker demostrate how you can develop a non-blocking rest service in a spring based application. Below are some of the captured logs from one of the test execution. Read below article for more detail.
https://dzone.com/articles/non-blocking-rest-services-with-spring
[http-nio-8080-exec-1] DispatcherServlet - DispatcherServlet with name 'dispatcherServlet' processing GET request for [/quotation]
....
[http-nio-8080-exec-1] DynamicJmsTemplate - Sending created message: ActiveMQObjectMessage {commandId = 0, responseRequired = false,properties = {quote=1020.0, sequenceSize=2, loan_broker_selector=07e93936-7bcc-45b6-be5a-0126a965eed5, loan_request_claim=5d59c870-60ab-3892-444f-37bd61461731, correlation_Id=5d59c870-60ab-3892-444f-37bd61461731}
....
[http-nio-8080-exec-1] DynamicJmsTemplate - Sending created message: ActiveMQObjectMessage {commandId = 0, responseRequired = false,properties = {quote=1020.0, sequenceSize=2, loan_broker_selector=07e93936-7bcc-45b6-be5a-0126a965eed5, loan_request_claim=5d59c870-60ab-3892-444f-37bd61461731, correlation_Id=5d59c870-60ab-3892-444f-37bd61461731}
....
[http-nio-8080-exec-1] WebAsyncManager - Concurrent handling starting for GET [/quotation]
[http-nio-8080-exec-1] DispatcherServlet - Leaving response open for concurrent processing
....
[org.springframework.jms.listener.DefaultMessageListenerContainer#3-2] BankStub - >> Callculating best quotation for price 1020.0 is 51.0. Where approx. calculation time is 1010 ms.
....
[org.springframework.jms.listener.DefaultMessageListenerContainer#0-5] AggregatingMessageHandler - org.springframework.integration.handler.MessageHandlerChain#1$child#0.handler received message: GenericMessage [payload=51.0, headers={timestamp=1450496257021, id=9f1d7387-b06a-8086-e356-0737d7ac6f6c, jms_timestamp=1450496257014, jms_redelivered=false, priority=4, quote=1020.0, sequenceSize=2, loan_broker_selector=07e93936-7bcc-45b6-be5a-0126a965eed5, loan_request_claim=5d59c870-60ab-3892-444f-37bd61461731, correlation_Id=5d59c870-60ab-3892-444f-37bd61461731, jms_messageId=ID:Husains-MacBook-Pro.local-53176-1450496240701-3:1:39:1:1}]
....
[org.springframework.jms.listener.DefaultMessageListenerContainer#2-3] BankStub - >> Callculating best quotation for price 1020.0 is 40.800000000000004. Where approx. calculation time is 1077 ms.
....
[org.springframework.jms.listener.DefaultMessageListenerContainer#1-1] AggregatingMessageHandler - org.springframework.integration.handler.MessageHandlerChain#1$child#0.handler received message: GenericMessage [payload=40.800000000000004, headers={timestamp=1450496257088, id=729752b7-f8f0-b952-bcda-36379de76fa3, jms_timestamp=1450496257083, jms_redelivered=false, priority=4, quote=1020.0, sequenceSize=2, loan_broker_selector=07e93936-7bcc-45b6-be5a-0126a965eed5, loan_request_claim=5d59c870-60ab-3892-444f-37bd61461731, correlation_Id=5d59c870-60ab-3892-444f-37bd61461731, jms_messageId=ID:Husains-MacBook-Pro.local-53176-1450496240701-3:1:28:1:1}]
....
[org.springframework.jms.listener.DefaultMessageListenerContainer#1-1] AbstractCorrelatingMessageHandler - Completing group with correlationKey [5d59c870-60ab-3892-444f-37bd61461731]
....
[org.springframework.jms.listener.DefaultMessageListenerContainer#1-1] LoggingHandler - org.springframework.integration.handler.LoggingHandler#0 received message: GenericMessage [payload=40.800000000000004, headers={errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@2f92b51, result=40.800000000000004, jms_timestamp=1450496257083,
....
[org.springframework.jms.listener.DefaultMessageListenerContainer#1-1] WebAsyncManager - Concurrent result value [<200 OK,40.800000000000004,{}>] - dispatching request to resume processing
....
[http-nio-8080-exec-2] RequestMappingHandlerAdapter - Found concurrent result value [<200 OK,40.800000000000004,{}>]
....
[http-nio-8080-exec-2] DispatcherServlet - Successfully completed request
You can test timeout scenario by requesting loan amount <= 10. This will fail outcome from one of the bank. Failure strategy is subjective to requirement. Hence, in this example partial failures are not acceptable. In case you are interested to load test the example, you can find JMeter test plan in source code.