In activeMQ when the an producer application sets the JMSXGroupID while posting a message and there are 2 instances of a consumer application running, activeMQ seems to have a JMSXGroupID to active consumers mapping internally. This is causing the activeMQ to send the messages with the same JMSXGroupID value to the same consumer instance, and if consumer 1 instance goes down then the activeMQ seems to change its mapping and starts sending the load which was meant for consumer 1 to consumer 2. This seems to be like a dynamic load balancing based on JMSXGroupID and number of active consumers.
But in IBMMQ this doesn't seem to be the case. We could go with the selector concept but thats only good if the no. of instances are always static, but then again this cannot dynamically load balance the messages if the no. of instances changes. Is there any way where we can have the same dynamic load balancing behaviour that is shown by activeMQ while using IBMMQ?
For activeMQ & IBMMQ, we tested with code change made at the message publishing section where we set the header "JMSXGroupID" with a value.
It worked for activeMQ and it did not work for IBMMQ. We would like to achieve the same behaviour of activeMQ for IBMMQ
Edit:
We set the group id under the "JMSXGroupID" header while sending it via producer template of Apache Camel. The same test was done with both just by swapping the underlying Connection Factory for both activeMQ and IBMMQ. It is possible to set the Group id but it looks like IBM is not doing the load balancing on its own like activeMQ even though We use the same code snippet for publishing message. Find the code snippet below:
public void postMessage() {
Map<String,Object> messageHeaders = new HashMap<>();
String groupId = String.valueOf(System.currentTimeMillis()%2);
messageHeaders.put("JMSXGroupID", groupId);
producerTemplate.sendBodyAndHeaders("mq:TESTQ", "Sample Test with group id : "+groupId, messageHeaders);
log.info("Published message with headers : {}",messageHeaders);
}