I am using Glassfish and OpenMQ for a remote Consumer instance to look up a message Producer's queue and process requests synchronously.
According to McIntosh's answer on Synchronous Consumer with JMS Queue, synchronous message receiving can be handled via scheduling. I plan on doing this, but I have only seen examples of connecting to a message queue by way of an asynchronous Message Driven Bean (MDB), as shown below:
import javax.jms.MessageListener;
import javax.annotation.Resource;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.ejb.MessageDrivenContext;
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "addressList", propertyValue = "mq://localhost:54020/"), //found in Producer server's domain.xml as JMS_PROVIDER_PORT
@ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "jms/ProducerRequestMessageQueue"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")})
public class ConsumerNode extends Node implements MessageListener {
@Resource
private MessageDrivenContext _mdc;
public ConsumerNode() {
super();
}
@Override
public void onMessage(Message message) {
//process message...
}
}
How do I connect to the remote Producer queue without implementing MessageListener
and setting up as a Message Driven Bean?