com.resilientedge.jockey.peer
Class MessageBrokerImpl

java.lang.Object
  |
  +--com.resilientedge.jockey.peer.MessageBrokerImpl
All Implemented Interfaces:
MessageBroker

public class MessageBrokerImpl
extends java.lang.Object
implements MessageBroker

The MessageBrokerImpl enables a applications to send messages, requests and replies to other apps.

Version:
$Revision: 1.1.1.1 $
Author:
John Gardner

Constructor Summary
MessageBrokerImpl(PeerGroupToken group)
          No-arg constructor.
 
Method Summary
 void addMessageListener(AppToken app, MessageListener listener)
          Add a listener that wishes to receive message notifications.
 void distribute(AppToken destApp, PeerMessage message)
          Distribute a message to waiting listeners.
 void distribute(PeerMessage message)
          Distribute a message to waiting listeners.
 void distributeResponse(ResponseMarker marker, PeerMessage message)
          Distribute a message to waiting listeners.
 void removeMessageListener(AppToken app, MessageListener listener)
          Remove an entity from the list of those interested in messages notifications.
 ResponseMarker sendAsyncRequest(AppToken destApp, PeerMessage request, int timeout)
          Sends an asynchronous request to a app, informing the registered MessageListener when the response is received or the timeout has been exceeded.
 SendMarker sendMessage(AppToken destApp, PeerMessage message)
          Sends a message asynchronously, returning a SendMarker for tracking the progress of the message transmission.
 PeerMessage sendRequest(AppToken destApp, PeerMessage request, int timeout)
          Sends a request to a app, waiting until the response is received or until the timeout is exceeded.
 SendMarker sendResponse(PeerMessage request, PeerMessage message)
          Sends an asynchronous reply to a peer's request, informing the registered MessageListener when the send has completed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageBrokerImpl

public MessageBrokerImpl(PeerGroupToken group)
No-arg constructor.
Method Detail

sendRequest

public PeerMessage sendRequest(AppToken destApp,
                               PeerMessage request,
                               int timeout)
                        throws java.io.IOException
Sends a request to a app, waiting until the response is received or until the timeout is exceeded.
Specified by:
sendRequest in interface MessageBroker
Parameters:
destApp - app to receive request
request - request to send
timeout - time (in seconds) to wait for response
Returns:
response message from app

sendMessage

public SendMarker sendMessage(AppToken destApp,
                              PeerMessage message)
                       throws java.io.IOException
Sends a message asynchronously, returning a SendMarker for tracking the progress of the message transmission.
Specified by:
sendMessage in interface MessageBroker
Parameters:
destApp - app to receive request
message - message to send
Returns:
marker to identify send progress

sendAsyncRequest

public ResponseMarker sendAsyncRequest(AppToken destApp,
                                       PeerMessage request,
                                       int timeout)
                                throws java.io.IOException
Sends an asynchronous request to a app, informing the registered MessageListener when the response is received or the timeout has been exceeded.
Specified by:
sendAsyncRequest in interface MessageBroker
Parameters:
destApp - app to receive request
request - request to send
timeout - time (in seconds) to wait for response
Returns:
marker to identify matching response

sendResponse

public SendMarker sendResponse(PeerMessage request,
                               PeerMessage message)
                        throws java.io.IOException
Sends an asynchronous reply to a peer's request, informing the registered MessageListener when the send has completed.
Specified by:
sendResponse in interface MessageBroker
Parameters:
request - request which was received
message - message to send
Returns:
marker to identify send progress

addMessageListener

public void addMessageListener(AppToken app,
                               MessageListener listener)
Add a listener that wishes to receive message notifications.
Specified by:
addMessageListener in interface MessageBroker
Parameters:
listener - entity to add

removeMessageListener

public void removeMessageListener(AppToken app,
                                  MessageListener listener)
Remove an entity from the list of those interested in messages notifications.
Specified by:
removeMessageListener in interface MessageBroker
Parameters:
listener - entity to remove

distribute

public void distribute(PeerMessage message)
Distribute a message to waiting listeners. This is called by the PB implementation.
Parameters:
message - message to distribute

distribute

public void distribute(AppToken destApp,
                       PeerMessage message)
Distribute a message to waiting listeners. This is called by the PB implementation.
Parameters:
destApp - app to receive message
message - message to distribute

distributeResponse

public void distributeResponse(ResponseMarker marker,
                               PeerMessage message)
Distribute a message to waiting listeners. This is called by the PB implementation.
Parameters:
message - message to distribute


Copyright © 2001 Resilient Edge, Inc. All Rights Reserved.