Package org.apache.nifi.jms.processors
Class PublishJMS
- All Implemented Interfaces:
ConfigurableComponent,Processor
@Tags({"jms","put","message","send","publish"})
@InputRequirement(INPUT_REQUIRED)
@CapabilityDescription("Creates a JMS Message from the contents of a FlowFile and sends it to a JMS Destination (queue or topic) as JMS BytesMessage or TextMessage. FlowFile attributes will be added as JMS headers and/or properties to the outgoing JMS message.")
@ReadsAttribute(attribute="jms_deliveryMode",description="This attribute becomes the JMSDeliveryMode message header. Must be an integer.") @ReadsAttribute(attribute="jms_expiration",description="This attribute becomes the JMSExpiration message header. Must be a long.") @ReadsAttribute(attribute="jms_priority",description="This attribute becomes the JMSPriority message header. Must be an integer.") @ReadsAttribute(attribute="jms_redelivered",description="This attribute becomes the JMSRedelivered message header.") @ReadsAttribute(attribute="jms_timestamp",description="This attribute becomes the JMSTimestamp message header. Must be a long.") @ReadsAttribute(attribute="jms_correlationId",description="This attribute becomes the JMSCorrelationID message header.") @ReadsAttribute(attribute="jms_type",description="This attribute becomes the JMSType message header. Must be an integer.") @ReadsAttribute(attribute="jms_replyTo",description="This attribute becomes the JMSReplyTo message header. Must be an integer.") @ReadsAttribute(attribute="jms_destination",description="This attribute becomes the JMSDestination message header. Must be an integer.") @ReadsAttribute(attribute="other attributes",description="All other attributes that do not start with jms_ are added as message properties.") @ReadsAttribute(attribute="other attributes .type",description="When an attribute will be added as a message property, a second attribute of the same name but with an extra `.type` at the end will cause the message property to be sent using that strong type. For example, attribute `delay` with value `12000` and another attribute `delay.type` with value `integer` will cause a JMS message property `delay` to be sent as an Integer rather than a String. Supported types are boolean, byte, short, integer, long, float, double, and string (which is the default).")
@DynamicProperty(name="The name of a Connection Factory configuration property.",
value="The value of a given Connection Factory configuration property.",
description="Additional configuration property for the Connection Factory. It can be used when the Connection Factory is being configured via the \'JNDI *\' or the \'JMS *\'properties of the processor. For more information, see the Additional Details page.",
expressionLanguageScope=ENVIRONMENT)
@SeeAlso({ConsumeJMS.class,JMSConnectionFactoryProvider.class})
@SystemResourceConsideration(resource=MEMORY)
@Restricted(restrictions=@Restriction(requiredPermission=REFERENCE_REMOTE_RESOURCES,explanation="Client Library Location can reference resources over HTTP"))
public class PublishJMS
extends AbstractJMSProcessor<JMSPublisher>
An implementation of JMS Message publishing
Processor which upon each
invocation of AbstractJMSProcessor.onTrigger(ProcessContext, ProcessSession) method will
construct a Message from the contents of the FlowFile sending
it to the Destination identified by the
AbstractJMSProcessor.DESTINATION property while transferring the
incoming FlowFile to 'success' Relationship. If message can
not be constructed and/or sent the incoming FlowFile will be
transitioned to 'failure' Relationship-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.nifi.jms.processors.AbstractJMSProcessor
AbstractJMSProcessor.ConnectionFactoryConfigValidator -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final PropertyDescriptor(package private) static final PropertyDescriptor(package private) static final PropertyDescriptorprivate static final List<PropertyDescriptor> (package private) static final PropertyDescriptor(package private) static final PropertyDescriptorstatic final Relationshipstatic final Relationshipprivate static final Set<Relationship> Fields inherited from class org.apache.nifi.jms.processors.AbstractJMSProcessor
BASE_RECORD_READER, BASE_RECORD_WRITER, BYTES_MESSAGE, CF_SERVICE, CHARSET, CLIENT_ID, DESTINATION, DESTINATION_TYPE, JMS_CF_PROPERTIES, JNDI_JMS_CF_PROPERTIES, PASSWORD, QUEUE, TEXT_MESSAGE, TOPIC, USER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate byte[]extractMessageBody(FlowFile flowFile, ProcessSession session) Extracts contents of theFlowFileas byte array.private StringextractTextMessageBody(FlowFile flowFile, ProcessSession session, String charset) protected JMSPublisherfinishBuildingJmsWorker(org.springframework.jms.connection.CachingConnectionFactory connectionFactory, org.springframework.jms.core.JmsTemplate jmsTemplate, ProcessContext processContext) Will create an instance ofJMSPublisherprotected List<PropertyDescriptor> private voidhandleException(ProcessContext context, ProcessSession processSession, JMSPublisher publisher, FlowFile flowFile, Exception e) private voidprocessStandardFlowFile(ProcessContext context, ProcessSession processSession, JMSPublisher publisher, FlowFile flowFile, String destinationName, String charset, Map<String, String> attributesToSend) private voidpublishMessage(ProcessContext context, ProcessSession processSession, JMSPublisher publisher, FlowFile flowFile, String destinationName, String charset, Map<String, String> attributesToSend) protected voidrendezvousWithJms(ProcessContext context, ProcessSession processSession, JMSPublisher publisher) Will construct JMSMessageby extracting its body from the incomingFlowFile.Methods inherited from class org.apache.nifi.jms.processors.AbstractJMSProcessor
close, customValidate, getClientId, getSupportedDynamicPropertyDescriptor, migrateProperties, onTrigger, setClientId, setupConnectionFactoryProvider, setupWorkerPool, shutdownConnectionFactoryProviderMethods inherited from class org.apache.nifi.processor.AbstractProcessor
onTriggerMethods inherited from class org.apache.nifi.processor.AbstractSessionFactoryProcessor
getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, init, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrueMethods inherited from class org.apache.nifi.components.AbstractConfigurableComponent
equals, getPropertyDescriptor, getPropertyDescriptors, hashCode, onPropertyModified, validateMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.nifi.components.ConfigurableComponent
getPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validateMethods inherited from interface org.apache.nifi.processor.Processor
isStateful, migrateRelationships
-
Field Details
-
MESSAGE_BODY
-
ALLOW_ILLEGAL_HEADER_CHARS
-
ATTRIBUTES_AS_HEADERS_REGEX
-
RECORD_READER
-
RECORD_WRITER
-
REL_SUCCESS
-
REL_FAILURE
-
propertyDescriptors
-
relationships
-
-
Constructor Details
-
PublishJMS
public PublishJMS()
-
-
Method Details
-
rendezvousWithJms
protected void rendezvousWithJms(ProcessContext context, ProcessSession processSession, JMSPublisher publisher) throws ProcessException Will construct JMSMessageby extracting its body from the incomingFlowFile.FlowFileattributes that represent standard JMS headers will be extracted from theFlowFileand set as JMS headers on the newly constructed message. For the list of available message headers please seeJmsHeaders.
Upon success the incomingFlowFileis transferred to the 'success'Relationshipand upon failure FlowFile is penalized and transferred to the 'failure'Relationship- Specified by:
rendezvousWithJmsin classAbstractJMSProcessor<JMSPublisher>- Throws:
ProcessException
-
handleException
private void handleException(ProcessContext context, ProcessSession processSession, JMSPublisher publisher, FlowFile flowFile, Exception e) -
getSupportedPropertyDescriptors
- Overrides:
getSupportedPropertyDescriptorsin classAbstractConfigurableComponent
-
getRelationships
- Specified by:
getRelationshipsin interfaceProcessor- Overrides:
getRelationshipsin classAbstractSessionFactoryProcessor
-
finishBuildingJmsWorker
protected JMSPublisher finishBuildingJmsWorker(org.springframework.jms.connection.CachingConnectionFactory connectionFactory, org.springframework.jms.core.JmsTemplate jmsTemplate, ProcessContext processContext) Will create an instance ofJMSPublisher- Specified by:
finishBuildingJmsWorkerin classAbstractJMSProcessor<JMSPublisher>- See Also:
-
processStandardFlowFile
private void processStandardFlowFile(ProcessContext context, ProcessSession processSession, JMSPublisher publisher, FlowFile flowFile, String destinationName, String charset, Map<String, String> attributesToSend) -
publishMessage
private void publishMessage(ProcessContext context, ProcessSession processSession, JMSPublisher publisher, FlowFile flowFile, String destinationName, String charset, Map<String, String> attributesToSend) -
extractMessageBody
Extracts contents of theFlowFileas byte array. -
extractTextMessageBody
-