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

Quick Search    Search Deep

com.presumo.jms.router
Class RemoteSession  view RemoteSession download RemoteSession.java

java.lang.Object
  extended bycom.presumo.jms.router.RemoteSession
All Implemented Interfaces:
RoutingTarget

public class RemoteSession
extends java.lang.Object
implements RoutingTarget

Class that sits between the Router and the Transport layer in terms of message flow. Essentially encapsulates the remote connection from the router, as well as handling the persistent message acknowledgment scheme.


Nested Class Summary
protected  class RemoteSession.MessageReader
          Inner class reperesenting thread reading messages from the transport implementation.
protected  class RemoteSession.MessageWriter
          Inner class writing messages to the Transport
 
Field Summary
protected static java.lang.String ACKS_PROPERTY
          Property name for sending acks via system messages
protected  ConnectionListener connxListener
          Listener to be notified of if the connection is lost
protected static java.lang.String FILTER_PROPERTY
          Property name for sending filters via system messages
protected static long latency
          Time that between sending batches of messages
protected  com.presumo.jms.selector.JmsOperand localFilter
          Local filter which the represents what messages the local router is interested in.
private static com.presumo.util.log.Logger logger
           
protected static int MSG_BATCH_SIZE
          Largest batch of messages that will be bundled together
protected  RemoteSession.MessageReader msgReader
          Instance of inner class that reads message from the Transport
protected  RemoteSession.MessageWriter msgWriter
          Instance of inner class that writes message from the Transport
private  java.util.ArrayList outbox
          Messages queued up to be send
private  com.presumo.jms.selector.Parser parser
          Local copy of the Parser singleton
protected  PersistentAckHandler persistentAckHandler
          Handles acknowledgement logic for persistent messages
protected  com.presumo.jms.selector.JmsOperand remoteFilter
          Filter sent to this JVM from the other side of the connection which indicates what messages the router on the other side is interested in.
protected  Router router
          Router this RemoteSession is connected to
protected  int targetID
          Set unique ID assigned to the remote session by the router
protected  com.presumo.jms.plugin.transport.Transport transport
          Interface which messages are sent to and received from the network
 
Constructor Summary
RemoteSession(Router router, com.presumo.jms.plugin.transport.Transport transport, ConnectionListener listener)
           
 
Method Summary
(package private)  void acksAvailable()
           
 void close()
           
private  com.presumo.jms.message.JmsMessage[] collapseMsgArray(com.presumo.jms.message.JmsMessage[] msgs, int size)
           
private  void connectionLost(java.io.IOException ioe)
           
private  com.presumo.jms.message.JmsMessage createAckMessage()
           
 com.presumo.jms.selector.JmsOperand getRoutingFilter()
          Used by the Router to get the RoutingTarget's routing filter which could be used to determine if the RoutingTarget needs a message.
private  void handleRemoteFilterMsg(com.presumo.jms.message.JmsMessage msg)
           
 boolean needsFilterUpdates()
          Some RoutingTargets, like JmsSession, do not care about filter propogation since they will always give their produced messages to the Router.
private  void queueMessage(com.presumo.jms.message.JmsMessage msg)
           
 void receiveMessages(com.presumo.jms.message.JmsMessage[] msgs)
          Called by MessageReader.run() when messages come from the transport.
 void setRemoteRoutingFilter(com.presumo.jms.selector.JmsOperand filter, boolean add)
          Called by the Router to tell the target what the combined routing filter is for the given Router.
 void setTargetID(int id)
          Used by the Router to assign a unique ID (per JVM) to the RoutingTarget
 void setTransport(com.presumo.jms.plugin.transport.Transport t)
           
 void start()
           
 void stop()
           
 com.presumo.jms.message.JmsMessage takeMessage(com.presumo.jms.message.JmsMessage msg)
          Called by the router to give a potential message to this routing target.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MSG_BATCH_SIZE

protected static final int MSG_BATCH_SIZE
Largest batch of messages that will be bundled together

See Also:
Constant Field Values

latency

protected static final long latency
Time that between sending batches of messages

See Also:
Constant Field Values

FILTER_PROPERTY

protected static final java.lang.String FILTER_PROPERTY
Property name for sending filters via system messages

