Package org.apache.nifi.jms.processors
Class ConsumeJMS
- All Implemented Interfaces:
ConfigurableComponent,Processor
@Tags({"jms","get","message","receive","consume"})
@InputRequirement(INPUT_FORBIDDEN)
@CapabilityDescription("Consumes JMS Message of type BytesMessage, TextMessage, ObjectMessage, MapMessage or StreamMessage transforming its content to a FlowFile and transitioning it to \'success\' relationship. JMS attributes such as headers and properties will be copied as FlowFile attributes. MapMessages will be transformed into JSONs and then into byte arrays. The other types will have their raw contents as byte array transferred into the flowfile.")
@WritesAttribute(attribute="jms_deliveryMode",description="The JMSDeliveryMode from the message header.") @WritesAttribute(attribute="jms_expiration",description="The JMSExpiration from the message header.") @WritesAttribute(attribute="jms_priority",description="The JMSPriority from the message header.") @WritesAttribute(attribute="jms_redelivered",description="The JMSRedelivered from the message header.") @WritesAttribute(attribute="jms_timestamp",description="The JMSTimestamp from the message header.") @WritesAttribute(attribute="jms_correlationId",description="The JMSCorrelationID from the message header.") @WritesAttribute(attribute="jms_messageId",description="The JMSMessageID from the message header.") @WritesAttribute(attribute="jms_type",description="The JMSType from the message header.") @WritesAttribute(attribute="jms_replyTo",description="The JMSReplyTo from the message header.") @WritesAttribute(attribute="jms_destination",description="The JMSDestination from the message header.") @WritesAttribute(attribute="jms.messagetype",description="The JMS message type, can be TextMessage, BytesMessage, ObjectMessage, MapMessage or StreamMessage).") @WritesAttribute(attribute="other attributes",description="Each message property is written to an attribute.")
@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({PublishJMS.class,JMSConnectionFactoryProvider.class})
@Restricted(restrictions=@Restriction(requiredPermission=REFERENCE_REMOTE_RESOURCES,explanation="Client Library Location can reference resources over HTTP"))
public class ConsumeJMS
extends AbstractJMSProcessor<JMSConsumer>
Consuming JMS processor which upon each invocation of
AbstractJMSProcessor.onTrigger(ProcessContext, ProcessSession) method will construct a
FlowFile containing the body of the consumed JMS message and JMS
properties that came with message which are added to a FlowFile as
attributes.-
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 AllowableValue(package private) static final AllowableValueprivate static final Stringprivate static final Stringprivate static final String(package private) static final AllowableValue(package private) static final PropertyDescriptor(package private) static final PropertyDescriptorstatic final Stringstatic final String(package private) static final PropertyDescriptor(package private) static final PropertyDescriptorprivate static final List<PropertyDescriptor> static final PropertyDescriptorstatic final PropertyDescriptorstatic final Relationshipstatic final Relationshipprivate static final Set<Relationship> (package private) static final PropertyDescriptor(package private) static final PropertyDescriptor(package private) static final PropertyDescriptorFields 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 voidacknowledge(List<JMSConsumer.JMSResponse> processedMessages, List<JMSConsumer.JMSResponse> failedMessages) private voidacknowledge(JMSConsumer.JMSResponse response) private FlowFilecreateFlowFileFromMessage(ProcessSession processSession, String destinationName, JMSConsumer.JMSResponse response) protected Collection<ValidationResult> customValidate(ValidationContext validationContext) private JMSConsumer.JMSResponsefindLastBatchedJmsResponse(List<JMSConsumer.JMSResponse> processedMessages, List<JMSConsumer.JMSResponse> failedMessages) protected JMSConsumerfinishBuildingJmsWorker(org.springframework.jms.connection.CachingConnectionFactory connectionFactory, org.springframework.jms.core.JmsTemplate jmsTemplate, ProcessContext processContext) Will create an instance ofJMSConsumerprotected List<PropertyDescriptor> private static booleanisDurableSubscriber(ProcessContext context) private static booleanisShared(ProcessContext context) voidonSchedule(ProcessContext context) private voidprocessMessageSet(ProcessContext context, ProcessSession session, JMSConsumer consumer, String destinationName, String errorQueueName, boolean durable, boolean shared, String subscriptionName, String messageSelector, String charset) private voidprocessSingleMessage(ProcessSession processSession, JMSConsumer consumer, String destinationName, String errorQueueName, boolean durable, boolean shared, String subscriptionName, String messageSelector, String charset) private voidreject(List<JMSConsumer.JMSResponse> processedMessages, List<JMSConsumer.JMSResponse> failedMessages) protected voidrendezvousWithJms(ProcessContext context, ProcessSession processSession, JMSConsumer consumer) Will construct aFlowFilecontaining the body of the consumed JMS message (ifJMSConsumer.JMSResponsereturned byJMSConsumeris not null) and JMS properties that came with message which are added to aFlowFileas attributes, transferringFlowFileto 'success'Relationship.protected voidsetClientId(ProcessContext context, org.springframework.jms.connection.SingleConnectionFactory cachingFactory) Use provided clientId for non shared durable consumers, if not set always a different value as defined inAbstractJMSProcessor.setClientId(ProcessContext, SingleConnectionFactory).private FlowFileupdateFlowFileAttributesWithJMSAttributes(Map<String, String> jmsAttributes, FlowFile flowFile, ProcessSession processSession) Copies JMS attributes (i.e., headers and properties) as FF attributes.private voidMethods inherited from class org.apache.nifi.jms.processors.AbstractJMSProcessor
close, getClientId, getSupportedDynamicPropertyDescriptor, migrateProperties, onTrigger, 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
-
JMS_MESSAGETYPE
- See Also:
-
COUNTER_PARSE_FAILURES
- See Also:
-
COUNTER_RECORDS_RECEIVED
- See Also:
-
COUNTER_RECORDS_PROCESSED
- See Also:
-
AUTO_ACK
-
CLIENT_ACK
-
DUPS_OK
-
JMS_SOURCE_DESTINATION_NAME
- See Also:
-
MESSAGE_SELECTOR
-
ACKNOWLEDGEMENT_MODE
-
DURABLE_SUBSCRIBER
-
SHARED_SUBSCRIBER
-
SUBSCRIPTION_NAME
-
TIMEOUT
-
ERROR_QUEUE
-
RECORD_READER
-
RECORD_WRITER
-
OUTPUT_STRATEGY
-
REL_SUCCESS
-
REL_PARSE_FAILURE
-
relationships
-
propertyDescriptors
-
-
Constructor Details
-
ConsumeJMS
public ConsumeJMS()
-
-
Method Details
-
isDurableSubscriber
-
onSchedule
-
customValidate
- Overrides:
customValidatein classAbstractJMSProcessor<JMSConsumer>
-
rendezvousWithJms
protected void rendezvousWithJms(ProcessContext context, ProcessSession processSession, JMSConsumer consumer) throws ProcessException Will construct aFlowFilecontaining the body of the consumed JMS message (ifJMSConsumer.JMSResponsereturned byJMSConsumeris not null) and JMS properties that came with message which are added to aFlowFileas attributes, transferringFlowFileto 'success'Relationship.- Specified by:
rendezvousWithJmsin classAbstractJMSProcessor<JMSConsumer>- Throws:
ProcessException
-
processSingleMessage
private void processSingleMessage(ProcessSession processSession, JMSConsumer consumer, String destinationName, String errorQueueName, boolean durable, boolean shared, String subscriptionName, String messageSelector, String charset) -
createFlowFileFromMessage
private FlowFile createFlowFileFromMessage(ProcessSession processSession, String destinationName, JMSConsumer.JMSResponse response) -
processMessageSet
private void processMessageSet(ProcessContext context, ProcessSession session, JMSConsumer consumer, String destinationName, String errorQueueName, boolean durable, boolean shared, String subscriptionName, String messageSelector, String charset) -
acknowledge
-
acknowledge
private void acknowledge(List<JMSConsumer.JMSResponse> processedMessages, List<JMSConsumer.JMSResponse> failedMessages) -
reject
private void reject(List<JMSConsumer.JMSResponse> processedMessages, List<JMSConsumer.JMSResponse> failedMessages) -
withLog
-
findLastBatchedJmsResponse
private JMSConsumer.JMSResponse findLastBatchedJmsResponse(List<JMSConsumer.JMSResponse> processedMessages, List<JMSConsumer.JMSResponse> failedMessages) -
finishBuildingJmsWorker
protected JMSConsumer finishBuildingJmsWorker(org.springframework.jms.connection.CachingConnectionFactory connectionFactory, org.springframework.jms.core.JmsTemplate jmsTemplate, ProcessContext processContext) Will create an instance ofJMSConsumer- Specified by:
finishBuildingJmsWorkerin classAbstractJMSProcessor<JMSConsumer>- See Also:
-
getRelationships
- Specified by:
getRelationshipsin interfaceProcessor- Overrides:
getRelationshipsin classAbstractSessionFactoryProcessor
-
getSupportedPropertyDescriptors
- Overrides:
getSupportedPropertyDescriptorsin classAbstractConfigurableComponent
-
setClientId
protected void setClientId(ProcessContext context, org.springframework.jms.connection.SingleConnectionFactory cachingFactory) Use provided clientId for non shared durable consumers, if not set always a different value as defined in
SeeAbstractJMSProcessor.setClientId(ProcessContext, SingleConnectionFactory).Session.createDurableConsumer(javax.jms.Topic, String, String, boolean), in special following part: An unshared durable subscription is identified by a name specified by the client and by the client identifier, which must be set. An application which subsequently wishes to create a consumer on that unshared durable subscription must use the same client identifier.- Overrides:
setClientIdin classAbstractJMSProcessor<JMSConsumer>- Parameters:
context- context.cachingFactory- the connection factory.
-
updateFlowFileAttributesWithJMSAttributes
private FlowFile updateFlowFileAttributesWithJMSAttributes(Map<String, String> jmsAttributes, FlowFile flowFile, ProcessSession processSession) Copies JMS attributes (i.e., headers and properties) as FF attributes. Given that FF attributes mandate that values are of type String, the copied values of JMS attributes will be "stringified" via String.valueOf(attribute). -
mergeJmsAttributes
-