Reputation: 186
I am developing an application which used JMS as the messaging layer. I'm also using glassfish to host the jms/mq backend. The application is able to do pub/sub messaging using a connection factory and topic in the glassfish 3.1 server that I originally set up. I now have another instance of glassfish (4.1) that hosts a new set of functionality that a new suite of applications uses, but I still need to consume the messages broadcast by the first glassfish server. The fact that the clients use new libraries specific to glassfish 4.1, I can't connect directly to the glassfish1 server.
I have followed this tutorial regarding multi-server environments (https://docs.oracle.com/cd/E19798-01/821-1841/bncfp/index.html) and the stand-alone java clients all use the connection factory set up in the new glassfish server to connect to the old glassfish server. I know the connection is being made because if I stop glassfish1, I get connection dropped errors, etc.
The relevant client code is as follows:
System.setProperty("org.omg.CORBA.ORBInitialHost", "10.20.10.52");
System.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
try {
try {
ctx = new InitialContext();
} catch (NamingException ex) {
ex.printStackTrace();
}
ConnectionFactory cf = (ConnectionFactory) ctx.lookup("jms/ConnectionFactory");
Connection connection = cf.createConnection();
jmsContext = cf.createContext(Session.AUTO_ACKNOWLEDGE);
topic = (Topic) ctx.lookup("jms/Topic");
updateShipperConsumer = jmsContext.createConsumer(topic);
jmsProducer = jmsContext.createProducer();
logger.info("Started JMS successfully!");
} catch (NamingException ex) {
ex.printStackTrace();
} catch (JMSException ex) {
Logger.getLogger(LamtecJMSSystemImpl.class.getName()).log(Level.SEVERE, null, ex);
}
}
The jms/ConnectionFactory jndi is a local connection factory on glassfish2 that has an AddressList property set to glassfish1:7676. There is a corresponding connection factory on glassfish1 with the same name, as suggested by the tutorial. Looking at the imq log files on the glassfish1 server, I see that the connection from glassfish2 is made.
I'm not sure I should be doing a lookup on the topic jndi (which I have locally, as well as on the remote server), but I don't think that has made a difference.
According to the tutorial that I referenced above, I have done everything needed configuration and code-wise, but I still don't get any jms messages in my clients. Any ideas?
Upvotes: 1
Views: 1026
Reputation:
I can advise about JMS queues, probably for topics is similar or same solution. You can create queues with same names on both servers, and let the first queue push its messages to the second one using glassfish configuration, so let the imq brokers do the job. Configure the jms connection factory on the first server with the property "AddressList" with value "mq://host2:port2" with the settings for the second broker.
See the glassfish resource template for such a configuration in the OSCM Service Catalog https://github.com/servicecatalog/development/blob/master/oscm-installation/domains/bes_domain/installer/resources-template.xml
The example is the connection factory "jms/bss/masterIndexerQueueFactory" which you can find in this template.
More about the Open Source Project OSCM Cloud Service Management Software
Upvotes: 2