Code Monkey home page Code Monkey logo

vert.x-busmod-amqp'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"
    }
);

vert.x-busmod-amqp's People

Contributors

blalor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vert.x-busmod-amqp's Issues

Do we need to upgrade to vertx 1.3.0.final

Just having an issue with all modules, not just yours here.

I get an exception like this. This one is for mongo persistor, but I had gotten the same for the amqp module.

java.lang.NoSuchMethodError: org.vertx.java.core.eventbus.EventBus.registerHandler(Ljava/lang/String;Lorg/vertx/java/core/Handler;)Ljava/lang/String;
at org.vertx.mods.MongoPersistor.start(MongoPersistor.java:73)

Mark

Should there be a queue created automatically in RabbitMQ

So, I got the mod deployed in my app. And going to the RabbitMQ admin I see that it created a Queue called amq.gen-AvV3-gemGoCxYFjjUetQG2

But when I send a message I type in the routing to a queue that I created. I don't think that other queue should have been generated. Now I wonder if the message will be routed to the queue that I created. Which is being listened to via another app using Spring Integration.

Thanks

Mark

# in mod name has issues with a mod repository downloading

So we have decided to make our own local/company vert.x mod repo and if we do and use the mod name in the URL the # sign causes problems. Locally we have downloaded the mod and can modify the files so that it no longer has a # sign in the name. If you want we can change it to your project and do a pull request.

Also, at the same time could also upgrade to 1.3.1.final

Mark

How to send other message types besides json

I know about content type. The default is JsonObject? then application/text would send that JsonObject as a String??

I am just trying to figure out what approach I should take. At the moment I have a Spring Integration app that is listening into the queue that your mod is send to in my vertx app, and then having a service-activator call a Spring Data Mongo repository's save method. When I look at what was saved in Mongo, I see that it is calling toString on the JsonObject and it shows

{ "_id" : ObjectId("505b76b603641c5d9af56c8f"), "_class" : "[B" }

for the entry in my mongodb collection.

Thanks.

Also is it best to ask specific questions on your mod here, or in the vertx group?

Mark

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.