Setting Up Messaging Overview
  • 15 Jul 2022
  • 3 Minutes to read
  • Dark
    Light

Setting Up Messaging Overview

  • Dark
    Light

Decisions Messaging is a pluggable system that can be extended via the SDK to support built-in messaging systems such as RabbitMQ, Azure Service Bus, and Apache Kafka.

In addition to the message queue, a Message Queue Handler needs to be configured to process the messages. This is a Flow that subscribes to a message queue and runs for every message in the queue. 

Building a Message Handler Flow requires different steps depending on the format for its contents. Each format has its own steps that extract the contents of the Message. 

Prerequisites

A Message Queue module must be installed onto a Decisions instance to follow alongside this article's instructions. The following pre-built Messaging System modules are available:

If using In-Memory, a File System, or a database message queues, then these modules are not necessary. 

In addition, if an environment is clustered, message queue handlers will behave like an interval job and will run on every server inside the cluster.


Setting up a Listener/Message Handler

To subscribe to messages in a queue, a Message Handler Flow needs to be configured. This will be used to interpret and run actions on messages received from the queue.

The following example will demonstrate how to pull messages from a RabbitMQ. A similar process will be involved for other message queues.

  1. From a Designer Project, create a new Flow.
  2. Navigate to the Properties panel for the Flow. Under the SETTINGS category select the dropdown menu under Behavior Type and select Message Queue Handler Flow.

    Choosing this Flow behavior provides three additional Flow Inputs; Message, Handler Id, and Headers. The Message Input contains the Payload (Byte[]), Id (String), and MessageDateTime (DateTime) Inputs.
  3. From Toolbox, navigate to DATA > TEXT and attach a Get String From UTF 8 Bytes step to the Start step. 
  4. On the Properties panel under INPUTS, click Unknown and select Select From Flow. Click Message, select Payload, and click DONE. 
    RabbitMQ Messages are typically encoded in UTF8. Other messengers may use Base 64, Ascii, or a different UTF decoding step to help decode the Payload.

  5. Attach a Show Popup step from Toolbox > FAVORITE STEPS, to the workspace. Map GetStringFromUTF8Bytes1_Output to Message, and Constant map the desired Subject

  6. Click Save to save changes to the Flow.


Subscribing to a Queue

The messaging system Queue will need to be configured in order for Decisions to subscribe to it.

  1. If a Queue has not been added, navigate to System > Jobs & Events > Message Queues. Click ADD RABBIT QUEUE from the Global Action Bar
  2. From the Add Rabbit Queue window, define the Message Queue parameters and click SAVE. 



Connect Processing Flow to Queue

The following demonstrates a Message Queue Handler. The setting options can be overridden to specify different servers or queues by navigating to System > Jobs and Events > Message Queues, creating a message queue, and selecting the Override Server Info option.

  1. Navigate to System > Jobs and Events > Message Queue Handlers. Click ADD MESSAGE HANDLER.
  2. From the Add Message Handler window, define the desired Handler Name, select the desired Message Handling behavior, define the Active Flow Count, create or pick the Message Handler Flow, then select the Message Queue. Click SAVE. 
    Configuration OptionsDescription
    Handler NameName to display in Decisions
    Message HandlingSets the Message Handling mode to lease the message (lock), lease the message temporarily (lock with auto timeout), remove it after processing (pop), or use it but leave it on the Queue (peek)

    LeaseReads Messages from the Message Server and tells the Message Server that they are being processed, this is used when every Message must be handled. The Message Server keeps them in the Queue, marking them as "leased" by a client (that is, Decisions), and does not deliver them to any other client that requests Messages from the Queue. When Decisions finishes handling the Message by running the Handler Flow, it tells the Message Server that the Message has been handled and the Message Server marks it for deletion. If Decisions doesn't do this (for example, if the Handler Flow encountered an error), then the lease on that Message will eventually timeout and the Message Server will mark it as deliverable to another client. Lease mode is slightly slower than Get mode but doesn't have the problem where Messages can be lost in memory prior to being processed if the Decisions server shuts down or gets rebooted.

    Lease w/ Expire

    GetReads Messages from the Message Server and tells the Message Server that they have been handled. The Message Server removes them from its Message Queue. This mode instructs the relevant Message Server or third party client to pull Messages off of the Message Server as fast as possible and keep them in an in-memory list for Decisions to pull from

    Get and Remove
    Active Flow CountMaximum number of simultaneous Messages that Decisions will process
    PICK HANDLER FLOWThe Flow used to process Messages that appear in the Queue
    Message QueueThe Queue for the Handler to listen on, that was configured in System Settings



For further information on Modules, visit the Decisions Forum.

Was this article helpful?

What's Next