Class JMSConnectionFactoryHandler

java.lang.Object
org.apache.nifi.jms.cf.CachedJMSConnectionFactoryHandler
org.apache.nifi.jms.cf.JMSConnectionFactoryHandler
All Implemented Interfaces:
IJMSConnectionFactoryProvider, JMSConnectionFactoryHandlerDefinition

public class JMSConnectionFactoryHandler extends CachedJMSConnectionFactoryHandler
Handler class to create a JMS Connection Factory by instantiating the vendor specific javax.jms.ConnectionFactory implementation class and configuring the Connection Factory object directly. The handler can be used from controller services and processors as well.
  • Field Details

  • Constructor Details

  • Method Details

    • createConnectionFactory

      public jakarta.jms.ConnectionFactory createConnectionFactory()
      Specified by:
      createConnectionFactory in class CachedJMSConnectionFactoryHandler
    • createConnectionFactoryInstance

      private jakarta.jms.ConnectionFactory createConnectionFactoryInstance()
      Creates an instance of the ConnectionFactory from the provided 'CONNECTION_FACTORY_IMPL'.
    • setConnectionFactoryProperties

      void setConnectionFactoryProperties(jakarta.jms.ConnectionFactory connectionFactory)
      This operation follows standard bean convention by matching property name to its corresponding 'setter' method. Once the method was located it is invoked to set the corresponding property to a value provided by during service configuration. For example, 'channel' property will correspond to 'setChannel(..) method and 'queueManager' property will correspond to setQueueManager(..) method with a single argument. The bean convention is also explained in user manual for this component with links pointing to documentation of various ConnectionFactories.

      There are also few adjustments to accommodate well known brokers. For example ActiveMQ ConnectionFactory accepts address of the Message Broker in a form of URL while IBMs in the form of host/port pair(s).

      This method will use the value retrieved from the 'BROKER_URI' static property as is. An exception to this if ConnectionFactory implementation is coming from IBM MQ and connecting to a stand-alone queue manager. In this case the Broker URI is expected to be entered as a colon separated host/port pair, which then is split on ':' and the resulting pair will be used to execute setHostName(..) and setPort(..) methods on the provided ConnectionFactory.

      This method may need to be maintained and adjusted to accommodate other implementation of ConnectionFactory, but only for URL/Host/Port issue. All other properties are set as dynamic properties where user essentially provides both property name and value.

      See Also:
    • setProperty

      void setProperty(jakarta.jms.ConnectionFactory connectionFactory, String propertyName, Object propertyValue)
      Sets corresponding ConnectionFactory's property to a 'propertyValue' by invoking a 'setter' method that corresponds to 'propertyName'. For example, 'channel' property will correspond to 'setChannel(..) method and 'queueManager' property will correspond to setQueueManager(..) method with a single argument.

      NOTE: There is a limited type conversion to accommodate property value types since all NiFi configuration properties comes as String. It is accomplished by checking the argument type of the method and executing its corresponding conversion to target primitive (e.g., value 'true' will go thru Boolean.parseBoolean(propertyValue) if method argument is of type boolean). None-primitive values are not supported at the moment and will result in IllegalArgumentException. It is OK though since based on analysis of several ConnectionFactory implementation the all seem to follow bean convention and all their properties using Java primitives as arguments.

    • toMethodName

      private String toMethodName(String propertyName)
      Will convert propertyName to a method name following bean convention. For example, 'channel' property will correspond to 'setChannel method and 'queueManager' property will correspond to setQueueManager method name