qpid-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marnie McCormack (JIRA)" <qpid-...@incubator.apache.org>
Subject [jira] Created: (QPID-103) Implement support for MessageListener interface
Date Thu, 16 Nov 2006 13:53:37 GMT
Implement support for MessageListener interface

                 Key: QPID-103
                 URL: http://issues.apache.org/jira/browse/QPID-103
             Project: Qpid
          Issue Type: Bug
          Components: Java Client
            Reporter: Marnie McCormack
             Fix For: M2

See AMQSession.get/setMessageListener methods which currently throw UnsupportedOperationException.

See javadoc/JMS spec.

The snippet below talks a little about the MessageListener interface (from JMS specification):

9.3.1 Receiving Messages Asynchronously

In order to receive message asynchronously as they are delivered to the message consumer,
the client program needs to create a message listener that implements the MessageListener
interface. An implementation of the MessageListener interface, called StockListener.java,
might look like this:

import javax.jms.*;
public class StockListener implements MessageListener
public void onMessage(Message message) {
/* Unpack and handle the messages received */
The client program registers the MessageListener object with the MessageConsumer object in
the following way:

StockListener myListener = new StockListener();

/* Receiver is MessageConsumer object */

The Connection must be started for the message delivery to begin. The MessageListener is asynchronously
notified whenever a message has been published to the Queue. This is done via the onMessage
method in the MessageListener interface. It is up to the client to process the message there.

JMS Example Code—April 12, 2002 105
public void onMessage(Message message)
String newStockData;
/* Unpack and handle the messages received */
newStockData = message.getText();
/* Logic related to the data */

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


View raw message