Skip to content

Using the MessageQueue

Kilemonn edited this page Jan 15, 2024 · 5 revisions

The MessageQueue is relatively flexible and depending on your needs will depend on how you utilise it. This page will explain some simple use cases and how you would go about interacting with the MessageQueue to achieve these types of behaviours.

Understanding MessageQueue Configuration

The MessageQueue's configuration settings and environmental property settings can be seen by calling: GET - https://<host-name>/settings.

Retrieving Enqueued Messages as needed

The most simple scenario to utilise the MessageQueue would be to enqueue events as they occur. And have another application constantly polling the MessageQueue to see if there are any new messages available.

Messages can be created via the POST - https://<host-name>/queue/entry API.

Knowing which subQueue your messages are created in, the applction can be polled by calling PUT - https://<host-name>/queue/next providing parameters for the subQueue and assignedTo which will determine which subQueue will be scanned for next available and unassigned messages. If a message is available it will be retrieved and assigned to the provided identifier then retrieved.

Once a message is assigned it cannot be retrieved via the https://<host-name>/queue/next endpoint as only unassigned messages can be retrieved from here. The message is still available in the MessageQueue and can be retrieved by uuid (https://<host-name>/queue/entry/{uuid}) or other means https://<host-name>/queue/owned, https://<host-name>/queue/all.

Once the message has been processed properly the polling application can delete this message completely from the MessageQueue via DELETE - https://<host-name>/queue/entry. Or the message can be retained in the MultiQueue in the assigned state.

Retrieving a list of Owners

If for some reason you lose track of some of the owner identifers you can call the GET - https://<host-name>/queue/owner endpoint to retrieve a mapping of owner (assignee) identifiers and a list of the subQueues that they have assigned messages in.

Example response:

{
  "owner1": [
    "email-messages"
  ],
  "owner2": [
    "email-messages", "notifications", "background-job-X"
  ],
  "owner3": [
    "background-job-X"
  ]
}

After calling this endpoint you want to probably call the GET - https://<host-name>/queue/owned endpoint with each assignee identifier and subQueue to iterate over the owned messages.

Retrieving Owned Messages

There are some scenarios where you may want to know which messages are owned and by which identifiers. Once these messages are found, maybe they need to be released/unassigned or removed from the MuliQueue.

Calling GET - https://<host-name>/queue/owned will retrieve a list of all messages that are assigned to the provided assignedTo identifier and subQueue identifier.

Clone this wiki locally