Skip to content
This repository has been archived by the owner on Aug 28, 2019. It is now read-only.

pmlopes/mod-stomp-io

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stomp busmod for Vert.x

Build Status

This module allows communcation between Message brokers such as ActiveMQ, RabbitMQ Apache Apollo.

Support the development of this module

Click here to lend your support to: Support com.jetdrone Vert.x modules and make a donation at www.pledgie.com !

Quick and Dirty Guide:

First deploy the module:

eb = vertx.eventBus()
container.deployModule('com.jetdrone~mod-stomp-io~1.1.2', [address: 'my-address'], 1)

The config json accepts the following optional parameters:

  • "host" default: "localhost"
  • "port" default 61613
  • "login" default null
  • "passcode" default: null

Second send/receive messages:

eb.send(address, [command: "send", destination: "/queue/FOO.BAR", body: "Hello, queue FOO.BAR"]) { reply ->
    if (reply.body.status == 'OK') {
        // ...
    }
}

// sync messages (wait for ACK)
eb.send(address, [command: "send", destination: "/queue/FOO.BAR", body: "Hello, queue FOO.BAR", sync: true]) { reply ->
    if (reply.body.status == 'OK') {
        // ...
    }
}

Work pub/sub mode:

    // register a handler for the incoming message
    eb.registerHandler("${address}/queue/unsub", new Handler<Message<JsonObject>>() {
        @Override
        void handle(Message<JsonObject> received) {
            def value = received.body.getField('value')
            assertNotNull(value)
            testComplete()
        }
    });

    eb.send(address, [command: "send", destination: "/queue/unsub", body: "Hello, queue unsub"]) { reply0 ->
        stomp([command: "subscribe", destination: "/queue/unsub"]) { reply1 ->
            def id = reply1.body.getString("id")

            // sleep 1 second to avoid receiving any old intransit messages
            vertx.setTimer(1000, new Handler<Long>() {
                @Override
                public void handle(Long event) {
                    stomp([command: "unsubscribe", id: id]) { reply2 ->
                        testComplete()
                    }
                }
            });
        }
    }

About

Vert.x STOMP Protocol Module

Resources

Stars

Watchers

Forks

Packages

No packages published