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" <[email protected]>
> To: [email protected]
> Sent: Wednesday, January 11, 2017 2:27:30 PM
> Subject: Re: Message Filters - C++ API
>
> Interested in the C++ API
>
> ________________________________________
> From: Clebert Suconic <[email protected]>
> Sent: Wednesday, January 11, 2017 12:26 PM
> To: [email protected]
> 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. <[email protected]>
> 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: [email protected]
> For additional commands, e-mail: [email protected]
>
>
> ________________________________
>
> 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: [email protected]
> For additional commands, e-mail: [email protected]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]