Options
All
  • Public
  • Public/Protected
  • All
Menu

Class QueueManager

The queue manager allows different parts of your application to communicate and perform activities asynchronously.

A message queue provides a buffer that temporarily stores messages and dispatches them to their consuming service. The messages are usually small, and can be things like requests, replies or error messages, etc.

Typically, in Altogic, you submit messages to a queue in your backend app services using the Submit Message to Queue node. However, with Altogic's client API by calling the submitMessage method, you can manually send messages to your selected queue for processing.

export

Hierarchy

Index

Constructors

  • Creates an instance of QueueManager to submit messages to your backend app message queues.

    Parameters

    • fetcher: Fetcher

      The http client to make RESTful API calls to the application's execution engine

    Returns QueueManager

Properties

fetcher: Fetcher

The http client to make RESTful API calls to the application's execution engine

Methods

  • getMessageStatus(messageId: string): Promise<{ errors: null | APIError; info: null | MessageInfo }>
  • Gets the latest status of the message. The last seven days message queue logs are kept. If you try to get the status of a message that has been submitted earlier, this method returns null for MessageInfo.

    If the client library key is set to enforce session, an active user session is required (e.g., user needs to be logged in) to call this method.

    Parameters

    • messageId: string

      The id of the message

    Returns Promise<{ errors: null | APIError; info: null | MessageInfo }>

    If successful, returns status information about the submitted message

  • submitMessage(queueNameOrId: string, message: object, delay?: number): Promise<{ errors: null | APIError; info: null | MessageInfo }>
  • Submits a message to the specified message queue for asychronous processing. After the message is submitted, the routed service defined in your message queue configuration is invoked. This routed service processes the input message and performs necessary tasks defined in its service flow.

    You can also specify a delay (in seconds) between message submission to the queue and routed service invocation. As an example, you would like to send a welcome email to your new users when they sign up. Instead of sending this email immediately after sign up, you can send it after 24 hours later (e.g., 60 x 60 x 24 = 86400 seconds)

    The structure of the message (e.g., key-value pairs) is defined by the Start Node of your queue service.

    If the client library key is set to enforce session, an active user session is required (e.g., user needs to be logged in) to call this method.

    Parameters

    • queueNameOrId: string

      The name or id of the message queue.

    • message: object

      The message payload (JSON object) that will be submitted to the message queue

    • Optional delay: number

      The number of seconds to delay the messages in queue before dispacthing them to their consuming service

    Returns Promise<{ errors: null | APIError; info: null | MessageInfo }>

    If successful, returns information about the submitted message. You can use messageId to check the processing status of your message by calling getMessageStatus method. In case of an errors, returns the errors that occurred.

Generated using TypeDoc