1

I have a queue on Wildfly 8.2 (JMS with default HornetQ) which receives messages relative to different entities with different MDB Classes as consumers (one MDB Class for each Entity).

I use The JMSType to send messages relative to Entity A to the MDB_A and so on.

Now I want that all messages relative to the same instance of Entity A are managed by the same instance of MDB_A. Before I insert the message in the queue I set the same value for the property JMSXGroupID for messages relative to the same instance of A.

Then I print out in the MDB an identifier of the MDB and the JMSXGroupID of the message, but I see that messages with same JMSXGroupID are managed by different MDBs.

I found this thread talking of this issue for AciveMQ, but I'm using HornetQ so I don't know what is behaviour in this case.

In that thread an answer was

In this case the Message Listener is the MDB container not the individual MDB instances. MDB container is free to select any mdb instance to process the message it received.So I think the JMSXGroupID has no significance here.

but if messages with same JMSXMessageID are processed by different instances, what is the purpose of this property? Isn't it the same as setting a JMSType for the messages?

I also found that setting the JMSXMessageID for messages on a Queue without selectors let all the messages be processed by the same instance of MDB, even if I have multiple instances available.

Community
  • 1
  • 1
Wallkan
  • 480
  • 1
  • 8
  • 27

1 Answers1

0

You could try using JMS message selectors to ensure that specific types of messages are processed by specific MDBs.

For example, if you set a property on a JMS message like the following:

message.setStringProperty("mdbType", "orderMDB")

or

message.setStringProperty("mdbType", "registrationMDB")

Then for each MDB, you can specify which messages it is interested in processing by annotating it with something like:

@ActivationConfigProperty(propertyName = "messageSelector",
        propertyValue = "mdbType= 'orderMDB' OR mdbType= 'registrationMDB'")
  • Thanks for your answer, but this won't ensure me that all the messages of that type will be manged by the same instance, but only that all the messages will be managed by instances of the same MDB class. – Wallkan Apr 04 '17 at 09:29