You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by "Flores, Paul A." <PA...@SAIC.COM> on 2017/01/11 19:27:30 UTC
Re: Message Filters - C++ API
Interested in the C++ API
________________________________________
From: Clebert Suconic <cs...@redhat.com>
Sent: Wednesday, January 11, 2017 12:26 PM
To: users@qpid.apache.org
Subject: Re: Message Filters
Message filtering as in the JMS api?
This is artemis, but the JMS API would work the same on qpid broker:
https://github.com/apache/activemq-artemis/tree/master/examples/features/standard/queue-selector
Sorry if I misunderstood your question.
On Wed, Jan 11, 2017 at 2:23 PM, Flores, Paul A. <PA...@saic.com> wrote:
> Can anyone point me to an example of message filtering or perhaps a tutorial ?
>
>
> Thank you!
>
>
> Paul
>
>
> ________________________________
>
> This communication (including any attachments) may contain information that is proprietary, confidential or exempt from disclosure. If you are not the intended recipient, please note that further dissemination, distribution, use or copying of this communication is strictly prohibited. Anyone who received this message in error should notify the sender immediately by telephone or by return email and delete it from his or her computer.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
________________________________
This communication (including any attachments) may contain information that is proprietary, confidential or exempt from disclosure. If you are not the intended recipient, please note that further dissemination, distribution, use or copying of this communication is strictly prohibited. Anyone who received this message in error should notify the sender immediately by telephone or by return email and delete it from his or her computer.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: Message Filters - C++ API
Posted by Gordon Sim <gs...@redhat.com>.
On 12/01/17 07:02, Fraser Adams wrote:
> I thought that with qpid::messaging you could use a (perhaps more
> intuitive) shorthand in the link stanza like:
>
> {link: {selector: \"messaging_service='amqp-delivery' and
> item_owner='fadams'\"}}
>
> where messaging_service and item_owner are message properties and the
> example selector is doing a boolean and
>
> I think that under the hood it gets mapped to an
> apache.org:selector-filter:string filter in the link attachment protocol
> and the above is just syntactic sugar at the API level, but the above
> seems neater to me than having to spell out the full filter syntax
> 'cause Lord knows Address strings can get complicated enough and be
> pretty hard to to debug.
That is true, and using the simpler syntax makes sense.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: Message Filters - C++ API
Posted by Fraser Adams <fr...@blueyonder.co.uk>.
I thought that with qpid::messaging you could use a (perhaps more
intuitive) shorthand in the link stanza like:
{link: {selector: \"messaging_service='amqp-delivery' and
item_owner='fadams'\"}}
where messaging_service and item_owner are message properties and the
example selector is doing a boolean and
I think that under the hood it gets mapped to an
apache.org:selector-filter:string filter in the link attachment protocol
and the above is just syntactic sugar at the API level, but the above
seems neater to me than having to spell out the full filter syntax
'cause Lord knows Address strings can get complicated enough and be
pretty hard to to debug.
ISTR too that property names need to use underscores for message
selectors to work so properties like "messaging-service" which would
work as property names in Qpid won't match with message selectors.
I *think* that was something to do with Java JMS spec. saying something
about JMS property names having to be valid Java identifiers (that is to
say something you could use as a variable name) however I don't thing
that the AMQP spec said anything about constraining message property
names in this way and moreover the AMQP 0.10 JMS API actually happily
allowed property names separated by hyphens, but message selectors as I
recall were more picky, it's possible that may have changed, but I'm not
aware that it has.
IMHO if the AMQP spec doesn't disallow hyphen separated property names
then Qpid message selectors should accept it (after all JMS is just one
API to AMQP) though noting the potential for interoperability issues
given the potential JMS property name constraint.
Frase
On 11/01/17 20:01, Gordon Sim wrote:
> On 11/01/17 19:27, Flores, Paul A. wrote:
>> Interested in the C++ API
>
> With qpid::messaging you use an address of the form:
>
> my-queue; {link:{filter:{name:jms-selector,
> descriptor:'apache.org:selector-filter:string', value:'myProperty=7'}}}
>
> The value of the 'value' element in the filter can be any valid JMS
> selector.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: Message Filters - C++ API
Posted by Gordon Sim <gs...@redhat.com>.
On 27/05/2020 7:20 pm, mohank wrote:
>>> With qpid::messaging you use an address of the form:
>
>>> my-queue; {link:{filter:{name:jms-selector,
>>> descriptor:'apache.org:selector-filter:string', value:'myProperty=7'}}}
>
> This kind of address syntax always throws exception
> EX : for above address
> Receiver receiver = session.createReceiver("'my-queue'; {link:
> {filter: {name:jms - selector,descriptor :
> 'apache.org:selector-filter:string', value : 'myProperty=7'}}}");
>
> got exception : Unmatched '{'!, character 38 of 'my-queue'; {link: {filter:
> {name:jms - selector,descriptor : 'apache.org:selector-filter:string', value
> : 'myProperty=7'}}}
>
> My environment setup is ,
> OS: Windows
> Client : QPID C++ 1.36 AMQP 1.0
> Broker : Rabbitmq 3.8
>
> If this syntax is not supported in RabbitMQ broker (then which broker
> supports complete AMQP 1.0 feature)or not supported in AMQP 1.0
The syntax doesn't get seen by RabbitMQ, it is interpreted by the client
(which then sends the filter in the AMQP 1.0 encoding to the broker).
From an initial glance I suspect the error may be due to "jms -
selector" not being in single quotes in spite of having spaces?
However RabbitMQ does not support filters anyway
(https://github.com/rabbitmq/rabbitmq-amqp1.0#limitations-and-unsupported-features).
In terms of brokers with support for AMQP 1.0, there are several. The
Qpid java broker supports all versions of AMQP and has very good AMQP
1.0 support including filters. The Qpid c++ broker supports AMQP 0-10
and AMQP 1.0 and also supports selectors. Both ActiveMQ 5 and ActiveMQ
Artemis also support AMQP 1.0.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: Message Filters - C++ API
Posted by mohank <mo...@eventtracker.com.INVALID>.
>>With qpid::messaging you use an address of the form:
>> my-queue; {link:{filter:{name:jms-selector,
>>descriptor:'apache.org:selector-filter:string', value:'myProperty=7'}}}
This kind of address syntax always throws exception
EX : for above address
Receiver receiver = session.createReceiver("'my-queue'; {link:
{filter: {name:jms - selector,descriptor :
'apache.org:selector-filter:string', value : 'myProperty=7'}}}");
got exception : Unmatched '{'!, character 38 of 'my-queue'; {link: {filter:
{name:jms - selector,descriptor : 'apache.org:selector-filter:string', value
: 'myProperty=7'}}}
My environment setup is ,
OS: Windows
Client : QPID C++ 1.36 AMQP 1.0
Broker : Rabbitmq 3.8
If this syntax is not supported in RabbitMQ broker (then which broker
supports complete AMQP 1.0 feature)or not supported in AMQP 1.0
Thanks,
Mohan
--
Sent from: http://qpid.2158936.n2.nabble.com/Apache-Qpid-users-f2158936.html
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: Message Filters - C++ API
Posted by Gordon Sim <gs...@redhat.com>.
On 11/01/17 19:27, Flores, Paul A. wrote:
> Interested in the C++ API
With qpid::messaging you use an address of the form:
my-queue; {link:{filter:{name:jms-selector,
descriptor:'apache.org:selector-filter:string', value:'myProperty=7'}}}
The value of the 'value' element in the filter can be any valid JMS
selector.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org
Re: Message Filters - C++ API
Posted by Chuck Rolke <cr...@redhat.com>.
Here's an example that Gordon sends around every year or so.
It creates a selector map on a receiver link to filter messages.
This example shows proper escapement to include hyphens in the filter.
#include <qpid/messaging/Address.h>
#include <qpid/messaging/Connection.h>
#include <qpid/messaging/Message.h>
#include <qpid/messaging/Receiver.h>
#include <qpid/messaging/Session.h>
#include <qpid/types/Variant.h>
#include <iostream>
using namespace qpid::messaging;
using qpid::types::Variant;
int main(int argc, char** argv) {
Connection connection;
try
{
std::string url = argc > 1 ? argv[1] : "localhost:5672";
std::string node = argc > 2 ? argv[2] : "queue";
std::string connectionOptions = argc > 3 ? argv[3] : "{protocol:amqp0-10}";
connection = Connection(url, connectionOptions);
connection.open();
Session session = connection.createSession();
Variant::Map selector;
selector["selector"] = "\"my-property\"='my-value'";
Variant::Map options;
options["link"] = selector;
Address address(node, "", options);
Receiver receiver = session.createReceiver(address);
Message message;
while (receiver.fetch(message)) {
std::cout << "received: " << message.getContentObject() << std::endl;
}
session.close();
connection.close();
return 0;
} catch (const std::exception& error) {
std::cout << "Error: " << error.what() << std::endl;
connection.close();
}
return 1;
}
----- Original Message -----
> From: "Paul A. Flores" <PA...@SAIC.COM>
> To: users@qpid.apache.org
> Sent: Wednesday, January 11, 2017 2:27:30 PM
> Subject: Re: Message Filters - C++ API
>
> Interested in the C++ API
>
> ________________________________________
> From: Clebert Suconic <cs...@redhat.com>
> Sent: Wednesday, January 11, 2017 12:26 PM
> To: users@qpid.apache.org
> Subject: Re: Message Filters
>
> Message filtering as in the JMS api?
>
>
> This is artemis, but the JMS API would work the same on qpid broker:
>
> https://github.com/apache/activemq-artemis/tree/master/examples/features/standard/queue-selector
>
>
>
> Sorry if I misunderstood your question.
>
> On Wed, Jan 11, 2017 at 2:23 PM, Flores, Paul A. <PA...@saic.com>
> wrote:
> > Can anyone point me to an example of message filtering or perhaps a
> > tutorial ?
> >
> >
> > Thank you!
> >
> >
> > Paul
> >
> >
> > ________________________________
> >
> > This communication (including any attachments) may contain information that
> > is proprietary, confidential or exempt from disclosure. If you are not the
> > intended recipient, please note that further dissemination, distribution,
> > use or copying of this communication is strictly prohibited. Anyone who
> > received this message in error should notify the sender immediately by
> > telephone or by return email and delete it from his or her computer.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
>
>
> ________________________________
>
> This communication (including any attachments) may contain information that
> is proprietary, confidential or exempt from disclosure. If you are not the
> intended recipient, please note that further dissemination, distribution,
> use or copying of this communication is strictly prohibited. Anyone who
> received this message in error should notify the sender immediately by
> telephone or by return email and delete it from his or her computer.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org