--- alias: user-guide-automation-task-core-rabbitMQ-subscribe-from-queue tags: - automation tasks - rabbitMQ description: "This task establishes a RabbitMQ subscription to a queue, handling acknowledgements and potential errors" --- # RabbitMQ Subscribe from Queue :iot-messagebus-listener-lg: The `RabbitMQ Subscribe from Queue` task will create a subscription to a particular Queue. If the request awaits for a reply it will create an execution context to acknowledge. This task is paired with the `RabbitMQ Acknowledge` task to return an acknowledge. ![Subscribe From Queue Task](../images/rabbitmq_subscribefromqueue.png) ## Inputs | Name | Data Type | Description | |-----------------------|-----------|----------------------------------------------------------------------| | Queue Name | `String` | The Queue name to send the message. | | Delete on unsubscribe | `Boolean` | Should delete Queue on unsubscribe. | | ReplyTimeout | `Integer` | Amount of time allowed to wait for a reply before issuing a timeout. | | Enable/Disable | `Boolean` | Activates or deactivates the subscription. Only needed when the `Auto Enable` setting is disabled; otherwise the task subscribes automatically once connected. | ## Outputs | Name | Data Type | Description | |------------|-----------|---------------------------------------------------------| | Topic | `String` | The topic received. | | rawMessage | `any` | The raw message received. | | message | `String` | The message content received. | | Success | `Boolean` | If there was no problem emits a true. | | Error | `Error` | Error that occurred during the processing of this task. | ## Settings | Name | Data Type | Default | Description | |-----------------------|-----------|----------------|----------------------------------------------------------------------------| | Queue Name | `String` | `defaultQueue` | The exchange Name to publish to. | | Auto Enable | `Boolean` | true | Automatically subscribe when the RabbitMQ connection is established. | | Auto Ack | `Boolean` | true | Should an automatic acknowledge be sent upon receiving a message. | | Delete on unsubscribe | `Boolean` | false | Should the exchange (and associated queue) be deleted on un-subscription. | | Reply Timeout | `Integer` | 60000 | Amount of time allowed to wait for a reply before issuing a timeout. | ## Behavior The `RabbitMQ Subscribe from Queue` task creates a subscription for a specific Queue and a context for each received message. If the request expects an acknowledge, the task waits for an execution from the `RabbitMQ Acknowledge` task within `ReplyTimeout`. When `Auto Enable` is set (the default), the task subscribes automatically as soon as the RabbitMQ connection is established, without needing the `Enable/Disable` input to be wired. If `Auto Enable` is disabled, the subscription is instead controlled by the `Enable/Disable` input: if set to true it subscribes, otherwise it unsubscribes, and the input must be wired to a triggering signal (for example, a controller-level enable flag) for the subscription to start. ## Remarks * This task allows the user to explicitly define the deletion of the queue related with the subscription. This might be useful when queue is only being used by this task, this way when the un-subscription occurs no durable queues stay on the rabbitMQ.