See Also:
Constant Field Values

ACKS_PROPERTY

protected static final java.lang.String ACKS_PROPERTY
Property name for sending acks via system messages

See Also:
Constant Field Values

remoteFilter

protected com.presumo.jms.selector.JmsOperand remoteFilter
Filter sent to this JVM from the other side of the connection which indicates what messages the router on the other side is interested in.


localFilter

protected com.presumo.jms.selector.JmsOperand localFilter
Local filter which the represents what messages the local router is interested in. This filter is sent to other routers.


router

protected final Router router
Router this RemoteSession is connected to


transport

protected com.presumo.jms.plugin.transport.Transport transport
Interface which messages are sent to and received from the network


connxListener

protected ConnectionListener connxListener
Listener to be notified of if the connection is lost


persistentAckHandler

protected PersistentAckHandler persistentAckHandler
Handles acknowledgement logic for persistent messages


msgReader

protected RemoteSession.MessageReader msgReader
Instance of inner class that reads message from the Transport


msgWriter

protected RemoteSession.MessageWriter msgWriter
Instance of inner class that writes message from the Transport


targetID

protected int targetID
Set unique ID assigned to the remote session by the router


parser

private final com.presumo.jms.selector.Parser parser
Local copy of the Parser singleton


outbox

private final java.util.ArrayList outbox
Messages queued up to be send


logger

private static com.presumo.util.log.Logger logger
Constructor Detail

RemoteSession

public RemoteSession(Router router,
                     com.presumo.jms.plugin.transport.Transport transport,
                     ConnectionListener listener)
Method Detail

setTransport

public void setTransport(com.presumo.jms.plugin.transport.Transport t)

start

public void start()

stop

public void stop()

close

public void close()

setTargetID

public void setTargetID(int id)
Description copied from interface: RoutingTarget
Used by the Router to assign a unique ID (per JVM) to the RoutingTarget

Specified by:
setTargetID in interface RoutingTarget

getRoutingFilter

public com.presumo.jms.selector.JmsOperand getRoutingFilter()
Description copied from interface: RoutingTarget
Used by the Router to get the RoutingTarget's routing filter which could be used to determine if the RoutingTarget needs a message. This is not actually what it is used for though, the RoutingTarget is responsible for determining if it needs the message when the Router calls takeMessage on the target. Instead, the router uses this method to fetch the routing filter for necessary filter propogation to other Routers.

Specified by:
getRoutingFilter in interface RoutingTarget

setRemoteRoutingFilter

public void setRemoteRoutingFilter(com.presumo.jms.selector.JmsOperand filter,
                                   boolean add)
Description copied from interface: RoutingTarget
Called by the Router to tell the target what the combined routing filter is for the given Router. The RoutingTarget should try not to pass any Messages to the Router that do not pass this filter.

Specified by:
setRemoteRoutingFilter in interface RoutingTarget

needsFilterUpdates

public boolean needsFilterUpdates()
Description copied from interface: RoutingTarget
Some RoutingTargets, like JmsSession, do not care about filter propogation since they will always give their produced messages to the Router.

Specified by:
needsFilterUpdates in interface RoutingTarget

takeMessage

public com.presumo.jms.message.JmsMessage takeMessage(com.presumo.jms.message.JmsMessage msg)
Called by the router to give a potential message to this routing target. Implementes RoutingTarget.takeMessage();

Specified by:
takeMessage in interface RoutingTarget

receiveMessages

public void receiveMessages(com.presumo.jms.message.JmsMessage[] msgs)
Called by MessageReader.run() when messages come from the transport.


acksAvailable

void acksAvailable()

queueMessage

private void queueMessage(com.presumo.jms.message.JmsMessage msg)

handleRemoteFilterMsg

private void handleRemoteFilterMsg(com.presumo.jms.message.JmsMessage msg)

collapseMsgArray

private com.presumo.jms.message.JmsMessage[] collapseMsgArray(com.presumo.jms.message.JmsMessage[] msgs,
                                                              int size)

connectionLost

private void connectionLost(java.io.IOException ioe)

createAckMessage

private com.presumo.jms.message.JmsMessage createAckMessage()