vendredi 19 octobre 2018

Node-red How to use Pattern with amqp lib and variable

I'm using Node-Red with this library: node-red-contrib-amqp. I'm connecting to a RabbitMQ Server (AMQP) to get some messages from a topic using routing-key.

The node AMQP has a tab where you can define the topology and routing_key for listen some message with a specific routing (feature of AMQP protocol).

This says the help:

In the topology tab you can define the AMQP server exchange and queue topology (exchanges, queues and bindings). You define the topology in the JSON editor.

Topology configuration example:

{
    "exchanges": [
        {"name": "exchange1", "type": "direct", "options": {"durable": false}},
        {"name": "exchange2"}
    ],
    "queues": [
        {"name": "queue1", "options": {"messageTtl": 60000}},
        {"name": "queue2"}
    ],
    "bindings": [
        {"source": "exchange1", "queue": "queue1", "pattern": "debug", "args": {}},
        {"source": "exchange1", "exchange": "exchange2", "pattern": "error"},
        {"source": "exchange2", "queue": "queue2"}
    ]
};

I want to ask if somebody know how to use the pattern, but with variables from Node-red. For example I used this pattern:

{"source": "exchange_1", "exchange": "queue_name_1", "pattern": "*.*.rabbit"},

And i want something like:

{"source": "exchange_1", "exchange": "queue_name_1", "pattern": {inject_node.msg.payload}},

Where inject_node is an Inject Node with string input. The idea for this is change the pattern according to some function on the Flow depending of other results. By this i mean that the pattern may be "#" or ".orange." (examples from RabbitMQ tutorials), but changing according to some function result.

By now i have several AMQP server configured with specifics pattern, but that is not the idea.

I have:

  • Node-RED version: v0.19.4
  • Node.js version: v10.9.0
  • Linux4.4.0-1069-aws x64 LE (Amazon virtual server Ubuntu)
  • RabbitMQ 3.7

Aucun commentaire:

Enregistrer un commentaire