Jumpi v1.2.0

org.jumpi.impl.connector.jms10
Class JmsContext

java.lang.Object
  |
  +--org.jumpi.impl.connector.jms10.JmsContext
Direct Known Subclasses:
JmsQueueContext, JmsTopicContext

public abstract class JmsContext
extends java.lang.Object

A JmsContext encapsulates point-to-point JmsQueueContext and publish-subscribe JmsTopicContexts, providing common functionality needed by the JmsConnector to send and receive messages to both context types. The JMS Producer and JMS Consumer instances which are created for sending and receiving messages are maintained once opened by the JmsContext. The JMS Producer and Consumer share the same non-transacted JMS Session. The JMS Consumer is auto-acknowledging.


Field Summary
protected  JmsDestination dest_
          The default JMS Destination linked to the JmsContext.
static java.lang.String PROPERTY_JMS_CORRELATION_ID
          The JMSCorrelationID property used on sent messages.
static java.lang.String PROPERTY_JMS_RECEIVE_TIMEOUT
          The receive timeout property used for synchronous reception.
static java.lang.String PROPERTY_JMS_REPLY_DESTINATION
          The Temporary JmsDestination created on send when PROPERTY_JMS_REPLY_WANTED_FLAG is true.
static java.lang.String PROPERTY_JMS_REPLY_WANTED_FLAG
          The JMSReplyTo property used on sent messages. - value is true or false.
static java.lang.String PROPERTY_JMS_TTL
          The time to live for JMS messages before expiry.
 
Constructor Summary
JmsContext(JmsDestination dest)
          Creates a new JmsContext object.
 
Method Summary
abstract  void close()
          Close the JmsContext, which entails closing any established JMS entities..
protected  java.util.Hashtable consolidatedProperties(Envelope env)
          Customizing properties may be sent from either the Jumpi client layer, or from the Controller layer.
protected  java.lang.String getCorrelationID(java.util.Hashtable props)
          The correlationID placed on outgoing Messages, or to filter incoming messages by, as determined by the PROPERTY_JMS_CORRELATION_ID property.
 JmsDestination getDestination()
          Get the associated JmsDestination.
protected  long getReceiveTimeout(java.util.Hashtable props)
          The receive timeout in milliseconds determined by the PROPERTY_JMS_TTL property.
protected  long getTTL(java.util.Hashtable props)
          The time to live in milliseconds of outgoing Messages determined by the PROPERTY_JMS_TTL property.
protected  boolean isReplyTo(java.util.Hashtable props)
          Whether a JMSReplyTo Destination should be set on outgoing Messages, since the PROPERTY_JMS_REPLY_WANTED_FLAG is "true".
abstract  boolean recv(JmsDestination dest, Envelope env)
          Receive an ObjectMessage from the JmsDestination provided.
abstract  boolean send(JmsDestination dest, Envelope env)
          Send an ObjectMessage to the JmsDestination provided.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_JMS_REPLY_DESTINATION

public static final java.lang.String PROPERTY_JMS_REPLY_DESTINATION
The Temporary JmsDestination created on send when PROPERTY_JMS_REPLY_WANTED_FLAG is true. Value: jms.reply.destination.

See Also:
Constant Field Values

PROPERTY_JMS_TTL

public static final java.lang.String PROPERTY_JMS_TTL
The time to live for JMS messages before expiry. Value: jms.ttl.

See Also:
Constant Field Values

PROPERTY_JMS_REPLY_WANTED_FLAG

public static final java.lang.String PROPERTY_JMS_REPLY_WANTED_FLAG
The JMSReplyTo property used on sent messages. - value is true or false. Value: jms.reply.wanted.flag.

See Also:
Constant Field Values

PROPERTY_JMS_CORRELATION_ID

public static final java.lang.String PROPERTY_JMS_CORRELATION_ID
The JMSCorrelationID property used on sent messages. Value: jms.correlation.id.

See Also:
Constant Field Values

PROPERTY_JMS_RECEIVE_TIMEOUT

public static final java.lang.String PROPERTY_JMS_RECEIVE_TIMEOUT
The receive timeout property used for synchronous reception. Value: jms.receive.timeout.

See Also:
Constant Field Values

dest_

protected JmsDestination dest_
The default JMS Destination linked to the JmsContext.

Constructor Detail

