On 05/22/2015 12:38 PM, Chris Richardson wrote:
No-go unfortunately:
  Error: Unmatched '{'!, character 28 of my-queue;
{link:{selector:""my-property"='property-value'"}}

I've tried single quotes as well but that doesn't seem to help.

The selector syntax as recognised by the broker requires the property identifier to be enclosed in double quotes, but the value to be enclosed in single quotes.

However the qpid::messaging client's address parsing does not handle any escaping of quotes, so that combination of both double and single quoted parts in a property value isn't possible.

What you can do is construct the address options map manually (rather than relying on the string parsing), which works though it is admittedly clunky.

See attached example.
#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;
}

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to