Tips for my scenario + receiving adminstrative messages on MDB?
pjr69 Mar 7, 2013 6:59 AMMy scenario:
- One server running JBoss 7.1.1.Final running the stock standalone-full-ha.xml configuration
- Several clients that come and go, Java SE desktop applications with Embedded HornetQ 2.2.19.Final.
- The clients are configured into same cluster with the server.
On the server I have several MDBs that receive service requests from the clients. Each MDB has a separate known queue name (that's how the clients find them) which are also configured on the client side using the hornetq-jms.xml-file. The clients are able to send messages to the MDBs, that much I have verified. However, The MDBs should also be able to send replies to the clients as asynchronous JMS-messages and getting this to work is a bit problematic. The clients do pass their individual unique reply-queue names in the jmsReplyTo-property to the MDBs when making the service requests so the MDBs do know the name of the specific client queue where it should send the reply message once it's finished the service request. But AFAIU, I need to create this queue also on the server side before the server is able to send the reply to the client.
Does that sound feasible use case?
I have two ideas:
a) When a MDB receives first request from client XYZ, it creates programmatically a queue named "XYZReplies" if it doesn't exist. This queue should be re-used by other MDBs until the client dies (=there are no more consumers to this queue), then it could be removed. So as there are multiple MDBs, the MDB should always check of the queue exists before trying to create it, and if it does, then just re-use it.
b) Make a "manager MDB" on server that receives notification about the clustering bridge being formed and then creates a client-specific queue based on some unique identifier on the bridge. So, when the server is running and client XYZ starts it's embedded HornetQ Server and it forms a bridge with the HornetQ server running on the server, I'd get notification about this on the server and use that notification to create the client-specific queue so the MDBs can send service replies to that queue and the client would be listening to the queue. The point is that the name of the queue would be derived so that both client and server create equally named queues so they match. If the client is shutdown, there would be another notification and I would then programmatically destroy the queue.
Any comments / ideas on my solutions?
For b) I've tried to make a MDB like this:
@MessageDriven(name = "MyManager", activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "topic/NotificationDestination") })
public class MyManager implements MessageListener {
@Override
public void onMessage(Message msg) {
System.out.println("GOT MESSAGE!"); // check here about bridges coming/going and create/destroy client-reply-queues accordingly
}
}
And just dropped that to JBoss deployment and it gets registered, but I never get any messages and no console output (when I start the client, I do get BridgeImpl output about the bridge formation, so that works, but no callback to my MyManager onMessage...). Should I be able to capture management messages (specifically about bridge creationg/destroying) like that?