The TIBCO StreamBase® Adapter for RabbitMQ Consumer allows the system to consume data from a RabbitMQ broker. The connection to the broker can be shared across multiple RabbitMQ adapters and each adapter creates its own channel on the connection. A consumer can create an exchange and queue or use and existing exchange or queue. Each message received by the adapter from the broker will produce a tuple with the message as well as the envelope and the properties of that message.
This section describes the properties you can set for this adapter, using the various tabs of the Properties view in StreamBase Studio.
Name: Use this field to specify or change the component's name, which must be unique in the application. The name must contain only alphabetic characters, numbers, and underscores, and no hyphens or other special characters. The first character must be alphabetic or an underscore.
Operator: A read-only field that shows the formal name of the operator.
Start with application: If this field is set to Yes or to a module parameter that evaluates to true, an instance of this adapter starts as part of the containing StreamBase Server. If this field is set to No or to a module parameter that evaluates to false, the adapter is loaded with the server, but does not start until you send an sbadmin resume command, or until you start the component with StreamBase Manager. With this option set to No or false, the adapter does not start even if the application as a whole is suspended and later resumed. The recommended setting is selected by default.
Enable Error Output Port: Select this check box to add an Error Port to this component. In the EventFlow canvas, the Error Port shows as a red output port, always the last port for the component. See Using Error Ports and Error Streams to learn about Error Ports.
Description: Optionally enter text to briefly describe the component's purpose and function. In the EventFlow canvas, you can see the description by pressing Ctrl while the component's tooltip is displayed.
Property | Type | Description |
---|---|---|
RabbitMQ Server | drop-down list | A list of RabbitMQ server connections that were specified in the sbconf file. See the SBConf File Configuration section of this document for RabbitMQ connection options.
|
Create Channel On Connect | check box | When enabled a channel with the properties giving at design time is created. |
Qos | integer | When a positive integer value is supplied it is used as the channel's quality of service value. A value of 0 means unlimited. |
Qos Global | check box | When enabled the Qos setting is applied to the entire channel rather than each consumer. |
Enable Auto Acknowledge | check box | When enabled each message is considered acknowledged once delivered. When not enabled each message must be specifically acknowledged using the RabbitMQ Ack adapter. |
Message Data Type | drop-down list | The type of data that is stored in the message. This data type affects the output schema.
If custom or tuple is selected, the edit schema section must contain a valid schema. If custom is selected a valid class name must be provided that implements IRabbitMQDeserializer. Available values are: String, Tuple, Blob, Custom. |
Message Deserializer Class | string | The class that implements the IRabbitMQDeserializer and is instantiated to convert message bytes to the resulting message
schema.
NoteSee the section on custom serialization in this document. |
Enable Control Port | check box | When enabled a control port allows commands to be sent to the operator to perform actions during runtime. |
Enable Status Port | check box | When enabled a status port is available that emits status tuples for various events of this operator. |
Log Level | Drop-down list | Controls the level of verbosity the adapter uses to issue informational traces to the console. This setting is independent of the containing application's overall log level. Available values, in increasing order of verbosity, are: OFF, ERROR, WARN, INFO, DEBUG, TRACE, and ALL. |
Property | Type | Description |
---|---|---|
Name | string | The name of the exchange to connect to or create when Createchannel On Connect is enabled. If this value is blank the default exchange is used. This value cannot be blank if declare exchange is enabled.
|
Declare Exchange | check box | When enabled the system tries to declare this exchange on the server. This option is only valid when Createchannel On Connect is enabled. If enabled the Name property must be specified. If any other adapter is also set to declare an exchange and has the same name, the declare options
must be identical or a runtime error will occur on startup. It is suggested that only on adapter set the declare flag and
other adapters simply use the exchange name.
|
Type | drop-down list | The type of exchange to create. This option is only valid when Createchannel On Connect is enabled. See the RabbitMQ documentation for descriptions of the exchange types.
|
Use Defaults | check box | When checked the exchange is created as a non-autodelete, non-durable exchange with no extra arguments. |
Is Durable | check box | When enabled the exchange is set to durable when created. |
Is Auto Delete | check box | When enabled the exchange is set to deleted when not used. |
Exchange Arguments | key value pair | The arguments to use when creating an exchange. |
Property | Type | Description |
---|---|---|
Name | string | The name of the queue to connect to or create if Createchannel On Connect is enabled. If this value is blank and declare queue is enabled a temporary queue is created. The name of the queue can be
received from the status port when action is queue.
|
Declare Queue | check box | When enabled the system tries to declare this queue on the server. This option is only valid when Createchannel On Connect is enabled. If any other adapter is also set to declare a queue and has the same name, the declare options must be identical
or a runtime error occurs on startup. It is suggested that only on adapter set the declare flag and other adapters simply
use the queue name.
|
Is Durable | check box | When enabled the exchange is set to durable when created. |
Is Auto Delete | check box | When enabled the exchange is set to deleted when not used. |
Is Exclusive | check box | When enabled the queue is set to exclusive. |
Queue Arguments | key value pair | The arguments to use when creating an queue. |
Property | Type | Description |
---|---|---|
Routing Keys | key value | The routing keys to use which are used differently depending on the type of exchange that is currently connected. See the RabbitMQ documentation for information about routing keys. |
The RabbitMQ adapter configuration section starts with an <adapter-configurations> element containing one <adapter-configuration name="RabbitMQServers"> element that contains one or more <section name="RabbitMQServer"> elements.
Each <section name="RabbitMQServer"> configuration must contain a <setting name="id" val="RabbitMQ XYZ"/> and <setting name="Host" val="nnnn" /> settings fields. All other setting elements are optional.
This example configuration shows a basic configuration. You can have as many configurations as your application requires, but each must have a unique ID.
<adapter-configurations> <adapter-configuration name="RabbitMQServers"> <section name="RabbitMQServer"> <setting name="id" val="RabbitMQ"/> <setting name="ConnectOnStartup" val="true"/> <setting name="Host" val="127.0.0.1"/> <setting name="Username" val=""/> <setting name="Password" val=""/> <!--<setting name="VirtualHost" val=""/>--> <!--<setting name="Port" val=""/>--> <!--<setting name="AutomaticRecoveryEnabled" val=""/>--> <!--<setting name="NetworkRecoveryInterval" val=""/>--> <!--<setting name="ConnectionTimeout" val=""/>--> <!--<setting name="HandshakeTimeout" val=""/>--> <!--<setting name="ShutdownTimeout" val=""/>--> <!--<setting name="RequestedHeartbeat" val=""/>--> <!--<setting name="TopologyRecoveryEnabled" val=""/>--> </section> </adapter-configuration> </adapter-configurations>
Setting | Type | Required | Description |
---|---|---|---|
id | string | true | The value to display in the drop down list and is used to key to this section of the configuration file. |
ConnectOnStartup | true/false | true | Connect to the RabbitMQ broker on startup. |
Host | string | true | The host address of the RabbitMQ Server. |
Username | string | false | The user name to use when connection to the RabbitMQ Server. |
Password | string | false | The password to use when connection to the RabbitMQ Server. |
VirtualHost | string | false | The virtual host to use when connection to the RabbitMQ Server. |
Port | integer | false | The target port to use when connection to the RabbitMQ Server. |
AutomaticRecoveryEnabled | true/false | false | Enables or disables automatic connection recovery. |
NetworkRecoveryInterval | long | false | Sets connection recovery interval. Default is 5000 milliseconds. |
ConnectionTimeout | integer | false | Set the TCP connection timeout in milliseconds; zero for infinite. |
HandshakeTimeout | integer | false | Set the AMQP0-9-1 protocol handshake timeout, in milliseconds. |
ShutdownTimeout | integer | false | Set the shutdown timeout in milliseconds; zero for infinite; default 10000. This is the amount of time that Consumer implementations have to continue working through deliveries (and other Consumer callbacks) after the connection has closed but before the ConsumerWorkService is torn down. If consumers exceed this timeout then any remaining queued deliveries (and other Consumer callbacks, including the Consumer's handleShutdownSignal() invocation) will be lost. |
RequestedHeartbeat | integer | false | Set the requested heartbeat timeout, in seconds; zero for none. Heartbeat frames will be sent at about 1/2 the timeout interval. |
TopologyRecoveryEnabled | true/false | false | Enables or disables topology recovery. |
-
command, string. The command to send to the adapter.
The values are:
-
connect — Connect to the RabbitMQ server.
-
disconnect — Disconnect from the RabbitMQ server.
-
createchannel — Create a channel with the given exchange and queue information.
-
removechannel — Remove a channel using channel number supplied.
-
-
exchangeName, string. Used with createchannel command, determines the name of the exchange to create or use.
-
exchangeDeclare, boolean. Used with createchannel command to determine whether an exchange should be declared.
-
exchangeDefaults, boolean. Used with createchannel command and exchangeDeclare is true. If true, declares the exchange with RabbitMQ defaults.
-
exchangeType, string, Used with createchannel command and exchangeDeclare is true. Determines the type of exchange to create, valid values are:
-
direct
-
topic
-
fanout
-
headers
-
-
exchangeDurable, boolean. Used with createchannel command and exchangeDeclare is true. If true, declares the exchange as durable.
-
exchangeAutoDelete, boolean. Used with createchannel command and exchangeDeclare is true. If true, declares the exchange as auto-delete.
-
exchangeArgs. list<tuple<string key, string value>>. Used with createchannel command and exchangeDeclare is true. A list of key value pairs to be used as the exchange arguments.
-
queueName, string. Used with createchannel command. Determines the name of the queue to create or use.
-
queueDeclare, boolean. Used with createchannel command to determine whether an queue should be declared.
-
queueDurable, boolean. Used with createchannel command and queueDeclare is true. If true, declares the queue as durable.
-
queueExclusive, boolean. Used with createchannel command and queueDeclare is true. If true declares the queue as exclusive.
-
queueAutoDelete, boolean. Used with createchannel command and queueDeclare is true. If true declares the queue as auto-delete.
-
queueArgs, list<tuple<string key, string value>>. Used with createchannelcommand and queueDeclare is true. A list of key value pairs to be used as the queue arguments.
-
routingKeys, list<string>. Used with createchannel command, a list of routing keys.
-
channel, integer. Used with removechannel command, the channel ID to remove. The channel ID is output as the object field of the status port when action equals channel.
The status port is used to send status information tuples downstream to inform the user of changes.
-
type, string. The type of status information emitted on this port. Status types are:
-
Error — Indicates this message is related to an error that occurred.
-
Warn — Indicates this message is related to a warning that the user should be aware of.
-
Info — Indicates this message is related to extra status information.
-
-
action, string.
-
Connected — Connected to requested broker list.
-
Connecting — Starting to connect
-
Disconnecting — Disconnecting from.
-
Connection — Information about the current connection
-
Update Brokers — Information about updating the brokers
-
Command — A user command
-
Send — Trying to send a message
-
-
object, string. This value may be null. If it is not null, it contains a value relevant to the status message.
-
message, string. This is a formatted human readable message that explains the status message.
-
time, timestamp. The time the status message occurred.
Use the Concurrency tab to specify parallel regions for this instance of this component, or multiplicity options, or both. The Concurrency tab settings are described in Concurrency Options, and dispatch styles are described in Dispatch Styles.
Caution
Concurrency settings are not suitable for every application, and using these settings requires a thorough analysis of your application. For details, see Execution Order and Concurrency, which includes important guidelines for using the concurrency options.
When custom is selected for the message type you will need to provide a class which implements the com.streambase.sb.adapter.rabbitmq.IRabbitMQDeserializer
interface. Here is an example:
package com.streambase.rabbitmq.sample; import com.rabbitmq.client.AMQP.BasicProperties; import com.rabbitmq.client.Envelope; import com.streambase.sb.Schema; import com.streambase.sb.Tuple; import com.streambase.sb.TupleJSONUtil; import com.streambase.sb.adapter.rabbitmq.IRabbitMQDeserializer; public class CustomDeserializer implements IRabbitMQDeserializer { @Override public Tuple deseralize(Schema schema, String consumerTag, Envelope envelope, BasicProperties properties, byte[] body) throws Exception { Tuple tuple = schema.createTuple(); TupleJSONUtil.setTupleFromJSONLoose(tuple, new String(body), ""); return tuple; } }