org.apache.qpid.test.utils
Class QpidClientConnectionHelper

java.lang.Object
  extended by org.apache.qpid.test.utils.QpidClientConnectionHelper
All Implemented Interfaces:
ExceptionListener

public class QpidClientConnectionHelper
extends Object
implements ExceptionListener

Todo:
This was originally cut and paste from the client module leading to a duplicate class, then altered very slightly. To avoid the duplicate class the name was altered slightly to have 'Helper' on the end in order to distinguish it from the original. Delete this class and use the original instead, just upgrade it to provide the new features needed.

Field Summary
protected  boolean connected
           
protected  Session session
           
 
Constructor Summary
QpidClientConnectionHelper(String broker)
           
 
Method Summary
 void connect()
           
 void consume(String queueName, int readTimeout)
          Completely clears a queue.
 void disconnect()
           
 void disconnectWithoutCommit()
           
 String getBrokerList()
           
 Message getNextMessage(String queueName)
          GET the top message on a queue.
 Message getNextMessage(String queueName, long readTimeout)
          GET the top message on a queue.
 Session getSession()
           
 String getVirtualHost()
           
 boolean isConnected()
           
 void onException(JMSException exception)
          override as necessary
 void put(String queueName, String payload, int copies, int deliveryMode)
          Put a String as a text messages, repeat n times.
 void setBrokerList(String brokerlist)
           
 void setPrefetch(int prefetch)
           
 void setVirtualHost(String virtualHost)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

session

protected Session session

connected

protected boolean connected
Constructor Detail

QpidClientConnectionHelper

public QpidClientConnectionHelper(String broker)
Method Detail

connect

public void connect()
             throws JMSException
Throws:
JMSException

disconnect

public void disconnect()
                throws JMSException
Throws:
JMSException

disconnectWithoutCommit

public void disconnectWithoutCommit()
                             throws JMSException
Throws:
JMSException

getBrokerList

public String getBrokerList()

setBrokerList

public void setBrokerList(String brokerlist)

getVirtualHost

public String getVirtualHost()

setVirtualHost

public void setVirtualHost(String virtualHost)

setPrefetch

public void setPrefetch(int prefetch)

onException

public void onException(JMSException exception)
override as necessary

Specified by:
onException in interface ExceptionListener

isConnected

public boolean isConnected()

getSession

public Session getSession()

put

public void put(String queueName,
                String payload,
                int copies,
                int deliveryMode)
         throws JMSException
Put a String as a text messages, repeat n times. A null payload will result in a null message.

Parameters:
queueName - The queue name to put to
payload - the content of the payload
copies - the number of messages to put
Throws:
JMSException - any exception that occurs

getNextMessage

public Message getNextMessage(String queueName,
                              long readTimeout)
                       throws JMSException
GET the top message on a queue. Consumes the message. Accepts timeout value.

Parameters:
queueName - The quename to get from
readTimeout - The timeout to use
Returns:
the content of the text message if any
Throws:
JMSException - any exception that occured

getNextMessage

public Message getNextMessage(String queueName)
                       throws JMSException
GET the top message on a queue. Consumes the message.

Parameters:
queueName - The Queuename to get from
Returns:
The string content of the text message, if any received
Throws:
JMSException - any exception that occurs

consume

public void consume(String queueName,
                    int readTimeout)
             throws JMSException,
                    InterruptedException
Completely clears a queue. For readTimeout behaviour see Javadocs for javax.jms.MessageConsumer.

Parameters:
queueName - The Queue name to consume from
readTimeout - The timeout for each consume
Throws:
JMSException - Any exception that occurs during the consume
InterruptedException - If the consume thread was interrupted during a consume.


Licensed to the Apache Software Foundation