Class JMSRouter

  • All Implemented Interfaces:
    org.smooks.api.delivery.ContentHandler, org.smooks.api.delivery.ordering.Consumer, org.smooks.api.resource.visitor.sax.ng.AfterVisitor, org.smooks.api.resource.visitor.sax.ng.BeforeVisitor, org.smooks.api.resource.visitor.sax.ng.SaxNgVisitor, org.smooks.api.resource.visitor.Visitor

    @VisitBeforeIf(condition="executeBefore")
    @VisitAfterIf(condition="!executeBefore")
    public class JMSRouter
    extends Object
    implements org.smooks.api.resource.visitor.sax.ng.BeforeVisitor, org.smooks.api.resource.visitor.sax.ng.AfterVisitor, org.smooks.api.delivery.ordering.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.smooks.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
    • Constructor Detail

      • JMSRouter

        public JMSRouter()
    • Method Detail

      • initialize

        @PostConstruct
        public void initialize()
                        throws org.smooks.api.SmooksConfigException,
                               javax.jms.JMSException
        Throws:
        org.smooks.api.SmooksConfigException
        javax.jms.JMSException
      • preDestroy

        @PreDestroy
        public void preDestroy()
                        throws javax.jms.JMSException
        Throws:
        javax.jms.JMSException
      • consumes

        public boolean consumes​(Object object)
        Specified by:
        consumes in interface org.smooks.api.delivery.ordering.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

        @Inject
        public void setJndiContextFactory​(Optional<String> contextFactory)
      • setJndiProperties

        @Inject
        public void setJndiProperties​(Optional<String> propertiesFile)
      • setJndiProperties

        public void setJndiProperties​(Properties properties)
      • setJndiProviderUrl

        @Inject
        public void setJndiProviderUrl​(Optional<String> providerUrl)
      • setJndiNamingFactoryUrl

        @Inject
        public void setJndiNamingFactoryUrl​(Optional<String> pkgUrl)
      • setDestinationName

        @Inject
        public void setDestinationName​(String destinationName)
      • setTimeToLive

        @Inject
        public void setTimeToLive​(Optional<Long> timeToLive)
      • setSecurityPrincipal

        @Inject
        public void setSecurityPrincipal​(Optional<String> securityPrincipal)
      • setSecurityCredential

        @Inject
        public void setSecurityCredential​(Optional<String> securityCredential)
      • setTransacted

        @Inject
        public void setTransacted​(Optional<Boolean> transacted)
      • setConnectionFactoryName

        @Inject
        public void setConnectionFactoryName​(Optional<String> connectionFactoryName)
      • setPriority

        @Inject
        public void setPriority​(Optional<Integer> priority)
      • setAcknowledgeMode

        @Inject
        public void setAcknowledgeMode​(Optional<AckMode> jmsAcknowledgeMode)
      • getExecuteBefore

        public Boolean getExecuteBefore()
      • visitAfter

        public void visitAfter​(Element element,
                               org.smooks.api.ExecutionContext execContext)
                        throws org.smooks.api.SmooksException
        Specified by:
        visitAfter in interface org.smooks.api.resource.visitor.sax.ng.AfterVisitor
        Throws:
        org.smooks.api.SmooksException
      • visitBefore

        public void visitBefore​(Element element,
                                org.smooks.api.ExecutionContext execContext)
                         throws org.smooks.api.SmooksException
        Specified by:
        visitBefore in interface org.smooks.api.resource.visitor.sax.ng.BeforeVisitor
        Throws:
        org.smooks.api.SmooksException
      • 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 org.smooks.api.SmooksConfigException
        Sets the following MessageProducer properties:
      • TimeToLive
      • Priority
      • DeliveryMode

        Subclasses may override this behaviour.

Throws:
org.smooks.api.SmooksConfigException