You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Christian Fromme <ka...@strace.org> on 2013/05/17 09:37:29 UTC

Add route via C++ API?

Greetings,

in Qpid, broker federation is usually done via the `qpid-route`
command line utility. I wonder if there is a way to add and control
routes via the C++ API? If possible, an example would help!

TIA,
Christian

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


Re: Add route via C++ API?

Posted by Christian Fromme <cf...@strace.org>.
Hi Gordon,

thanks for your quick reply!

On Fri, May 17, 2013 at 10:52 AM, Gordon Sim <gs...@redhat.com> wrote:

> The recommended approach for federation is to use the 'create' method[1] to
> create objects of type 'link' (i.e. connections between two brokers) and
> associated 'bridges' (i.e. subscriptions over those connections). These can
> be removed using the 'delete' method.
>
> Attached is a simple example showing what this would look like using the C++
> qpid::messaging API. It creates a link between two brokers and then
> established a flow of messages between the amq.fanout exchanges.
>
> Feel free to ask any questions as regrettably this is not terribly well
> documented.

At first glance, the examples you've attached look exactly like what I
was looking for. I will play around with it a bit and possibly will be
back with more questions later.

Thanks again,
Christian

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


Re: Add route via C++ API?

Posted by Christian Fromme <cf...@strace.org>.
On Fri, May 17, 2013 at 2:21 PM, Christian Fromme <cf...@strace.org> wrote:

> Using the (newer) qpid::messaging API, I can't seem to find where to
> add the routing-key for a bridge. I guess its somewhere through the
> Variant::Map args? Are possible key/value pairs the broker understands
> documented somewhere?

Argh, I hate to answer my own questions 5 minutes after I wrote them,
but I think I've found the way to add the key. Its done in the
"oldexample.cpp" like this: params["key"]=key;

Christian

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


Re: Add route via C++ API?

Posted by Christian Fromme <cf...@strace.org>.
On Fri, May 17, 2013 at 2:37 PM, Gordon Sim <gs...@redhat.com> wrote:

> Its in the properties map within the args, the name of the property is
> 'key'.
>
> The full ist of properties for a bridge are "src", "dest", "key", "tag",
> "excludes", "srcIsQueue", "srcIsLocal", "dynamic", "sync" and
> "credit"

Thanks once more,
Christian

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


Re: Add route via C++ API?

Posted by Christian Fromme <cf...@strace.org>.
On Tue, May 21, 2013 at 1:43 PM, Gordon Sim <gs...@redhat.com> wrote:

>> Is there an exhaustive list of exceptions/error codes and what they
>> mean? I've looked in the QMF Map Message Protocol[0], but didn't find
>> it there.
>>
>> Also, a list of requests (types?) would be very handy. (Requesting a
>> list of existing bridges, for instance.)
>
> Sorry, unfortunately there is really not much in the way of documentation on
> QMF beyond the description you list below.
> Attached is a little example that hopefully helps illustrate what I mean.

Thanks very much again, Gordon!

Christian

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


Re: Add route via C++ API?

Posted by Gordon Sim <gs...@redhat.com>.
On 05/21/2013 10:35 AM, Christian Fromme wrote:
> Is there an exhaustive list of exceptions/error codes and what they
> mean? I've looked in the QMF Map Message Protocol[0], but didn't find
> it there.
>
> Also, a list of requests (types?) would be very handy. (Requesting a
> list of existing bridges, for instance.)

Sorry, unfortunately there is really not much in the way of 
documentation on QMF beyond the description you list below.

To get a list of objects of a particular class you set the qmf op code 
to '_query_request' (as opposed to _method_request' for method 
invocations). You then set the body of the map message to contain a 
query, which in this case is a nested map keyed on '_schema_id' that 
itself has the '_class_name' set to the class of interest (bridge, link, 
queue, exchange etc).

Attached is a little example that hopefully helps illustrate what I mean.

>
> [0]  https://cwiki.apache.org/qpid/qmf-map-message-protocol.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
>


Re: Add route via C++ API?

Posted by Christian Fromme <cf...@strace.org>.
On Fri, May 17, 2013 at 4:29 PM, Gordon Sim <gs...@redhat.com> wrote:

>> When adding links or bridges, is it possible to check beforehand
>> whether or not they already exist?
>> Currently I get: "{error_code:7, error_text:object already exists:
>> mylink-1}"
>
>
> You can get send a request for a list of all links or bridges (I can cook up
> an example of that if needed). Of course its possible that one gets added
> after you've requested the list and before you create a new one. So in some
> ways I think just handling the 'already exists' case may be something you
> want to do anyway. Unless you go with using UUIDs for names or something.

