A working RabbitMQ adapter configuration example

A working RabbitMQ adapter configuration example

book

Article ID: KB0072980

calendar_today

Updated On:

Products Versions
TIBCO Streaming 10.6 and later

Description

This article provides a working RabbitMQ adapter configuration example. To test this configuration, you may run a local RabbitMQ message broker as described below.
 

Issue/Introduction

Provides a working RabbitMQ adapter configuration example that connects to a locally-run RabbitMQ broker.

Resolution

First, start a local RabbitMQ broker. This is easily accomplished using Docker. For example:
$ docker pull rabbitmq:3-management
$ docker run -d --hostname localhost --name some-rabbit -p 5672:5672 -p 8080:15672 rabbitmq:3-management
This exposes ports 5672 (for the broker) and 8080 (for the management console) to your host machine. You should now be able to login to the RabbitMQ management console. In your web browser, confirm that you can successfully login to http://localhost:8080 (supplying the username 'guest' and password 'guest').

Next, load the RabbitMQ sample in StreamBase Studio by going to File > Import Samples and Community Content > (search) 'rabbit'. This will load the 'sample_adapter_embedded_rabbitmq' project into your workspace. Under src/main/configurations, edit the adapter configuration ('RabbitMQ.conf') as follows:
name = "RabbitMQ.conf"
type = "com.tibco.ep.streambase.configuration.adapter"
version = "1.0.0"
configuration = {
  AdapterGroup = {
    adapters = {
      RabbitMQServers = {
        sections = [ 
          {
            name = "RabbitMQServer"
            settings = {
              ConnectOnStartup = "true"
              Host = "localhost"
              Password = "guest"
              Username = "guest"
              id = "RabbitMQ"
              Port = "5672"
            }
          }
        ]
      }
    }
  }
}
Finally, confirm the adapter configuration by running the HelloWorld.sbapp fragment under src/main/eventflow/.  This should successfully connect to the RabbitMQ broker and create the 'hello' queue.  You can expect to see the following output in the Studio Console view:
(fragment deploy): 2021-10-13 15:21:46.984000-0400 [26512:runtime [tid=26656]] INFO  Consumer: Action: 
connected Object: amqp://guest@0:0:0:0:0:0:0:1:5672/ Message: Connected successfully
(fragment deploy): 2021-10-13 15:21:47.002000-0400 [26512:runtime [tid=26656]] INFO  Consumer: Action: 
queue Object: hello Message: Queue connected
(fragment deploy): 2021-10-13 15:21:47.011000-0400 [26512:runtime [tid=26656]] INFO  Consumer: Action: 
channel Object: 1 Message: Channel created successfully
(fragment deploy): 2021-10-13 15:21:47.011000-0400 [26512:runtime [tid=26656]] INFO  Producer: Action: 
connected Object: amqp://guest@0:0:0:0:0:0:0:1:5672/ Message: Connected successfully
(fragment deploy): 2021-10-13 15:21:47.015000-0400 [26512:runtime [tid=26656]] INFO  Producer: Action: 
queue Object: hello Message: Queue connected
(fragment deploy): 2021-10-13 15:21:47.015000-0400 [26512:runtime [tid=26656]] INFO  Producer: Action: 
channel Object: 2 Message: Channel created successfully