--- alias: user-guide-automation-task-core-rabbitMQ-send-message-to-queue tags: - automation tasks - rabbitMQ description: "This task sends messages to a RabbitMQ queue, optionally awaiting confirmation of delivery" --- # RabbitMQ Send Message to Queue :iot-messagebus-send-lg: The `RabbitMQ Send Message to Queue` task will send a message to a particular queue. ![Send Message To Queue Task](../images/rabbitmq_sendmessagetoqueue.png) ## Inputs | Name | Data Type | Description | |------------------------|-----------|------------------------------------------------------------------| | QueueName | `String` | The name of the RabbitMQ queue to send the message to. If left empty, the task will attempt to use the default queue name configured in the settings. | | Message | `String` | The message content to be published to the queue. | | Wait For Confirmation? | `Boolean` | If `true`, the task will wait for confirmation from RabbitMQ that the message has been received. Defaults to `true`. | | Activate | `any` | Triggers the task to send the message to the specified queue. | ## Outputs | Name | Data Type | Values | Description | |---------|-----------|--------|--------------------------------------------------------------------------------| | Success | `Boolean` | | Emits `true` when the message is successfully sent (and optionally confirmed). | | Error | `Error` | | Emits an `Error` object if sending the message fails. | ## Settings | Name | Data Type | Default | Description | |------------------------|-----------|----------------|--------------------------------------------------------------------------| | Queue Name | `String` | `defaultQueue` | The default name of the RabbitMQ queue to send messages to. This value will be used if the `queueName` input is not provided when the task is activated. | | Message | `String` | | The default message to be sent. | | Wait For Confirmation? | `Boolean` | false | The default value for `Wait For Confirmation?` flag. | ## Behavior The `RabbitMQ Send Message to Queue` task sends a message to a RabbitMQ Queue. It also supports sending a message and expecting a confirmation from the RabbitMQ. When the `Activate` input is triggered, this task determines the target RabbitMQ queue. It first checks if a `Queue Name` is provided through the input. If so, it uses that value. If the `queueName` input is empty, the task will use the "Queue Name" configured in its settings. The task then uses the injected `RabbitMQManager` to publish the provided `Message` to the determined queue. The `Wait For Confirmation` setting controls whether the task waits for an acknowledgement from the RabbitMQ broker before emitting the `Success` output. If the message is successfully sent (and confirmed if `Wait For Confirmation` is `true`), the `Success` output emits `true`. If any error occurs during the process (e.g., connection issues with RabbitMQ, invalid queue name), the `Error` output will emit an `Error` object containing details about the failure. ## Remarks * This task provides a straightforward way to publish messages to specific RabbitMQ queues. * Enabling "Wait for Confirmation" enhances reliability by ensuring the sender is notified if the message was successfully received by the RabbitMQ broker. Consider the performance implications of enabling this option in high-throughput scenarios. * Implementing error handling for the `Error` output is crucial for managing potential issues with the RabbitMQ connection or the target queue. * Remember to include a RabbitMQ Setup task in your workflow before using this task to ensure a proper connection to the RabbitMQ server is established.