DevJam
DevJam

Reputation: 19

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.

Upvotes: 0

Views: 1114

Answers (2)

DevJam
DevJam

Reputation: 19

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);

   }

}

Upvotes: 0

Puce
Puce

Reputation: 38142

Not sure where you have the issues:

Do something like:

  • define the JMS resources in WebSphere
  • inject the javax.jms.Queue as a Resource (or maybe using CDI? Not sure if CDI supports this) in a EJB
  • use this Queue to send messages
  • define a MDB (@MessageDriven) to listen for messages

Upvotes: 1

Related Questions