abreits / amqp-ts

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

Fix issues with replying to RPC messages using Promises #44

Closed austin-beer closed 5 years ago

austin-beer commented 5 years ago

Issue 1: If a message is received with the replyTo field set (an RPC message) and the onMessage function that's passed to activateConsumer() or startConsumer() returns a Promise and the Promise isn't an ES6 Promise, a JSON version of the Promise itself may be returned in the reply message instead of the Promise's resolved value. https://stackoverflow.com/questions/27746304/how-do-i-tell-if-an-object-is-a-promise

Issue 2: If a message is received with the replyTo field set (an RPC message) and the onMessage function that's passed to startConsumer() returns a Promise, the Promise's resolved value isn't returned in the reply message. Instead a JSON version of the entire Promise is returned.

Issue 3: Allow the onMessage callback that's passed to activateConsumer() and startConsumer() to return a promise regardless of whether or not the replyTo field is set. startConsumer() can automatically ack the message. If noAck == false and manualAck == false and onMessage returns a promise, wait until the promise is resolved before acknowledging the message.