Queue Trigger
Frends can be used in event-driven architecture as AMQP subscriber with a Queue Trigger. The Queue Triggers enable triggering Processes in messages received from an AMQP 1.0 queue. The Queue Trigger consumes the message from the queue whenever there is a new message available in the queue. The contents of the consumed message are then available in the Process for further processing.
Queue Trigger parameters
The Queue Trigger offers the following configuration properties to connect to a specified queue.
Queue
- The name of the AMQP queue which is listened toBus Uri
- The URI for the the AMQP Bus, e.g. amqps://owner:@.servicebus.windows.net:5671Reply
- Should we send a succeeding Process result to the Queue specified by theReplyTo
optionReply Errors
- Should we send a failing Process result to the Queue specified by theReply To
optionReply To
- The queue where we should send the replies toQueue is durable
- If set, the queue is expected to be durable, i.e. it will survive possible broker restarts.
This setting needs to match the actual configuration of the queue, if it has been created beforehand.
Please note that this setting is only recognized by Frends Agents in version 5.2.4 and above.
Receiving messages
The Queue Trigger receives and accepts(completes) messages from the queue as they arrive with the limit of 10 concurrent messages being processed per Queue Trigger per Agent. If configured to do so, the Trigger will send a reply message to the 'Reply To' queue when the Process finishes.
Note: The AMQP body may contain different types of data. Most of the time this is provided as is to the Process, the exception being when the body is a byte array and the property 'ContentType' has the 'Charset' field set, e.g. 'text/plain; charset=UTF-8'. In this case the binary data is converted to a string with the encoding matching the charset.
Reply messages
If the Process failed and Reply Errors
was selected, the exception that caused the failure will be written to the reply message. The message will have a new Guid as the MessageId and the same CorrelationId as the original Trigger message.
When returning a success to a queue, the result is written as the body of the message. Complex structures(objects) are serialized by default as JSON. In this case the Correlation Id of the triggering message is copied to the reply message.
It is possible to define the message structure directly in the result. This is done when the result contains an object which has at least either of the properties Body
or ApplicationProperties
. In this case the result object is mapped directly as the reply message with the following structure:
Body: object - the body of the reply message ApplicationProperties: Dictionary - the custom headers for the message Properties - the AMQP message properties MessageId; string AbsoluteExpiryTime: DateTime ContentEncoding: string ContentType: string CorrelationId: string CreationTime: DateTime GroupId: string GroupSequence: uint ReplyToGroupId: string ReplyTo: string Subject: string UserId: byte[] To: string
Referencing Trigger parameter values
#trigger.data.body
- The body of the message.#trigger.data.applicationProperties
- The custom headers of the message#trigger.data.properties
- The AMQP message properties, see this for more details
The next article is Introduction to Service Bus Trigger