Skip to main content

RabbitMQ Producer

Purpose

This target publishes variables, devices, alarms, and plugin events to a RabbitMQ exchange and routes them to queues.

Configure the forwarding group and target through Data Forwarding. This page covers RabbitMQ connection, exchange behavior, Topic templates, and debug operations.

Open the plugin

Open Development Configuration → Data Forwarding and:

  1. Configure and save the forwarding group range, trigger, interval, online filter, and batching.
  2. Add a target, choose RabbitMQ Producer, and fill in the basic target information.
  3. Open Target properties and configure connection, authentication, exchange, routing keys, templates, and cache.
  4. Save and enable the group and target, then use Target debug to verify routing and payloads.

Basic target information

SettingDefaultConfiguration
Group-Select a saved forwarding group.
Target name-Required and unique within the group. Include the RabbitMQ cluster or environment.
EnableEnabledDisable to stop the producer from connecting.
Log levelInfoTemporarily use Debug for connection, declaration, or publish diagnostics.
Start timeout60 secondsValid range is 1 to 3600 seconds.

Target properties

Connection and authentication

SettingDefaultConfiguration
IP addresslocalhostRabbitMQ host or IP without a scheme.
Port5672AMQP default port; use the Listener's configured TLS port when applicable.
Virtual host/Virtual Host containing the exchange, queues, and bindings.
UsernameguestUse a least-privilege production account instead of the default account.
PasswordguestChange the default in production; never expose it in templates, screenshots, or logs.

This target exposes no separate TLS switch or certificate property. TLS must be provided by the RabbitMQ Listener and deployment configuration used by the current connection factory.

Exchange and publishing

SettingDefaultConfiguration
Declare queueDisabledStartup declares durable queues for non-empty Topic templates and binds each queue using the same routing key. Use only with broker permission.
Declare exchangeDisabledStartup declares a durable, non-auto-delete exchange. Existing type must match.
Publisher confirmationsEnabledWaits for Broker publisher confirmations.
Require routing successEnabledUses AMQP mandatory publishing; unroutable messages are treated as failures.
Exchange typetopicMust match RabbitMQ: direct, fanout, topic, or headers.
Exchange nameTGExchange receiving the messages. Create it in the selected vhost when declaration is disabled.
Publish timeout5000 msPositive timeout for publishing and channel acquisition.

Routing-key templates

SettingDefaultConfiguration
Device Topic templateEmptyEmpty disables device records; use a fixed key when queue declaration is enabled.
Variable Topic templateThingsGateway/VariableVariable routing key; ${DeviceName} and ${Name} may be used.
Alarm Topic templateEmptyEmpty disables alarm records.
Plugin-event Topic templateEmptyEmpty disables plugin-event records.

${field} must exist on the upload entity or entity-script result. The forwarding group controls membership; exchange, routing key, and queue binding control delivery.

Target-variable properties

RabbitMQ inherits the optional text fields Data1 to Data10, all empty by default. They are metadata only and are not added to messages automatically. Configure variable membership, aliases, trigger, and batching in Data Forwarding.

SettingDefaultConfiguration
Data1 to Data10EmptyFill project-specific metadata when needed; leave empty otherwise and never store passwords or tokens here.

Data and scripts

SettingDefaultConfiguration
Detail logDisabledEnable briefly to inspect publish payloads or counts.
JSON indentationEnabledDisable to reduce payload size.
Ignore JSON nullsEnabledDisable when null fields must remain.
Device list uploadEnabledPublish device records as a list; disable for one message per record.
Variable list uploadEnabledPublish variable records as a list; disable for one message per record.
Variable dictionary uploadDisabledApplies only to variable-list mode; groups by DeviceName → Name → Value.
Alarm list uploadEnabledPublish alarm records as a list; disable for one message per record.
Alarm dictionary uploadDisabledApplies only to alarm-list mode; groups by device and variable.
Plugin-event list uploadEnabledPublish plugin events as a list; disable for one message per event.
Entity scriptsEmptySelect saved device, variable, alarm, or plugin-event scripts before routing-key and payload rendering.

Upload template fields

In Upload Template Configuration, choose Text or Json for each entity and insert ${field} placeholders. Empty content uses default JSON serialization; preview before saving.

EntityAvailable fields
VariableId, Name, DeviceName, Value, RawValue, LastSetValue, CollectGroup, CollectTime, CreateTime, ChangeTime, IsOnline, DataType, Unit, RegisterAddress, OtherMethod, Description, ProtectType, RpcWriteEnable, Remark1 to Remark5, ValueInited, IsMemory
DeviceId, Name, ActiveTime, DeviceStatus, PluginName, Description, LastErrorMessage, Remark1 to Remark5
AlarmAlarmId, VariableId, Name, DeviceName, AlarmCode, AlarmLevel, AlarmLimit, AlarmText, RecoveryCode, AlarmTime, EventTime, FinishTime, ConfirmTime, ConfirmText, AlarmType, EventType, Remark1 to Remark5
Plugin eventDeviceName, ObjectValue

An entity script runs before routing-key and template rendering; its output must contain every referenced field. An empty Topic template disables that entity type.

Cache and capacity

SettingDefaultConfiguration
Enable failed-write retry cacheDisabledEnable in production to retain failed publishes in CacheDB and replay them after recovery.
Cache file maximum rows262144Maximum CacheDB outbox rows; oldest rows are removed after the limit.
Upload chunk size2000Maximum records per write or replay batch.
Memory queue limit100000Maximum in-memory records before CacheDB handoff; sustained overload can still discard old data.
Filter offline dataDisabledFilters offline variables at dequeue; the forwarding-group filter also applies.
Upload concurrency1RabbitMQ maintains a channel pool using this value; keep 1 until parallel load is tested.

Target debug

Open Development Configuration → Data Forwarding, select the forwarding group and target, and open Debug.

RabbitMQ protocol panel

RabbitMQ Producer protocol debug panel

Use the panel to perform the plugin-specific connection or publish operation and inspect the result.

Verify the target

  1. Confirm host, port, virtual host, credentials, exchange, and exchange type.
  2. Confirm that the exchange and queue/binding are managed by the target or already exist in RabbitMQ.
  3. Use a test routing key and small payload.
  4. Consume the queue and compare message count and payload.
  5. Check publisher confirmations, routing results, and target logs.

Troubleshooting

SymptomCheck
Queue receives no messageHost, virtual host, exchange, exchange type, routing key, queue binding, and target state.
Authentication failsUsername, password, virtual host permissions, and the RabbitMQ listener.
Routing is rejectedExchange type, routing key, queue binding, and Require routing success.
Declaration failsBroker account permissions, existing resource type, queue/exchange name, and declaration switches.
Publish times outBroker reachability, publisher confirmations, network latency, publish timeout, and broker load.
Payload is invalidTemplate preview, JSON syntax, placeholder names, and entity-script output.

Do not declare or delete production queues and exchanges during a routine debug session unless the broker owner has approved the change.