Synchronous Message Processing –Hybrid Design pattern; Handle request and response message Asynchronously in case of failure.
This pattern is a variant of hybrid design pattern. The difference is response messages also needs to be queued in case of failure. The pattern is rarely used. To implement this pattern you should have 3 processes. 1 Main process and additional 2 batch processes.
Main Process.
- The main process will validate the request and if messages are ok, enrich and transform the messages and invoke provider service.
- The process will send the response in real time to the requester
- The process will send the failed messages( which could not be posted) to the request message queue.
- The process will send the response messages which could not be posted back to requester to response message queue.
Process 2.
This process should be a scheduled processes which will read the messages from the queue or database as similar to earlier hybrid design pattern.
Process 3.
This process should be scheduled process which will read the file from Response messages queue and will try to push the messages to the source or requester application. This is similar to process 2.
Use Case
This is similar to hybrid pattern use case. But here additionally we are saving provider response messages so that you don’t need to invoke provider we services again in case of connection failure with requester.