org.logicblaze.lingo.jms.impl
Class OneWayRequestor

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

public class OneWayRequestor
extends java.lang.Object
implements Requestor, org.springframework.beans.factory.DisposableBean

A simple requestor which only supports one-way and so does not need a consumer.

Version:
$Revision: 93 $

Constructor Summary
OneWayRequestor(javax.jms.Connection connection, javax.jms.Session session, javax.jms.MessageProducer producer, javax.jms.Destination serverDestination, boolean ownsConnection)
           
OneWayRequestor(JmsProducerConfig config, javax.jms.Destination serverDestination)
           
 
Method Summary
 void close()
          Closes the Requestor and its session.
 java.lang.String createCorrelationID()
          Creates a new correlation ID.
 void destroy()
           
protected  void doSend(javax.jms.Destination destination, javax.jms.Message message, int deliveryMode, int priority, long timeToLive)
           
protected  void doSend(javax.jms.Destination destination, javax.jms.Message message, long timeToLive)
           
 javax.jms.Connection getConnection()
          Provides access to the underlying Connection this requestor is using
 int getDeliveryMode()
           
 javax.jms.MessageProducer getMessageProducer()
          Returns the underying producer
 int getPriority()
           
 javax.jms.Session getSession()
          Provides access to the underlying JMS session so that you can create messages.
 long getTimeToLive()
          The default time to live on request messages
static OneWayRequestor newInstance(javax.jms.Connection connection, JmsProducerConfig config, boolean ownsConnection)
           
protected  long nextCounter()
           
