@Tags(value={"jms","messaging","integration","queue","topic","publish","subscribe"}) @CapabilityDescription(value="Provides a generic service to create vendor specific javax.jms.ConnectionFactory implementations. ConnectionFactory can be served once this service is configured successfully") @DynamicProperty(name="The name of a Connection Factory configuration property.", value="The value of a given Connection Factory configuration property.", description="The properties that are set following Java Beans convention where a property name is derived from the \'set*\' method of the vendor specific ConnectionFactory\'s implementation. For example, \'com.ibm.mq.jms.MQConnectionFactory.setChannel(String)\' would imply \'channel\' property and \'com.ibm.mq.jms.MQConnectionFactory.setTransportType(int)\' would imply \'transportType\' property.") @SeeAlso(classNames={"org.apache.nifi.jms.processors.ConsumeJMS","org.apache.nifi.jms.processors.PublishJMS"}) public class JMSConnectionFactoryProvider extends AbstractControllerService implements JMSConnectionFactoryProviderDefinition
ConnectionFactory specific to the third party JMS system.
It accomplishes it by adjusting current classpath by adding to it the
additional resources (i.e., JMS client libraries) provided by the user via
JMSConnectionFactoryProviderDefinition#CLIENT_LIB_DIR_PATH, allowing
it then to create an instance of the target ConnectionFactory based
on the provided
JMSConnectionFactoryProviderDefinition#CONNECTION_FACTORY_IMPL which
can be than access via getConnectionFactory() method.
| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
JMSConnectionFactoryProvider.NonEmptyBrokerURIValidator
Validator that ensures that brokerURI's length > 0 after EL
evaluation |
| Modifier and Type | Field and Description |
|---|---|
private static String |
BROKER |
static PropertyDescriptor |
BROKER_URI |
private static String |
CF_IMPL |
private static String |
CF_LIB |
static PropertyDescriptor |
CLIENT_LIB_DIR_PATH |
private boolean |
configured |
static PropertyDescriptor |
CONNECTION_FACTORY_IMPL |
private javax.jms.ConnectionFactory |
connectionFactory |
private org.slf4j.Logger |
logger |
private static List<PropertyDescriptor> |
PROPERTY_DESCRIPTORS |
static PropertyDescriptor |
SSL_CONTEXT_SERVICE |
| Constructor and Description |
|---|
JMSConnectionFactoryProvider() |
| Modifier and Type | Method and Description |
|---|---|
private void |
createConnectionFactoryInstance(ConfigurationContext context)
Creates an instance of the
ConnectionFactory from the provided
'CONNECTION_FACTORY_IMPL'. |
void |
disable() |
void |
enable(ConfigurationContext context) |
javax.jms.ConnectionFactory |
getConnectionFactory() |
protected PropertyDescriptor |
getSupportedDynamicPropertyDescriptor(String propertyDescriptorName) |
protected List<PropertyDescriptor> |
getSupportedPropertyDescriptors() |
void |
resetConnectionFactory(javax.jms.ConnectionFactory cachedFactory) |
private void |
setConnectionFactoryProperties(ConfigurationContext context)
This operation follows standard bean convention by matching property name
to its corresponding 'setter' method.
|
private void |
setProperty(String propertyName,
Object propertyValue)
Sets corresponding
ConnectionFactory's property to a
'propertyValue' by invoking a 'setter' method that corresponds to
'propertyName'. |
private String |
toMethodName(String propertyName)
Will convert propertyName to a method name following bean convention.
|
abstractClearConfigContext, abstractStoreConfigContext, disabled, enabled, getConfigurationContext, getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, getProperty, getStateManager, init, initialize, isEnabledcustomValidate, equals, getPropertyDescriptor, getPropertyDescriptors, hashCode, onPropertyModified, toString, validateclone, finalize, getClass, notify, notifyAll, wait, wait, waitinitializegetIdentifier, getPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validateprivate final org.slf4j.Logger logger
private static final List<PropertyDescriptor> PROPERTY_DESCRIPTORS
private volatile boolean configured
private volatile javax.jms.ConnectionFactory connectionFactory
private static final String BROKER
private static final String CF_IMPL
private static final String CF_LIB
public static final PropertyDescriptor CONNECTION_FACTORY_IMPL
public static final PropertyDescriptor CLIENT_LIB_DIR_PATH
public static final PropertyDescriptor BROKER_URI
public static final PropertyDescriptor SSL_CONTEXT_SERVICE
protected List<PropertyDescriptor> getSupportedPropertyDescriptors()
getSupportedPropertyDescriptors in class AbstractConfigurableComponentprotected PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName)
getSupportedDynamicPropertyDescriptor in class AbstractConfigurableComponentpublic void resetConnectionFactory(javax.jms.ConnectionFactory cachedFactory)
resetConnectionFactory in interface JMSConnectionFactoryProviderDefinitionpublic javax.jms.ConnectionFactory getConnectionFactory()
getConnectionFactory in interface JMSConnectionFactoryProviderDefinitionConnectionFactory@OnEnabled public void enable(ConfigurationContext context) throws InitializationException
InitializationException@OnDisabled public void disable()
private void setConnectionFactoryProperties(ConfigurationContext context)
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 (more common). So this method will use value retrieved from the 'BROKER_URI' static property 'as is' if ConnectionFactory implementation is coming from ActiveMQ and for all others (for now) the 'BROKER_URI' value will be split on ':' and the resulting pair will be used to execute setHostName(..) and setPort(..) methods on the provided ConnectionFactory. This 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, The bean convention is also explained in user manual for this component with links pointing to documentation of various ConnectionFactories.
methodprivate void setProperty(String propertyName, Object propertyValue)
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.
private void createConnectionFactoryInstance(ConfigurationContext context)
ConnectionFactory from the provided
'CONNECTION_FACTORY_IMPL'.Copyright © 2019 Apache NiFi Project. All rights reserved.