Setting Up Messaging OverviewLast Updated: 03/22/2016 Introduced in Verision: 2.0
How to setup Decisions to work with a messaging system. Decisions Messaging is a pluggable system that can be extended via our SDK. It is available in the Decisions Platform 3.2.x. The built in messaging systems are: RabbitMQ, Database Queue, File System Queue, In Memory Queue.
RabbitMQ was chosen as our only default 3rd party messaging system due to its simplicity and reliability.
For more information on adding new messaging system please see the SDK docs: http://decdocs3x.wpengine.com/sdk
Once you have a successfully installed build of Decisions you need to choose what messaging system you will use. If you’re using In Memory, File System, or Database you do not need to install any additional modules. For RabbitMQ you will need to install the RabbitMQ module from the modules page under /System/Administration/Modules
Note: to install Module in Decisions 3.5 or newer, please read the following document.
Setting up a Listener
To subscribe to messages in a queue you must first set up the flow that is going to handle messages.
Creating a Message Handler Flow
To create a message handler flow simply select the flow behavior “Message Queue Flow” as shown below.
The inputs to this flow will now automatically include a “Handler Id” and a “Message Queue Message” which has the following properties:
- Payload (byte)
- Message Id (string)
- Message Date (date time)
The payload is the most important part of the message. If the message you’re expecting is text you’ll need to use a Base 64, Ascii, or UTF decoding step depending on the type of messaging system you’re receiving messages from.
For RabbitMQ the messages will be typically UTF8 encoded.
Now you can use the message payload the way you would any other data. For example you could use it to show a pop up notification.
Now that you have a flow that can handle a message so now we need to connect it to a message queue.
Subscribing to a Queue
Decisions needs you to configure the queues in Rabbit (or other system) that you want to subscribe to. You do this usually in /System/Settings but it depends on the messaging implementation.
Go to /System/Settings and edit “RabbitMQ Settings”.
Add a queue to the list by pressing “Add New” –
This step simply makes Decisions aware of queues that are available and connects these queues to the base Decisions messaging service through our APIs.
Now that Decisions knows about the queue we are ready to connect our processing flow to the queue.
Connect Processing Flow to Queue
Browse to /System/Jobs and Events/Message Queue Handlers
In this folder you create handlers which tie queues to workflows.
Click the ‘Add Handler’ button at the top of this page and fill out the following settings:
- Handler Name – a name that will allow you to remember what this processor is for.
- Message Handling – do you lease the message (lock), lease the message temporarily (lock with auto timeout), remove it after processing (pop), or use it but leave it on queue (peek).
- Active Flow Count – how many concurrent flows this handler can run when dealing with messages
- Handler Flow – this is the flow we created above
- Message Queue – the queue that you configured in system settings.
Now test your handler by sending a message to the queue. This can easily be done by creating a flow and using the ‘Push’ step to push a message to a queue.