new RabbitMQConsumer()
A stream of messages from a rabbitmq queue.
Methods
cancel(cancelResult)
Stop message consumption from a queue.
The operation is asynchronous. When consumption will be stopped, you can by notified via RabbitMQConsumer#endHandler
Parameters:
| Name | Type | Description |
|---|---|---|
cancelResult |
function | contains information about operation status: success/fail. |
consumerTag() → {string}
Returns:
a consumer tag
- Type
- string
endHandler(endHandler) → {RabbitMQConsumer}
Set an end handler. Once the stream has canceled successfully, the handler will be called.
Parameters:
| Name | Type | Description |
|---|---|---|
endHandler |
function |
Returns:
a reference to this, so the API can be used fluently
- Type
- RabbitMQConsumer
exceptionHandler(exceptionHandler) → {RabbitMQConsumer}
Set an exception handler on the read stream.
Parameters:
| Name | Type | Description |
|---|---|---|
exceptionHandler |
function | the exception handler |
Returns:
a reference to this, so the API can be used fluently
- Type
- RabbitMQConsumer
fetch(amount) → {ReadStream}
Fetch the specified
amount of elements. If the ReadStream has been paused, reading will
recommence with the specified amount of items, otherwise the specified amount will
be added to the current stream demand.
Parameters:
| Name | Type | Description |
|---|---|---|
amount |
number |
Returns:
a reference to this, so the API can be used fluently
- Type
- ReadStream
handler(messageArrived) → {RabbitMQConsumer}
Set a message handler. As message appear in a queue, the handler will be called with the message.
Parameters:
| Name | Type | Description |
|---|---|---|
messageArrived |
function |
Returns:
a reference to this, so the API can be used fluently
- Type
- RabbitMQConsumer
isPaused() → {boolean}
Returns:
is the stream paused?
- Type
- boolean
pause() → {RabbitMQConsumer}
Pause the stream of incoming messages from queue.
The messages will continue to arrive, but they will be stored in a internal queue. If the queue size would exceed the limit provided by , then incoming messages will be discarded.
Returns:
a reference to this, so the API can be used fluently
- Type
- RabbitMQConsumer
pipe() → {Pipe}
Pause this stream and return a to transfer the elements of this stream to a destination .
The stream will be resumed when the pipe will be wired to a
WriteStream.
Returns:
a pipe
- Type
- Pipe
pipeTo(dst, handler)
Pipe this
ReadStream to the WriteStream.
Elements emitted by this stream will be written to the write stream until this stream ends or fails.
Once this stream has ended or failed, the write stream will be ended and the handler will be
called with the result.
Parameters:
| Name | Type | Description |
|---|---|---|
dst |
WriteStream | the destination write stream |
handler |
function |
resume() → {RabbitMQConsumer}
Resume reading from a queue. Flushes internal queue.
Returns:
a reference to this, so the API can be used fluently
- Type
- RabbitMQConsumer