this is what I want to achieve with IBM MQ:
I have a topic in place, and 2 different applications (A1,A2) subscribing the topic. each application has 2 instances, i.e. (A1-I1,A1-I2,A2-I1,A2-I2). when a message (M1) is published to the topic, the message will be received by both applications A1 & A2. but within A1, only one instance (A1-I1 or A1-I2) can receive this message M1, the same goes to instances of A2.
is it possible with IBM MQ topics and JMS?
I have looked up shared subscription mentioned in the comment, but I find it (IBM MQ) has a limitation that the shared subscription can only be accessed by one JVM, i.e. two application instances can't access the the shared subscription at the same time, so I give up this purely pub/sub direction.
I managed to make it work by making the applications listen to the destination queue of subscription instead of directly subscription. I defined in the queue manager subscription SUB.A1 with destination queue of SUB.A1.QUEUE and subscription SUB.A2 with destination queue of SUB.A2.QUEUE. all instances of application A1 will listen to SUB.A1.QUEUE and A2 to SUB.A2.QUEUE. and everything works as expected.
The above setup is all applications connecting to the same queue manager. if there is a queue manager cluster of multiple QMs, just define the subscription destination queues as cluster queues and it will work as well