Reputation: 161
I'introducin spring integration instead legacy integration architecture in our project. This architecture supports Senders and Recievers. Each sender can be configured with 3 destinations.
Spring integration gateways looks suitable. I can use default-request-channel for main flow, error-channel for fail flow. The problem with backup flow. How can I copy gateway incoming message and place it to the backup channel?
PS To be more precise here is a test and code.
https://github.com/semenodm/Coding-Exercises/tree/master/spring-integration/spring-integration/src
Test i_want_my_sender_put_message_into_fail_queue_when_sending_failed is failed because Wire Tap will always put message into its queue regardless of fail or success of main stream.
I don't want to add custom interceptors to handle this logic and cope with this problem using configuration.
Upvotes: 0
Views: 856
Reputation: 174739
If you subscribe both adapters to a direct channel, with no load balancing and set an order attribute on each subscriber, the framework will automatically fail over to the second adapter if the first throws an exception.
<int:channel id="foo>
<int:dispatcher load-balancer="none" />
</int:channel>
<... id="primary" order="1" .../>
<... id="secondary" order="2" .../>
The default load-balancer is round-robin.
Another option would be to use the new ExpressionEvaluatingMessageHandlerAdvice in the upcoming 2.2 release...
http://blog.springsource.org/2012/10/09/spring-integration-2-2-retry-and-more/
Upvotes: 0
Reputation: 506
You might want to consider adding a Wire Tap that sends to "backupChannel".
See: http://static.springsource.org/spring-integration/docs/2.1.x/reference/htmlsingle/#channel-wiretap
Upvotes: 0