org.logicblaze.lingo.jms.impl
Class MultiplexingRequestor

java.lang.Object
  extended by org.logicblaze.lingo.jms.impl.OneWayRequestor
      extended by org.logicblaze.lingo.jms.impl.SingleThreadedRequestor
          extended by org.logicblaze.lingo.jms.impl.MultiplexingRequestor
All Implemented Interfaces:
MessageListener, Requestor, org.springframework.beans.factory.DisposableBean

public class MultiplexingRequestor
extends SingleThreadedRequestor
implements MessageListener

A Requestor which will use a single producer, consumer and temporary topic for resource efficiency, but will use correlation IDs on each message and response to ensure that each threads requests can occur synchronously.

This class can be used concurrently by many different threads at the same time.

Version:
$Revision: 1.14 $

Constructor Summary
MultiplexingRequestor(Connection connection, Session session, MessageProducer producer, Destination serverDestination, Destination clientDestination, boolean ownsConnection)
           
MultiplexingRequestor(JmsProducerConfig config, Destination serverDestination, Destination clientDestination)
           
 
Method Summary
protected  JMSException createJMSException(Exception e)
           
protected  void doSend(Destination destination, Message message, long timeout)
           
 TimeoutMap getRequestMap()
           
static Requestor newInstance(ConnectionFactory connectionFactory, JmsProducerConfig config, Destination destination)
           
static Requestor newInstance(ConnectionFactory connectionFactory, JmsProducerConfig config, Destination destination, Destination responseDestination)
           
 void onMessage(Message message)
          Processes inbound responses from requests
 Message receive(long timeout)
          Receives a message waiting for a maximum timeout if the timeout value is > 0 ir waiting forever if the timeout is < 0 or not waiting at all if the timeout is zero
 void registerHandler(String correlationID, ReplyHandler handler, long timeout)
           
 Message request(Destination destination, Message message)
          Sends a request and waits for a reply.
 Message request(Destination destination, Message message, long timeout)
          Sends a request and waits for a reply up to a maximum timeout.
 void request(Destination destination, Message message, ReplyHandler handler, long timeout)
          Sends a request and provides a handler for all responses until the request is considered dead (or it is timed out).
 void setRequestMap(TimeoutMap requests)
           
 
Methods inherited from class org.logicblaze.lingo.jms.impl.SingleThreadedRequestor
close, createTemporaryDestination, getInboundDestination, getReceiver, isDeleteTemporaryDestinationsOnClose, populateHeaders, setDeleteTemporaryDestinationsOnClose
 
Methods inherited from class org.logicblaze.lingo.jms.impl.OneWayRequestor
createCorrelationID, destroy, doSend, getConnection, getDeliveryMode, getMessageProducer, getPriority, getSession, getTimeToLive, newInstance, nextCounter, send, send, send, setDeliveryMode, setPriority, setTimeToLive, validateDestination
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiplexingRequestor

public MultiplexingRequestor(JmsProducerConfig config,
                             Destination serverDestination,
                             Destination clientDestination)
                      throws JMSException
Throws:
JMSException

MultiplexingRequestor

public MultiplexingRequestor(Connection connection,
                             Session session,
                             MessageProducer producer,
                             Destination serverDestination,
                             Destination clientDestination,
                             boolean ownsConnection)
                      throws JMSException
Throws:
JMSException
Method Detail

newInstance

public static Requestor newInstance(ConnectionFactory connectionFactory,
                                    JmsProducerConfig config,
                                    Destination destination,
                                    Destination responseDestination)
                             throws JMSException
Throws:
JMSException

newInstance

public static Requestor newInstance(ConnectionFactory connectionFactory,
                                    JmsProducerConfig config,
                                    Destination destination)
                             throws JMSException
Throws:
JMSException

registerHandler

public void registerHandler(String correlationID,
                            ReplyHandler handler,
                            long timeout)

request

public Message request(Destination destination,
                       Message message)
                throws JMSException
Description copied from interface: Requestor
Sends a request and waits for a reply. The temporary queue is used for the JMSReplyTo destination, and only one reply per request is expected.

Specified by:
request in interface Requestor
Overrides:
request in class SingleThreadedRequestor
Parameters:
destination - the server side destination
message - the message to send
Returns:
the reply message
Throws:
JMSException - if the JMS provider fails to complete the request due to some internal error.

request

public Message request(Destination destination,
                       Message message,
                       long timeout)
                throws JMSException
Description copied from interface: Requestor
Sends a request and waits for a reply up to a maximum timeout. The temporary queue is used for the JMSReplyTo destination, and only one reply per request is expected.

Specified by:
request in interface Requestor
Overrides:
request in class SingleThreadedRequestor
Parameters:
destination - the server side destination
message - the message to send
Returns:
the reply message
Throws:
JMSException - if the JMS provider fails to complete the request due to some internal error.

request

public void request(Destination destination,
                    Message message,
                    ReplyHandler handler,
                    long timeout)
             throws JMSException
Description copied from interface: Requestor
Sends a request and provides a handler for all responses until the request is considered dead (or it is timed out).

Specified by:
request in interface Requestor
Overrides:
request in class OneWayRequestor
Throws:
JMSException

onMessage

public void onMessage(Message message)
Processes inbound responses from requests

Specified by:
onMessage in interface MessageListener

receive

public Message receive(long timeout)
                throws JMSException
Description copied from interface: Requestor
Receives a message waiting for a maximum timeout if the timeout value is > 0 ir waiting forever if the timeout is < 0 or not waiting at all if the timeout is zero

Specified by:
receive in interface Requestor
Overrides:
receive in class SingleThreadedRequestor
Throws:
JMSException

doSend

protected void doSend(Destination destination,
                      Message message,
                      long timeout)
               throws JMSException
Overrides:
doSend in class OneWayRequestor
Throws:
JMSException

getRequestMap

public TimeoutMap getRequestMap()

setRequestMap

public void setRequestMap(TimeoutMap requests)

createJMSException

protected JMSException createJMSException(Exception e)


Copyright © 2005-2006 LogicBlaze, Inc.. All Rights Reserved.