abreits / amqp-ts

AmqpSimple, a RabbitMQ tested Amqp library written in and for Typescript
MIT License
133 stars 37 forks source link

error: Queue.onMessage consumer function returned error: content is not a buffer module=amqp-ts #25

Open pscanlon1 opened 6 years ago

pscanlon1 commented 6 years ago

I am receiving the message, with all the right details, and then I am seeing this error. Any ideas?

razzeee commented 5 years ago

Did you figure this out?

austin-beer commented 5 years ago

I encountered this error when receiving a message that had the replyTo (reply-to) field set. In that case, the message is treated as an RPC call. The amqp-ts library automatically sends the queue.activateConsumer onMessage function's return value to the sender (i.e. to wherever the replyTo field is set to). If your onMessage function doesn't return anything, you will get this error: "Queue.onMessage consumer function returned error: content is not a buffer module=amqp-ts".

https://github.com/abreits/amqp-ts/wiki/Queue-class#activateConsumer

bruegth commented 4 years ago

Seems documentation/example is wrong:

// rpc server that returns a Message
queue.activateConsumer((msg) => {
    var rpcParameters = msg.getContent();
    return new Amqp.Message(rpcParameters.value, {});
});

because return value for reply queue will be stringified: https://github.com/abreits/amqp-ts/blob/0ca8250b61ea3ea2128d1034cc54e88b0df3568d/src/amqp-ts.ts#L798

Or?