org.apache.qpid.test.utils
Class ConversationFactory.Conversation

java.lang.Object
  extended by org.apache.qpid.test.utils.ConversationFactory.Conversation
Enclosing class:
ConversationFactory

public class ConversationFactory.Conversation
extends Object

Used to hold a conversation context. This consists of a correlating id for the conversation, and a reply destination automatically updated to the last received reply-to destination.


Field Summary
(package private)  long conversationId
          Holds the correlation id for the context.
(package private)  Destination sendDestination
          Holds the send destination for the context.
 
Constructor Summary
ConversationFactory.Conversation()
           
 
Method Summary
 void end()
          Completes the conversation.
 Message receive()
          Gets the next message in an ongoing conversation.
 Collection<Message> receiveAll(int num, long timeout)
          Gets many messages in an ongoing conversation.
 void send(Destination sendDestination, Message message)
          Sends a message to the default sending location.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

conversationId

long conversationId
Holds the correlation id for the context.


sendDestination

Destination sendDestination
Holds the send destination for the context. This will automatically be updated to the most recently received reply-to destination.

Constructor Detail

ConversationFactory.Conversation

public ConversationFactory.Conversation()
Method Detail

send

public void send(Destination sendDestination,
                 Message message)
          throws JMSException
Sends a message to the default sending location. The correlation id of the message will be assigned by this method, overriding any previously set value.

Parameters:
sendDestination - The destination to send to. This may be null to use the last received reply-to destination.
message - The message to send.
Throws:
JMSException - All undelying JMSExceptions are allowed to fall through. This will also be thrown if no send destination is specified and there is no most recent reply-to destination available to use.

receive

public Message receive()
                throws JMSException
Gets the next message in an ongoing conversation. This method may block until such a message is received.

Returns:
The next incoming message in the conversation.
Throws:
JMSException - All undelying JMSExceptions are allowed to fall through. Thrown if the received message did not have its reply-to destination set up.

receiveAll

public Collection<Message> receiveAll(int num,
                                      long timeout)
                               throws JMSException
Gets many messages in an ongoing conversation. If a limit is specified, then once that many messages are received they will be returned. If a timeout is specified, then all messages up to the limit, received within that timespan will be returned. At least one of the message count or timeout should be set to a value of 1 or greater.

Parameters:
num - The number of messages to receive, or all if this is less than 1.
timeout - The timeout in milliseconds to receive the messages in, or forever if this is less than 1.
Returns:
All messages received within the count limit and the timeout.
Throws:
JMSException - All undelying JMSExceptions are allowed to fall through.

end

public void end()
Completes the conversation. Any correlation id's pertaining to the conversation are no longer valid, and any incoming messages using them will go to the dead letter box.



Licensed to the Apache Software Foundation