|
Jumpi v1.2.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jumpi.impl.AbstractConnector | +--org.jumpi.impl.connector.jms10.JmsConnector
The JmsConnector allows message sending and receiving via a third-party JMS provider. The JmsConnector is JMS provider agnostic and uses portable client JMS code, using JNDI lookups for ConnectionFactories and Destinations. The JmsConnector uses separate JNDI Contexts for Topic and Queues. One QueueConnection and one TopicConnection are created on demand for messaging in the point-to-point or publish-subscribe domain respectively. Messaging to separate JmsDestinations is performed in separate JMS Sessions. One JMS Producer is created per JmsDestination to perform message sending. One JMS Consumer is created per JmsDestination to preform message receiving. Send receive and request reply messaging is possible.
The syntax of a JmsDestination is:
<protocolname>://topic|queue:<name>
Field Summary |
Fields inherited from class org.jumpi.impl.AbstractConnector |
cancelledRecvs_, cancelledSends_, controller_, joinFailInterval_, joinTestInterval_, jumpi_, maxRecvBacklog_, maxSendBacklog_, name_, protocol_, recvQueue_, recvTransformer_, sendQueue_, sendTransformer_, started_, stopping_, taskId_, url_format_, url_prefix_ |
Constructor Summary | |
JmsConnector()
|
Method Summary | |
void |
cancelRecv(Envelope env)
Does nothing. |
void |
cancelSend(Envelope env)
Does nothing. |
protected boolean |
checkJoinCondition()
The shutdown join condition is true if there are no active JMS Contexts. |
void |
configure(java.lang.String name,
Properties props)
Configure the JmsConnector. |
Destination |
getDestination(java.lang.String url,
java.util.Hashtable clientProps)
Get the Destination corresponding to the Url provided. |
void |
manage(Component root,
Component parent,
java.lang.String operation,
java.util.Hashtable parameters)
Perform a recursive management operation through the Jumpi component tree, using the parameters provided. |
protected boolean |
onRecv(Envelope env)
Receive a message from a JMS Destination. |
protected boolean |
onSend(Envelope env)
Send a message to a JMS Destination. |
void |
recv(Envelope env)
Perform the recv synchronously. |
void |
send(Envelope env)
Perform the send synchronously. |
protected void |
shutdownState()
Clear the JMSContext cache and close any active JMS Contexts. |
Methods inherited from class org.jumpi.impl.AbstractConnector |
getName, getTaskId, isLongRunning, isSchedulable, run |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public JmsConnector()
Method Detail |
public void configure(java.lang.String name, Properties props) throws java.lang.Exception
The following configuration attributes are defined in addition to those of the superclass:
queuejndikey<N> - string - optional.
The key for the N-th JNDI InitialContext's property for Queues. The value is the property queuejndivalue<N>.
queuejndivalue<N> - string - optional[].
The value for the N-th JNDI InitialContext's property for Queues. The value is the property queuejndikey<N>.
topicjndikey<N> - string - optional.
The key for the N-th JNDI InitialContext's property for Topics. The value is the property topicjndivalue<N>.
topicjndivalue<N> - string - optional[].
The value for the N-th JNDI InitialContext's property for Topics. The value is the property topicjndikey<N>.
jndiqueueconnectionfactorylookup - string - optional[QueueConnectionFactory].
The value used to lookup the QueueConnectionFactory in JNDI for the single JMS Connection used for point-to-point messaging.
jnditopicconnectionfactorylookup - string - optional[TopicConnectionFactory].
The value used to lookup the TopicConnectionFactory in JNDI for the single JMS Connection used for publish subscribe messaging.
configure
in interface Configurable
configure
in class AbstractConnector
name
- the fully qualified instance name.props
- the read-only properties to configure the instance with.
java.lang.Exception
- when configuration is unsuccessful.public void manage(Component root, Component parent, java.lang.String operation, java.util.Hashtable parameters) throws java.lang.Exception
manage
in interface Manageable
manage
in class AbstractConnector
root
- the Jumpi instance at the root of the component tree.parent
- the immediate parent of the component.operation
- the operation.parameters
- the operation parameters.
java.lang.Exception
- if any failure to perform management occurs.protected boolean checkJoinCondition()
checkJoinCondition
in class AbstractConnector
protected void shutdownState()
shutdownState
in class AbstractConnector
public Destination getDestination(java.lang.String url, java.util.Hashtable clientProps)
getDestination
in interface Connector
getDestination
in class AbstractConnector
url
- the Url of a JMS Topic or Queue.clientProps
- not used.
java.lang.IllegalArgumentException
- when url is null.protected boolean onSend(Envelope env) throws java.lang.Exception
Send a message to a JMS Destination.
The message format passed over JMS is an ObjectMessage. The ObjectMessage payload is simply a serializable Object. Transformation of the message to send by the send transformer is optional.
Allows multiple concurrent send operations to different Destinations but not the same Destination.
The JMS provider's send operation may or may not be truly asynchronous. The send is considered complete on the synchronous return from the JMS provider's send or publish call. This may block due to flow control in the JMS provider.
The PROPERTY_JMS_CORRELATION_ID is used to enable correlation of reply messages with request messages. The property is transferred unchanged to the JMS Message's JMSCorrelationID.
The PROPERTY_JMS_TTL is the time-to-live in milliseconds for sent messages. If not set, messages never expire.
The PROPERTY_JMS_REPLY_WANTED is an indicator that the sender is a requestor and will perform a receive on the Destination returned in the PROPERTY_JMS_REPLY_DESTINATION which is returned in the send operation's Handle's properties. The JmsConnector creates a Temporary JMS Destination which is set as the JMS Message's JMSReplyTo Destination. Use the PROPERTY_JMS_CORRELATION_ID to give the replyer a correlation id to use on the reply, so the requestor can uniquely receive the reply.
onSend
in class AbstractConnector
env
- the Envelope containing the Destination to send to and the
message.
java.lang.Exception
- if a failure condition occurs.public void send(Envelope env) throws java.lang.Exception
send
in interface Connector
send
in class AbstractConnector
env
- the Envelope which gives the Destination to send to and the
message itself.
java.lang.Exception
- if any failure condition occurs during the send
method.
java.lang.IllegalArgumentException
- when env is null.
java.lang.IllegalStateException
- when not started or stopping.Controller.callbackSend(org.jumpi.spi.Envelope, boolean, java.lang.String)
public void cancelSend(Envelope env)
cancelSend
in interface Connector
cancelSend
in class AbstractConnector
env
- the send operation's Envelope to cancel.protected boolean onRecv(Envelope env) throws java.lang.Exception
Receive a message from a JMS Destination. The time to block in the receive is configurable. If the JMS Message received was sent with a correlation id, then this is provided to the client layer in the Handle's properties called PROPERTY_JMS_CORRELATION_ID. If the JMS Message received has a JMSReplyTo Destination set for replying, then this Destination is returned to the client layer in the Handle's sender. If no JMSReplyTo is set on the received message then the receive Destination is the Sender.
The receive operation at the JMS layer delivers expects ObjectMessages. If a receive transformer is configured, then this must transform the ObjectMessage.
Allows multiple concurrent recv operations to different Destinations but not the same Destination.
The JMS provider's receive operation is synchronous, blocking for at most for the period defined in the PROPERTY_JMS_RECEIVE_TIMEOUT. The receive is considered complete on the synchronous return from the JMS provider's receive call. If a receive timeout happens, then the receive operation is failed.
The PROPERTY_JMS_RECEIVE_TIMEOUT is the time in milliseconds for the receive to block without receiving a message. If not set, receives block forever.
The PROPERTY_JMS_CORRELATION_ID is used to enable correlation of reply messages with request messages. The JMS Message's JMSCorrelationID must match the given property for a receive to be matched. Unmatched received messages are simply discarded!
onRecv
in class AbstractConnector
env
- the Envelope containing the Destination to receive from.
java.lang.Exception
- if a failure condition occurs.public void recv(Envelope env) throws java.lang.Exception
recv
in interface Connector
recv
in class AbstractConnector
env
- the Envelope which gives the Destination to receive from and
where the received message is eventually placed with the sender.
java.lang.Exception
- if any failure condition occurs during the recv
method.
java.lang.IllegalArgumentException
- when env is null.
java.lang.IllegalStateException
- when not started or stopping.Controller.callbackRecv(org.jumpi.spi.Envelope, boolean, java.lang.String)
public void cancelRecv(Envelope env)
cancelRecv
in interface Connector
cancelRecv
in class AbstractConnector
env
- the recv operation's Envelope to cancel.
|
Jumpi v1.2.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |