This module allows communication between Vert.x and the Apache ActiveMQ message broker. The module acts as a bridge between the internal event bus of Vert.x and ActiveMQ. It uses the ActiveMQ client library and exchanges “native” JMS messages.
Note
|
The module is in an early state. But the main functionality - sending and receiving message - should work. |
To use the module you have to deploy it in your Vert.x application.
container.deployModule("de.it-hempel.vertx~module-activemq-io~0.1.0");
The module can be configured with the following entries in the configuration Json.
Parameter | Type | Description |
---|---|---|
|
|
The IP address / network name fo the ActiveMQ broker. (default: |
|
|
Port number of the ActiveMQ broker to connect to. (default: |
|
|
The address of the ActiveMQ Vert.x module on the internal event bus. (default: |
JsonObject config = new JsonObject();
config.putString("host", "example.broker");
config.putInt("port", 61616);
container.deployModule("de.it-hempel.vertx~module-activemq-io~0.1.0", config);
You can send and receive message from the message broker.
To send a message you send a JsonObject
with the following structure to the vertx.mod-activemq-io
module:
Field | Type | Description |
---|---|---|
|
|
The command of the Vert.x module to be executed. With |
|
|
Address of the ActiveMQ queue to which the JMS message should be send. |
|
|
The content of the JMS message to be send. When the field is of type |
Example: Send a TextMessage
to the JMS queue TOQUEUE
.
EventBus eb = vertx.eventBus();
String busAddress = "vertx.mod-activemq-io";
JsonObject message = new JsonObject();
message.putString("command", "send");
message.putString("destination", "TOQUEUE");
message.putString("body", "Hello World!");
eb.send(busAddress, message);
You can subscribe your verticle to receive messages from the MessageBroker. To subscribe you have to send a JsonObject
to the vertx.mod-activemq-io
module.
Field | Type | Description |
---|---|---|
|
|
The command of the Vert.x module to be executed. With |
|
|
Address of the ActiveMQ queue from which JMS message should be received. |
|
|
The address on the Vert.x event bus, to which the received JMS message should be delievered. |
Example: Subscribe to receive message from the JSM queue FROMQUEUE
.
EventBus eb = vertx.eventBus();
String busAddress = "vertx.mod-activemq-io";
String myAddress = "my-vertx-address";
JsonObject message = new JsonObject();
message.putString("command", "subscribe");
message.putString("destination", "FROMQUEUE");
message.putString("subscriber-address", myAddress);
eb.send(busAddress, message);