protected  void populateHeaders(javax.jms.Message message)
          A hook to allow custom implementations to process headers differently.
 javax.jms.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
 javax.jms.Message request(javax.jms.Destination destination, javax.jms.Message message)
          Sends a request and waits for a reply.
 javax.jms.Message request(javax.jms.Destination destination, javax.jms.Message message, long timeout)
          Sends a request and waits for a reply up to a maximum timeout.
 void request(javax.jms.Destination destination, javax.jms.Message requestMessage, 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 send(javax.jms.Destination destination, javax.jms.Message message)
          Sends a one way message, not waiting for the response.
 void send(javax.jms.Destination destination, javax.jms.Message message, int deliveryMode, int priority, long timeToLive)
          Sends a message to the given destination in a way that can be implemented in JMS 1.0.2b as well as using the JMS 1.1 send() method on MessageProducer
 void send(javax.jms.Destination destination, javax.jms.Message message, long timeToLive)
           
 void setDeliveryMode(int deliveryMode)
          Sets the default delivery mode of request messages
 void setPriority(int priority)
          Sets the default priority of request messages
 void setTimeToLive(long timeToLive)
          Sets the maximum time to live for requests
protected  javax.jms.Destination validateDestination(javax.jms.Destination destination)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OneWayRequestor

public OneWayRequestor(JmsProducerConfig config,
                       javax.jms.Destination serverDestination)
                throws javax.jms.JMSException
Throws:
javax.jms.JMSException

OneWayRequestor

public OneWayRequestor(javax.jms.Connection connection,
                       javax.jms.Session session,
                       javax.jms.MessageProducer producer,
                       javax.jms.Destination serverDestination,
                       boolean ownsConnection)
Method Detail

newInstance

public static OneWayRequestor newInstance(javax.jms.Connection connection,
                                          JmsProducerConfig config,
                                          boolean ownsConnection)
                                   throws javax.jms.JMSException
Throws:
javax.jms.JMSException

close

public void close()
           throws javax.jms.JMSException
Description copied from interface: Requestor
Closes the Requestor and its session.

Since a provider may allocate some resources on behalf of a Requestor outside the Java virtual machine, clients should close them when they are not needed. Relying on garbage collection to eventually reclaim these resources may not be timely enough.

Note that this method closes the Session object passed to the Requestor constructor.

Specified by:
close in interface Requestor
Throws:
javax.jms.JMSException - if the JMS provider fails to close the Requestor due to some internal error.

destroy

public void destroy()
             throws java.lang.Exception
Specified by:
destroy in interface org.springframework.beans.factory.DisposableBean
Throws:
java.lang.Exception

send

public void send(javax.jms.Destination destination,
                 javax.jms.Message message)
          throws javax.jms.JMSException
Description copied from interface: Requestor
Sends a one way message, not waiting for the response.

Specified by:
send in interface Requestor
Parameters:
destination - the server side destination
message - the message to send
Throws:
javax.jms.JMSException

send

public void send(javax.jms.Destination destination,
                 javax.jms.Message message,
                 long timeToLive)
          throws javax.jms.JMSException
Throws:
javax.jms.JMSException

send

public void send(javax.jms.Destination destination,
                 javax.jms.Message message,
                 int deliveryMode,
                 int priority,
                 long timeToLive)
          throws javax.jms.JMSException
Description copied from interface: Requestor
Sends a message to the given destination in a way that can be implemented in JMS 1.0.2b as well as using the JMS 1.1 send() method on MessageProducer

Specified by:
send in interface Requestor
Throws:
javax.jms.JMSException - if the message could not be sent

receive

public javax.jms.Message receive(long timeout)
                          throws javax.jms.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
Throws:
javax.jms.JMSException

request

public javax.jms.Message request(javax.jms.Destination destination,
                                 javax.jms.Message message)
                          throws javax.jms.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
Parameters:
destination - the server side destination
message - the message to send
Returns:
the reply message
Throws:
javax.jms.JMSException - if the JMS provider fails to complete the request due to some internal error.

request

public javax.jms.Message request(javax.jms.Destination destination,
                                 javax.jms.Message message,
                                 long timeout)
                          throws javax.jms.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
Parameters:
destination - the server side destination
message - the message to send
Returns:
the reply message
Throws:
javax.jms.JMSException - if the JMS provider fails to complete the request due to some internal error.

request

public void request(javax.jms.Destination destination,
                    javax.jms.Message requestMessage,
                    ReplyHandler handler,
                    long timeout)
             throws javax.jms.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
Throws:
javax.jms.JMSException

getConnection

public javax.jms.Connection getConnection()
Description copied from interface: Requestor
Provides access to the underlying Connection this requestor is using

Specified by:
getConnection in interface Requestor

getSession

public javax.jms.Session getSession()
Description copied from interface: Requestor
Provides access to the underlying JMS session so that you can create messages.

Specified by:
getSession in interface Requestor

getMessageProducer

public javax.jms.MessageProducer getMessageProducer()
Description copied from interface: Requestor
Returns the underying producer

Specified by:
getMessageProducer in interface Requestor

getDeliveryMode

public int getDeliveryMode()
                    throws javax.jms.JMSException
Throws:
javax.jms.JMSException

setDeliveryMode

public void setDeliveryMode(int deliveryMode)
                     throws javax.jms.JMSException
Sets the default delivery mode of request messages

Throws:
javax.jms.JMSException

getPriority

public int getPriority()
                throws javax.jms.JMSException
Throws:
javax.jms.JMSException

setPriority

public void setPriority(int priority)
                 throws javax.jms.JMSException
Sets the default priority of request messages

Throws:
javax.jms.JMSException

getTimeToLive

public long getTimeToLive()
                   throws javax.jms.JMSException
The default time to live on request messages

Throws:
javax.jms.JMSException

setTimeToLive

public void setTimeToLive(long timeToLive)
                   throws javax.jms.JMSException
Sets the maximum time to live for requests

Throws:
javax.jms.JMSException

populateHeaders

protected void populateHeaders(javax.jms.Message message)
                        throws javax.jms.JMSException
A hook to allow custom implementations to process headers differently.

Throws:
javax.jms.JMSException

doSend

protected void doSend(javax.jms.Destination destination,
                      javax.jms.Message message,
                      long timeToLive)
               throws javax.jms.JMSException
Throws:
javax.jms.JMSException

doSend

protected void doSend(javax.jms.Destination destination,
                      javax.jms.Message message,
                      int deliveryMode,
                      int priority,
                      long timeToLive)
               throws javax.jms.JMSException
Throws:
javax.jms.JMSException

validateDestination

protected javax.jms.Destination validateDestination(javax.jms.Destination destination)

createCorrelationID

public java.lang.String createCorrelationID()
Creates a new correlation ID. Note that because the correlationID is used on a per-temporary destination basis, it does not need to be unique across more than one destination. So a simple counter will suffice.

Specified by:
createCorrelationID in interface Requestor
Returns:

nextCounter

protected long nextCounter()


Copyright © 2009 LogicBlaze, Inc.. All Rights Reserved.