Hey all,
I'm currently messing around writing some examples for the JavaScript bindings and I figured that it would be a good laugh to do a QMF2 example cause, that would illustrate a few use cases in one go.

My basic hacky starter for ten is nearly there (pasted below) it runs in node.js and uses a WebSocket -> TCP socket proxy to talk to qpidd.

The only bit I'm a bit stuck on is getting the reply-to to work properly.

I based it on the python client/server messenger example, which had a replyTo = '~/replies'; and didn't need the client to explicitly call subscribe in order to receive the response message. However If I just do that I get:

CONNECTION ERROR (amqp:internal-error) not-found: Exchange not found: amqp: (/home/fadams/qpid/qpid-trunk/qpid/cpp/src/qpid/broker/ExchangeRegistry.cpp:144)


So qpidd is clearly not amused by that. I don't *really* understand Messenger replyTo - the "~" seems to be the Messenger name (in the client/server code it seems to be printing <UUID>/replies) but qpidd seems to require a Node name as a replyTo.


As normal for QMF I want a dynamic reply address/queue, which I can get if I do.

var subscription = messenger.subscribe('amqp://0.0.0.0:5673/#');

However I don't know how to find the name of the queue thus created at run time that I can use to populate the replyTo?

my subscribe returns the subscription but my subscription.getAddress(); just returns an empty string - it could be an issue with my implementation but I don't think so as it's just a thin wrapper round pn_messenger_subscribe and pn_subscription_address.

If I use a named queue (e.g. test) and set the replyTo to "test" and messenger.subscribe('amqp://0.0.0.0:5673/test'); then I get the list of QMF queue objects printed out, which is what I want, so the only issue that I have really is not understanding how to do dynamic replyTo addresses from Messenger to qpidd.

The JavaScript code is copied below using the "test" queue.

I'd love to know how to use a proper dynamic replyTo for this.

Cheers,
Frase




proton = require("qpid-proton");

var address = 'amqp://0.0.0.0:5673/qmf.default.direct';
var subject = 'broker';
//var replyTo = '~/replies';
var replyTo = 'test';
var tracker = null;
var running = true;

var message = new proton.Message();
var messenger = new proton.Messenger();

var pumpData = function() {
    while (messenger.incoming()) {
        var t = messenger.get(message);

// data is the body as a proton.Data Object, used in this case because
        // format() returns exactly the same representation as recv.c
        console.log("Content: " + message.data.format());

        messenger.accept(t);
        messenger.stop();
    }

    if (messenger.isStopped()) {
        message.free();
        messenger.free();
    }
};

messenger.on('error', function(error) {console.log(error);});
messenger.on('work', pumpData);
messenger.setOutgoingWindow(1024);
messenger.start();

message.setAddress(address);
message.setSubject(subject);
message.setReplyTo(replyTo);
message.properties = {
    "x-amqp-0-10.app-id": "qmf2",
    "method": "request",
    "qmf.opcode": "_query_request",
};
message.body = {
    "_what": "OBJECT",
    "_schema_id": {
        "_package_name": "org.apache.qpid.broker",
        "_class_name": "queue"
    }
};

tracker = messenger.put(message);

messenger.subscribe('amqp://0.0.0.0:5673/test');

messenger.recv(); // Receive as many messages as messenger can buffer.




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@qpid.apache.org
For additional commands, e-mail: users-h...@qpid.apache.org

Reply via email to