A message queue is a form of communication between different software components or systems. It is widely used in distributed systems to enable asynchronous communication and decouple different parts of a system. The basic idea is to allow one part of a system to send a message to another part without requiring the sender to wait for an immediate response.
Description: Returns the current data structure of the message queue ('queue' or 'stack').
Parameters: None.
Returns: A string representing the current data structure.
Description: Registers a message provider for a specific service.
Parameters:
- serviceName (string): The name of the service.
- callback (function): The callback function to be executed when messages are provided by the service.
Description: Unregisters a message provider for a specific service.
Parameters:
- serviceName (string): The name of the service to unregister.
Description: Registers a message consumer for a specific service and topic.
Parameters:
- serviceName (string): The name of the service.
- topic (string): The topic for which the consumer is registered.
- callback (function): The callback function to be executed when messages are available for the service and topic.
Description: Unregisters a message consumer for a specific service and topic.
Parameters:
- serviceName (string): The name of the service.
- topic (string): The topic for which the consumer is unregistered.
- callback (function): The callback function to be unregistered.
Description: Adds a new message to the message queue or stack.
Parameters:
- topic (string): The topic to which the message belongs.
- message (any): The content of the message.
- priority (number, optional): The priority of the message (default is 0).
Description: Sorts the messages in the queue based on their priority.
Description: Trims the size of the message queue or stack to meet the specified maximum size.
Description: Acknowledges and removes a message from the message queue or stack based on its ID.
Parameters:
- messageId (string): The ID of the message to be acknowledged.
Returns: A string indicating the acknowledgment result.
Description: Dequeues and returns messages from the message queue or stack.
Returns: An array of messages that have been dequeued.
Description: Starts the automatic dequeue process at a specified interval. Stops automatically if the queue is empty.
Note: Adjust the interval as needed based on your application's requirements.
Description: Generates a unique message ID using the uuid library.
Returns: A unique message ID.