Search code examples
amqpqpidrhea

can't open a receiver bound to application header x-match expression


I'm using rhea (https://github.com/amqp/rhea), a node.js library to develop AMQP 1.0 clients.

I'm trying to adapt https://github.com/amqp/rhea/tree/master/examples/selector example using an x-match expression instead of a JMS expression.

The purpose is to implement an header routing mechanism based on a AMQP 1.0 compliant broker (ActiveMQ, Qpid, ...).

I tried this code in the appropriate section in recv.js:

connection.open_receiver({
    source: {
        address: 'amq.match',
        filter: {
            'x-match': 'all',
            value: {
                'nat': 'it',
                'prod': 'a22'
            }
        }
    }
})

Received a connection error "Expected value type is 'Filter' but got 'String' amqp:decode-error" from Qpid Java broker (rel. 7.1.0).


Solution

  • According to this answer received on rhea github repo:

    https://github.com/amqp/rhea/issues/200#issuecomment-469220880

    The filter needs to be a described value. Try something like this:

    connection.open_receiver({
        source: {
            address: 'amq.match',
            filter: {
                'foo': amqp_types.wrap_described({
                    'nat': 'it',
                    'prod': 'a22',
                    'x-match': 'all'
                }, 0x468C00000002)
            }
        }
    });
    

    where:

    var amqp_types = require('rhea').types;
    

    That works only with Qpid cpp, it's not working with ActiveMQ and Qpid java.