Open mtorre-iot opened 4 years ago
I think i solved (or at least made a workaround). the full message coming from the amqplib cannot be transmitted as amqpMessage by the node.
in file: src/node/nodejs/amqp.js
Original:
node.initialize = function () { function Consume(msg) { node.send({ topic: node.topic || msg.fields.routingKey, payload: msg.getContent(), amqpMessage: msg }); }
proposed workaround:
node.initialize = function () { function Consume(msg) { var amqpm = new Object(); amqpm.fields = msg.fields; amqpm.payload = msg.getContent(); node.send({ topic: node.topic || msg.fields.routingKey, payload: amqpm.payload, //amqpMessage: msg amqpMessage: amqpm }); }
I think i solved (or at least made a workaround). the full message coming from the amqplib cannot be transmitted as amqpMessage by the node.
in file: src/node/nodejs/amqp.js Original:
node.initialize = function () { function Consume(msg) { node.send({ topic: node.topic || msg.fields.routingKey, payload: msg.getContent(), amqpMessage: msg }); }
proposed workaround:
node.initialize = function () { function Consume(msg) { var amqpm = new Object(); amqpm.fields = msg.fields; amqpm.payload = msg.getContent(); node.send({ topic: node.topic || msg.fields.routingKey, payload: amqpm.payload, //amqpMessage: msg amqpMessage: amqpm }); }
Hi! I've just ran into the same problem, but I'm not doing the same thing:
...create more than one branch after amqp in.
Moreover, I've tried just with the debug node, but it still throws the same error right at the time it consumes the message from queue
Not sure if it's somehow related to the core of the problem - I'm using the RabbitMq server as a docker service:
oc-rabbit:
image: rabbitmq:3-management-alpine
container_name: oc-rabbit
Tried also different node versions for my app (12.14.0, 12.16.2, 12.20) - didn't help.
Anyway, your solutions seems to be working, but I had to parse it a bit, 'cause of the formatting errors (because you posted it as a one-liner):
node.initialize = function () {
if (node.server.prefetch) {
function Consumeack(msg) {
var amqpm = {};
amqpm.fields = msg.fields;
amqpm.payload = msg.getContent();
node.send({
topic: node.topic || msg.fields.routingKey,
payload: msg.getContent(),
amqpfields: msg.fields,
amqpMessage: amqpm
});
...
I'm wondering if those amqpfields
and amqpMessage
properties are really necessary?
I am using amqp node. It works ok (both amqp in and out). The error happens when create more than one branch after amqp in.
When I do that, node-red simply crashes dumping the following text:
Environment: Ubuntu 18.04 Node 12.15.0 npm 6.13.4 node-red 1.0.3 node-red-contrib-amqp 1.0.2