Publish Subscribe using Selector Process.
This is another publish and subscribe design pattern variant.
We can implement this design pattern using JMS message selector API. Publisher publish the messages in a common queue. Selector process listen to that queue and send the messages to destination specific queue.
Selector process use specific filter criteria to send the messages to different destination queue.
We need at least 4 process to implement this design pattern.
Publisher process: this is the same as describer in earlier section
Selector process.
This process use selection criteria to select the messages from the common queue. This can be a batch process or listener process.
The selector’s process select the messages from the common queue on the basis of filter criteria and move the messages to the destination specific queue.
We can have multiple selector process depending on the use case. We can have separate selector process for each destination. In this case governance, error handling and monitoring of the process would be easier.
Subscriber process: as described in earlier section. Normally you should have separate subscriber process for each destination.
Batch process to handle failed messages.
You should have separate batch process to handle the failed messages for each destination. It would provide you more control and granularity. If you can parameterize your connection URL you can run the same batch jobs with different connection parameter. Normally you should have single table to hold the all error messages.