Is there an exhaustive list of exceptions/error codes and what they
mean? I've looked in the QMF Map Message Protocol[0], but didn't find
it there.

Also, a list of requests (types?) would be very handy. (Requesting a
list of existing bridges, for instance.)

TIA,
Christian

[0]  https://cwiki.apache.org/qpid/qmf-map-message-protocol.html

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


Re: Add route via C++ API?

Posted by Gordon Sim <gs...@redhat.com>.
On 05/17/2013 02:40 PM, Christian Fromme wrote:
> On Fri, May 17, 2013 at 2:37 PM, Gordon Sim <gs...@redhat.com> wrote:
>
>> The full ist of properties for a bridge are "src", "dest", "key", "tag",
>> "excludes", "srcIsQueue", "srcIsLocal", "dynamic", "sync" and
>> "credit"
>
> When adding links or bridges, is it possible to check beforehand
> whether or not they already exist?
> Currently I get: "{error_code:7, error_text:object already exists: mylink-1}"

You can get send a request for a list of all links or bridges (I can 
cook up an example of that if needed). Of course its possible that one 
gets added after you've requested the list and before you create a new 
one. So in some ways I think just handling the 'already exists' case may 
be something you want to do anyway. Unless you go with using UUIDs for 
names or something.


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


Re: Add route via C++ API?

Posted by Christian Fromme <ka...@strace.org>.
On Fri, May 17, 2013 at 2:37 PM, Gordon Sim <gs...@redhat.com> wrote:

> The full ist of properties for a bridge are "src", "dest", "key", "tag",
> "excludes", "srcIsQueue", "srcIsLocal", "dynamic", "sync" and
> "credit"

When adding links or bridges, is it possible to check beforehand
whether or not they already exist?
Currently I get: "{error_code:7, error_text:object already exists: mylink-1}"

TIA,
Christian

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


Re: Add route via C++ API?

Posted by Gordon Sim <gs...@redhat.com>.
On 05/17/2013 01:21 PM, Christian Fromme wrote:
> Hi,
>
> On Fri, May 17, 2013 at 10:52 AM, Gordon Sim <gs...@redhat.com> wrote:
>
>> Attached is a simple example showing what this would look like using the C++
>> qpid::messaging API. It creates a link between two brokers and then
>> established a flow of messages between the amq.fanout exchanges.
>>
>> Feel free to ask any questions as regrettably this is not terribly well
>> documented.
>
> Using the (newer) qpid::messaging API, I can't seem to find where to
> add the routing-key for a bridge. I guess its somewhere through the
> Variant::Map args? Are possible key/value pairs the broker understands
> documented somewhere?

Its in the properties map within the args, the name of the property is 
'key'.

The full ist of properties for a bridge are "src", "dest", "key", "tag", 
"excludes", "srcIsQueue", "srcIsLocal", "dynamic", "sync" and
"credit"



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


Re: Add route via C++ API?

Posted by Christian Fromme <cf...@strace.org>.
Hi,

On Fri, May 17, 2013 at 10:52 AM, Gordon Sim <gs...@redhat.com> wrote:

> Attached is a simple example showing what this would look like using the C++
> qpid::messaging API. It creates a link between two brokers and then
> established a flow of messages between the amq.fanout exchanges.
>
> Feel free to ask any questions as regrettably this is not terribly well
> documented.

Using the (newer) qpid::messaging API, I can't seem to find where to
add the routing-key for a bridge. I guess its somewhere through the
Variant::Map args? Are possible key/value pairs the broker understands
documented somewhere?

TIA again,
Christian

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


Re: Add route via C++ API?

Posted by Gordon Sim <gs...@redhat.com>.
On 05/17/2013 08:37 AM, Christian Fromme wrote:
> in Qpid, broker federation is usually done via the `qpid-route`
> command line utility. I wonder if there is a way to add and control
> routes via the C++ API? If possible, an example would help!

All the management is done by sending specially formatted messages (the 
QMF protocol). This can be done with any client library (though in raw 
form it is a little verbose).

The recommended approach for federation is to use the 'create' method[1] 
to create objects of type 'link' (i.e. connections between two brokers) 
and associated 'bridges' (i.e. subscriptions over those connections). 
These can be removed using the 'delete' method.

Attached is a simple example showing what this would look like using the 
C++ qpid::messaging API. It creates a link between two brokers and then 
established a flow of messages between the amq.fanout exchanges.

Feel free to ask any questions as regrettably this is not terribly well 
documented.

--Gordon.

[1] The qpid-route utility predates the avialbility of the generic 
create method and uses Broker::connect() to create a Link object then 
Link::bridge() to create the bridge. I've attached an old example that 
does that as well, but I would recommend the create/delete approach as 
it is simpler.