org.apache.qpid.topic
Class Listener

java.lang.Object
  extended by org.apache.qpid.topic.Listener
All Implemented Interfaces:
MessageListener

public class Listener
extends Object
implements MessageListener

This class has not kept up to date with the topic_listener in the cpp tests. It should provide identical behaviour for cross testing the java and cpp clients.

How the cpp topic_publisher operates: It publishes text messages to the default topic exchange, on virtual host "/test", on the topic "topic_control", for the specified number of test messages to be sent. It publishes a report request message (on same topic), with the header text field "TYPE", value "REPORT_REQUEST", optionally within a transaction, and waits for the specified number of consumers to reply to this request. The listeners should reply to this message on a queue named "response", on virtual host "/test", with some sort of message about the number of messages received and how long it took, although the publisher never looks at the message content. The publisher then send a message (on the same topic), with the header text field "TYPE", value "TERMINATION_REQUEST", which the listener should close its connection and terminate upon receipt of.

Todo:
I've added lots of field table types in the report message, just to check if the other end can decode them correctly. Not really the right place to test this, so remove them from createReportResponseMessage(String) once a better test exists.

Field Summary
static String CONTROL_TOPIC
           
static String RESPONSE_QUEUE
           
 
Constructor Summary
Listener(Connection connection, int ackMode, String name)
           
 
Method Summary
(package private)  MessageProducer createControlPublisher()
           
(package private)  MessageConsumer createDurableTopicConsumer(String name)
           
(package private)  Message createReportResponseMessage(String msg)
           
(package private)  MessageConsumer createTopicConsumer()
           
(package private)  boolean isReport(Message m)
           
(package private)  boolean isShutdown(Message m)
           
static void main(String[] argv)
           
 void onMessage(Message message)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTROL_TOPIC

public static final String CONTROL_TOPIC
See Also:
Constant Field Values

RESPONSE_QUEUE

public static final String RESPONSE_QUEUE
See Also:
Constant Field Values
Constructor Detail

Listener

Listener(Connection connection,
         int ackMode,
         String name)
   throws Exception
Throws:
Exception
Method Detail

main

public static void main(String[] argv)
                 throws Exception
Throws:
Exception

onMessage

public void onMessage(Message message)
Specified by:
onMessage in interface MessageListener

createReportResponseMessage

Message createReportResponseMessage(String msg)
                              throws JMSException
Throws:
JMSException

isShutdown

boolean isShutdown(Message m)
             throws JMSException
Throws:
JMSException

isReport

boolean isReport(Message m)
           throws JMSException
Throws:
JMSException

createTopicConsumer

MessageConsumer createTopicConsumer()
                              throws Exception
Throws:
Exception

createDurableTopicConsumer

MessageConsumer createDurableTopicConsumer(String name)
                                     throws Exception
Throws:
Exception

createControlPublisher

MessageProducer createControlPublisher()
                                 throws Exception
Throws:
Exception


Licensed to the Apache Software Foundation