Receiving events in Node.js?

Is there anything special about receiving events from Nameko in Node.js?

We are having problems with the received message being transformed into a non-JSON object, i.e. {"a": "b"} becomes a=b which is not JSON. The message on the wire is correct, but the Node.js rabbitmq client appears to be de-serializing it incorrectly.

I know there is a Javascript package for making RPC calls via nameko, but I didn't see anything specifically for receiving events.

Thanks

Bob

Hi Bob,

My name is Kyle and I work with Matt Bannett who is a contributor to Nameko.

Might I ask the name of the rabbitmq client you are using? If you are using
"amqplib", keep in mind that it uses the Node's Buffer object which you
will need to convert to a string (which should be JSON) then call
JSON.parse() to get an object back. Might look something like this

function consumeQueue(message) {
  const rawMessageContent = message.content.toString();
  const messageContent = JSON.parse(rawMessageContent);

  // messageContent should be an object
}

Another thing to test would be to make sure Nameko is setting the "content_type"
and "content_encoding" headers on the messages.

Hope that helps :slight_smile:

Regards,

Kyle

ยทยทยท

On Tuesday, October 24, 2017 at 3:50:33 PM UTC+1, HADDLETON, Robert W (Bob) wrote:

Is there anything special about receiving events from Nameko in Node.js?

We are having problems with the received message being transformed into
a non-JSON object, i.e. {"a": "b"} becomes a=b which is not JSON. The
message on the wire is correct, but the Node.js rabbitmq client appears
to be de-serializing it incorrectly.

I know there is a Javascript package for making RPC calls via nameko,
but I didn't see anything specifically for receiving events.

Thanks

Bob