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.
- The main data flow, where messages should delivered. That can be file system, jms, mail, etc
- Backup flow. Store each received message into backup destination. Usually it's file appender where each message stored at the end of the file. That can also be jms queue. Backup gives us a chance to get message and replay if entire system failed and data loss
- Fail flow. If we cannot send message to destination (no connection, formatted failed to create message) messages are placed into this queue.
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.