Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.aendvari.hermes.broker
Class MessageRequestor  view MessageRequestor download MessageRequestor.java

java.lang.Object
  extended bycom.aendvari.hermes.broker.MessageRequestor
All Implemented Interfaces:
MessageListener

public class MessageRequestor
extends java.lang.Object
implements MessageListener

Provides a mechanism to publish a message and listen for a response.

This effectively makes the message publish/listen process work similar to a method call. The listener receiving the initial message would check the "replyTo" property of the Message it receives. If a MessageTopic is provided, then a response message is expected.

The properties of the published and return messages must be agreed upon by both parties.


Field Summary
protected  MessageBrokerConnection connection
          The MessageBrokerConnection to publish through.
protected static int nextResponseIdentifier
          The next available response identifier.
protected  MessageTopic requestTopic
          The MessageTopic to publish requests to.
protected  Message response
          The response received from the request.
protected static java.lang.String ResponseTopic
          A prefix for the temporary topic receiving the response.
 
Constructor Summary
MessageRequestor(MessageBrokerConnection setConnection, MessageTopic setTopic)
          Constructs a MessageRequestor for the given connection and topic.
 
Method Summary
 void onMessage(Message message)
          Listens for a response.
 Message request(Message request)
          Publishes the specified message and returns the response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connection

protected MessageBrokerConnection connection
The MessageBrokerConnection to publish through.


requestTopic

protected MessageTopic requestTopic
The MessageTopic to publish requests to.


response

protected Message response
The response received from the request.


nextResponseIdentifier

protected static int nextResponseIdentifier
The next available response identifier.


ResponseTopic

protected static final java.lang.String ResponseTopic
A prefix for the temporary topic receiving the response.

See Also:
Constant Field Values
Constructor Detail

MessageRequestor

public MessageRequestor(MessageBrokerConnection setConnection,
                        MessageTopic setTopic)
Constructs a MessageRequestor for the given connection and topic.

Method Detail

request

public Message request(Message request)
Publishes the specified message and returns the response.


onMessage

public void onMessage(Message message)
Listens for a response.

Specified by:
onMessage in interface MessageListener