From an EJB or a POJO deployed on Glassfish I can connect to HornetMQ with the following code, after I add to classpath the necessary hornet specific jars:
Properties properties = new Properties();
properties.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
// server name
properties.put("java.naming.provider.url", "jnp://hostname:1099");
properties.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
InitialContext initialContext = new InitialContext(properties);
// queue name
Queue queue = (Queue)initialContext.lookup("/queue/exampleQueue");
// connection factory
ConnectionFactory connectionFactory = (ConnectionFactory) initialContext.lookup("ConnectionFactory");
Connection conn = connectionFactory.createConnection();
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
conn.start();
// ...
But I want to do the same from a Message Driven Bean.
With a MDB it's very easy if I use the embedded Glassfish provider; but how do I configure GF to use a remote provider?
Any ideas? Thank you!
EDIT: to make things a little clearer; a typical MDB looks something like this:
@MessageDriven(mappedName = "/queue/exampleQueue", activationConfig = {
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
})
public class MessageProcessor implements MessageListener {
public MessageProcessor() {
}
public void onMessage(Message message) {
}
}
But in this case, the MDB will look for "/queue/exampleQueue" on the local server not the remote one.
Basically my question is how do I configure GF to look for the remote server (as in the first snippet) when using a MDB?