org.milyn.routing.jms
Class JMSRouter
java.lang.Object
org.milyn.routing.jms.JMSRouter
- All Implemented Interfaces:
- ContentHandler, DOMElementVisitor, DOMVisitAfter, DOMVisitBefore, DOMVisitor, Consumer, SAXVisitAfter, SAXVisitBefore, SAXVisitor, Visitor
@VisitBeforeIf(condition="parameters.containsKey(\'executeBefore\') && parameters.executeBefore.value == \'true\'")
@VisitAfterIf(condition="!parameters.containsKey(\'executeBefore\') || parameters.executeBefore.value != \'true\'")
public class JMSRouter
- extends Object
- implements DOMElementVisitor, SAXVisitBefore, SAXVisitAfter, Consumer
Router is a Visitor for DOM or SAX elements. It sends the content
as a JMS Message object to the configured destination.
The type of the JMS Message is determined by the "messageType" config param.
Example configuration:
<resource-config selector="orderItems">
<resource>org.milyn.routing.jms.JMSRouter</resource>
<param name="beanId">beanId</param>
<param name="destinationName">/queue/smooksRouterQueue</param>
</resource-config>
....
Optional parameters:
<param name="executeBefore">true</param>
<param name="jndiContextFactory">ConnectionFactory</param>
<param name="jndiProviderUrl">jnp://localhost:1099</param>
<param name="jndiNamingFactory">org.jboss.naming:java.naming.factory.url.pkgs=org.jnp.interfaces</param>
<param name="connectionFactory">ConnectionFactory</param>
<param name="deliveryMode">persistent</param>
<param name="priority">10</param>
<param name="timeToLive">100000</param>
<param name="securityPrincipal">username</param>
<param name="securityCredential">password</param>
<param name="acknowledgeMode">AUTO_ACKNOWLEDGE</param>
<param name="transacted">false</param>
<param name="correlationIdPattern">orderitem-${order.orderId}-${order.orderItem.itemId}</param>
<param name="messageType">ObjectMessage</param>
<param name="highWaterMark">50</param>
<param name="highWaterMarkTimeout">5000</param>
<param name="highWaterMarkPollFrequency">500</param>
Description of configuration properties:
- jndiContextFactory: the JNDI ContextFactory to use.
- jndiProviderUrl: the JNDI Provider URL to use.
- jndiNamingFactory: the JNDI NamingFactory to use.
- connectionFactory: the ConnectionFactory to look up.
- deliveryMode: the JMS DeliveryMode. 'persistent'(default) or 'non-persistent'.
- priority: the JMS Priority to be used.
- timeToLive: the JMS Time-To-Live to be used.
- securityPrincipal: security principal use when creating the JMS connection.
- securityCredential: the security credentials to use when creating the JMS connection.
- acknowledgeMode: the acknowledge mode to use. One of 'AUTO_ACKNOWLEDGE'(default), 'CLIENT_ACKNOWLEDGE', 'DUPS_OK_ACKNOWLEDGE'.
- transacted: determines if the session should be transacted. Defaults to 'false'.
- correlationIdPattern: JMS Correlation pattern that will be used for the outgoing message. Supports templating.
- messageType: type of JMS Message that should be sent. 'TextMessage'(default), 'ObjectMessage' or 'MapMessage'.
- highWaterMark: max number of messages that can be sitting in the JMS Destination at any any time. Default is 200.
- highWaterMarkTimeout: number of ms to wait for the system to process JMS Messages from the JMS destination
so that the number of JMS Messages drops below the highWaterMark. Default is 60000 ms.
- highWaterMarkPollFrequency: number of ms to wait between checks on the High Water Mark, while
waiting for it to drop. Default is 1000 ms.
- Since:
- 1.0
- Author:
- Daniel Bevenius
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JMSRouter
public JMSRouter()
initialize
@Initialize
public void initialize()
throws SmooksConfigurationException,
javax.jms.JMSException
- Throws:
SmooksConfigurationException
javax.jms.JMSException
uninitialize
@Uninitialize
public void uninitialize()
throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
consumes
public boolean consumes(Object object)
- Specified by:
consumes in interface Consumer
setBeanId
public void setBeanId(String beanId)
setCorrelationIdPattern
public void setCorrelationIdPattern(String correlationIdPattern)
setHighWaterMark
public void setHighWaterMark(int highWaterMark)
setHighWaterMarkTimeout
public void setHighWaterMarkTimeout(long highWaterMarkTimeout)
setHighWaterMarkPollFrequency
public void setHighWaterMarkPollFrequency(long highWaterMarkPollFrequency)
setJndiContextFactory
@ConfigParam(use=OPTIONAL)
public void setJndiContextFactory(String contextFactory)
setJndiProperties
@ConfigParam(use=OPTIONAL)
public void setJndiProperties(String propertiesFile)
setJndiProperties
public void setJndiProperties(Properties properties)
setJndiProviderUrl
@ConfigParam(use=OPTIONAL)
public void setJndiProviderUrl(String providerUrl)
setJndiNamingFactoryUrl
@ConfigParam(use=OPTIONAL)
public void setJndiNamingFactoryUrl(String pkgUrl)
setDestinationName
@ConfigParam(use=REQUIRED)
public void setDestinationName(String destinationName)
setDeliveryMode
@ConfigParam(choice={"persistent","non-persistent"},
defaultVal="persistent",
use=OPTIONAL)
public void setDeliveryMode(String deliveryMode)
setTimeToLive
@ConfigParam(use=OPTIONAL)
public void setTimeToLive(long timeToLive)
setSecurityPrincipal
@ConfigParam(use=OPTIONAL)
public void setSecurityPrincipal(String securityPrincipal)
setSecurityCredential
@ConfigParam(use=OPTIONAL)
public void setSecurityCredential(String securityCredential)
setTransacted
@ConfigParam(use=OPTIONAL,
defaultVal="false")
public void setTransacted(boolean transacted)
setConnectionFactoryName
@ConfigParam(defaultVal="ConnectionFactory",
use=OPTIONAL)
public void setConnectionFactoryName(String connectionFactoryName)
setPriority
@ConfigParam(use=OPTIONAL)
public void setPriority(int priority)
setAcknowledgeMode
@ConfigParam(defaultVal="AUTO_ACKNOWLEDGE",
choice={"AUTO_ACKNOWLEDGE","CLIENT_ACKNOWLEDGE","DUPS_OK_ACKNOWLEDGE"})
public void setAcknowledgeMode(String jmsAcknowledgeMode)
setMessageType
@ConfigParam(defaultVal="TextMessage",
choice={"TextMessage","ObjectMessage"})
public void setMessageType(String messageType)
visitAfter
public void visitAfter(Element element,
ExecutionContext execContext)
throws SmooksException
- Specified by:
visitAfter in interface DOMVisitAfter
- Throws:
SmooksException
visitBefore
public void visitBefore(Element element,
ExecutionContext execContext)
throws SmooksException
- Specified by:
visitBefore in interface DOMVisitBefore
- Throws:
SmooksException
visitAfter
public void visitAfter(SAXElement element,
ExecutionContext execContext)
throws SmooksException,
IOException
- Specified by:
visitAfter in interface SAXVisitAfter
- Throws:
SmooksException
IOException
visitBefore
public void visitBefore(SAXElement element,
ExecutionContext execContext)
throws SmooksException,
IOException
- Specified by:
visitBefore in interface SAXVisitBefore
- Throws:
SmooksException
IOException
createMessageProducer
protected javax.jms.MessageProducer createMessageProducer(javax.jms.Destination destination,
Context context)
throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
setMessageProducerProperties
protected void setMessageProducerProperties()
throws SmooksConfigurationException
- Sets the following MessageProducer properties:
- TimeToLive
- Priority
- DeliveryMode
Subclasses may override this behaviour.
- Throws:
SmooksConfigurationException
sendMessage
protected void sendMessage(javax.jms.Message message)
throws SmooksRoutingException
- Throws:
SmooksRoutingException
close
protected void close(javax.jms.Connection connection)
close
protected void close(javax.jms.Session session)
getDestination
public javax.jms.Destination getDestination()
getJndiContextFactory
public String getJndiContextFactory()
getJndiProviderUrl
public String getJndiProviderUrl()
getJndiNamingFactoryUrl
public String getJndiNamingFactoryUrl()
getDestinationName
public String getDestinationName()
getDeliveryMode
public String getDeliveryMode()
getTimeToLive
public long getTimeToLive()
getSecurityPrincipal
public String getSecurityPrincipal()
getSecurityCredential
public String getSecurityCredential()
isTransacted
public boolean isTransacted()
getConnectionFactoryName
public String getConnectionFactoryName()
getPriority
public int getPriority()
getAcknowledgeMode
public String getAcknowledgeMode()
setMsgCreationStrategy
public void setMsgCreationStrategy(MessageCreationStrategy msgCreationStrategy)
Copyright © 2014. All Rights Reserved.