Code Monkey home page Code Monkey logo

voom-vertx's Introduction

AMQP bridge busmod for Vert.x

This busmod is a bridge between Vert.x and an AMQP message broker (such as RabbitMQ). This code was originally developed on a branch of the main Vert.x project, but I extended it, added new features, and some tests.

Usage

The examples below are mostly conceptual; if you want to see working examples, look at src/test/javascript/amqp_test_client.js. They can be invoked as part of the integration test suite:

mvn -P integration-test -Damqp.uri=amqp://your-amqp-server-here verify

load the verticle

Programmatically, if you like:

vertx.deployWorkerVerticle(
    "org.vertx.java.busmods.amqp.AmqpBridge",
    {
        "uri": "amqp://localhost",
        "address": "amqp_bridge",
        "defaultContentType": "application/json"
    },
    1,
    function() {
        // subscribe, if necessary, or send initial message
    }
);

subscribe to a queue or topic

var handlerAddr = "my_addr";

eb.registerHandler(handlerAddr, function(msg) {
    // handle message!
});

eb.send(
    "amqp_bridge.create-consumer",
    {
        "exchange" : "raw_xbee_frames",
        "routingKey" : "#",
        "forward" : handlerAddr
    },
    function(reply) {
        // check reply.status == "ok"
    }
);

send a message to a queue or topic

eb.send(
    "amqp_bridge.send",
    {
        "routingKey" : "target_queue"
        "properties" : {
            "contentType" : "text/plain"
        },
        "body" : "my message"
    },
    function(reply) {
        // check reply.status == "ok"
    }
);

invoke an RPC method

Based on this RabbitMQ article.

eb.send(
    "amqp_bridge.invoke_rpc",
    {
        "routingKey" : "target_queue",
        "body" : {
            "my_name" : "Bob"
        }
    },
    function(reply) {
        // check reply.body == "Hi, Bob!"
    }
);

invoke an RPC method with multiple responses

var handlerAddr = "my_handler";

eb.registerHandler(handlerAddr, function(msg) {
    // do something with msg
});

eb.send(
    "amqp_bridge.invoke_rpc",
    {
        "routingKey" : "target_queue",
        "replyTo" : handlerAddr,
        "body" : {
            "times_to_reply" : 3
        }
    },
    function(reply) {
        // check reply.status == "ok"
    }
);

voom-vertx's People

Contributors

blalor avatar jaklaassen avatar ross-pfahler avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.