Skip to content

amqpx v1.0.1


amqpx / index / Producer

Interface: Producer<T, WholeMessage>

Defined in: src/producer/producer.ts:28

Represents service sending messages into the RabbitMQ. The generic properties are Message (the content published by the client), and WholeMessage that can contain additional properties that can be added by the producer implementation.

Extends

  • EventEmitter<ProducerEventMap<WholeMessage>>

Type Parameters

Type ParameterDefault type
T-
WholeMessageT

Accessors

channel

Get Signature

get channel(): Channel

Defined in: src/producer/producer.ts:48

The channel used by this producer for publishing.

Returns

Channel

Methods

close()

close(timeout?): Promise<void>

Defined in: src/producer/producer.ts:35

Stops accepting new publishes and waits for all pending publish operations to settle.

Parameters

ParameterTypeDescription
timeout?numberMaximum milliseconds to wait for pending publishes to settle. Throws 'Producer close timed out' if exceeded. Waits 30s when omitted.

Returns

Promise<void>


publish()

publish(message, routingKey?, options?): Promise<WholeMessage>

Defined in: src/producer/producer.ts:43

Publishes a message to RabbitMQ.

Parameters

ParameterTypeDescription
messageTMessage to publish. The producer implementation may augment it with additional properties.
routingKey?RoutingKeyGenerator<T>Either a static routing key string, or a generator function that derives the key from the message.
options?ProducerPublishOptionsPer-publish options such as a retry strategy override.

Returns

Promise<WholeMessage>

Released under the MIT License.