JmsContext

public JmsContext(JmsDestination dest)
Creates a new JmsContext object.

Parameters:
dest - the associated JMS Destination.
Method Detail

getDestination

public JmsDestination getDestination()
Get the associated JmsDestination.

Returns:
the associated JmsDestination.

send

public abstract boolean send(JmsDestination dest,
                             Envelope env)
                      throws java.lang.Exception
Send an ObjectMessage to the JmsDestination provided. Several configuration parameters are allowed from the Envelope's client properties or parameters. See JmsConnector.onSend(org.jumpi.spi.Envelope).

Parameters:
dest - the JmsDestination which may contain a Temporary Destination to use, instead of the instance's default Destination.
env - the Envelope containing the message and customizing properties.
Returns:
true if the operation succeeds, otherwise false if managed failure.
Throws:
java.lang.Exception - if any error condition occurs, failing the operation.

recv

public abstract boolean recv(JmsDestination dest,
                             Envelope env)
                      throws java.lang.Exception
Receive an ObjectMessage from the JmsDestination provided. Receive timeout returns false. Several configuration parameters are allowed from the Envelope's client properties or parameters. See JmsConnector.onRecv(org.jumpi.spi.Envelope).

Parameters:
dest - the JmsDestination which may contain a Temporary Destination to use, instead of the instance's default Destination.
env - the Envelope to place the message and containing customizing properties.
Returns:
true if the operation succeeds, otherwise false if the receive times-out.
Throws:
java.lang.Exception - if any error condition occurs, failing the operation.

close

public abstract void close()
                    throws java.lang.Exception
Close the JmsContext, which entails closing any established JMS entities..

Throws:
java.lang.Exception - if any failure condition occurs.

consolidatedProperties

protected java.util.Hashtable consolidatedProperties(Envelope env)
Customizing properties may be sent from either the Jumpi client layer, or from the Controller layer. Since the client layer properties in Envelope.getClientProperties() are read-only. The Properties from the Controller layer take priority over the same property from the client layer ( since the Controller can control them and determine how to overide them ). The client properties and the Controller properties are merged into the Controller properties, so that the Controller properties contain all relevant JmsConnector properties, even in the absence of a Controller.

Parameters:
env - the Envelope.containing client properties and, or Controller properties.
Returns:
the merged Controller properties, identical to env.getProperties(). The env Controller properties contain also the client properties.

isReplyTo

protected boolean isReplyTo(java.util.Hashtable props)
                     throws java.lang.Exception
Whether a JMSReplyTo Destination should be set on outgoing Messages, since the PROPERTY_JMS_REPLY_WANTED_FLAG is "true".

Parameters:
props - the consolidated customizing properties.
Returns:
true if the PROPERTY_JMS_REPLY_WANTED_FLAG is "true".
Throws:
java.lang.Exception - if any failure condition occurs.

getTTL

protected long getTTL(java.util.Hashtable props)
               throws java.lang.Exception
The time to live in milliseconds of outgoing Messages determined by the PROPERTY_JMS_TTL property.

Parameters:
props - the consolidated customizing properties.
Returns:
the numeric value of the PROPERTY_JMS_TTL.
Throws:
java.lang.Exception - if any failure condition occurs.

getReceiveTimeout

protected long getReceiveTimeout(java.util.Hashtable props)
                          throws java.lang.Exception
The receive timeout in milliseconds determined by the PROPERTY_JMS_TTL property. Consumers block no longer than this timeout synchronously in receive calls.

Parameters:
props - the consolidated customizing properties.
Returns:
the numeric value of the PROPERTY_JMS_RECEIVE_TIMEOUT, -1 is 0 timeout, 0 is infinite timeout, positive is finite.
Throws:
java.lang.Exception - if any failure condition occurs.

getCorrelationID

protected java.lang.String getCorrelationID(java.util.Hashtable props)
                                     throws java.lang.Exception
The correlationID placed on outgoing Messages, or to filter incoming messages by, as determined by the PROPERTY_JMS_CORRELATION_ID property.

Parameters:
props - the consolidated customizing properties.
Returns:
the value of the PROPERTY_JMS_CORRELATION_ID, or null if not set.
Throws:
java.lang.Exception - if any failure condition occurs.

Jumpi v1.2.0

Copyright 2003, Peter Jonathan Klauser.