Search code examples
javarestjakarta-eejava-ee-6websphere-8

Message Queue Listener and RESTful integration


My project publishes RESTful/SOAP services. One of these sends messages to a JMS queue on a Websphere application server. The application runs on the same application server. What I need is to define a listener to this queue. How can I activate this listener without a direct call from the service?

The project structure looks like this:

Project:
  -ejb
  -rest
  -soap

The user calls methods on the service, which calls the EJB component, so I dont have any main method where I can init the listener.

I need a solution which activates a permanent listener to the queue.

I already have the source code I just don't know how to initialize the listener.


Solution

  • WebSphere MDB with a lot of configuration it works!!!! But look at this:

        @MessageDriven(activationConfig={
                    @ActivationConfigProperty(propertyName="destination",     propertyValue="myDestination"),
                    @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue")
    })
    public class MsgBean implements javax.jms.MessageListener {
    
      public void onMessage(javax.jms.Message msg) {
    
          String receivedMsg = ((TextMessage) msg).getText();
          System.out.println("Received message: " + receivedMsg);
    
       }
    
    }