amqpx / index / ProducerImplementation
Class: ProducerImplementation<T>
Defined in: src/producer/producer-implementation.ts:17
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<T>>
Type Parameters
| Type Parameter |
|---|
T |
Implements
Producer<T>
Constructors
Constructor
new ProducerImplementation<
T>(channel,exchange,options?):ProducerImplementation<T>
Defined in: src/producer/producer-implementation.ts:24
Parameters
| Parameter | Type |
|---|---|
channel | Channel |
exchange | Exchange |
options | ProducerOptions<T> |
Returns
ProducerImplementation<T>
Overrides
EventEmitter<ProducerEventMap<T>>.constructor
Properties
| Property | Modifier | Type | Defined in |
|---|---|---|---|
channel | readonly | Channel | src/producer/producer-implementation.ts:25 |
Methods
close()
close(
timeout?):Promise<void>
Defined in: src/producer/producer-implementation.ts:49
Stops accepting new publishes and waits for all pending publish operations to settle.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
timeout | number | 30_000 | Maximum milliseconds to wait for pending publishes to settle. Throws 'Producer close timed out' if exceeded. Waits 30s when omitted. |
Returns
Promise<void>
Implementation of
publish()
publish(
message,routingKey?,options?):Promise<T>
Defined in: src/producer/producer-implementation.ts:83
Publishes a message to RabbitMQ.
Parameters
| Parameter | Type | Description |
|---|---|---|
message | T | Message 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? | ProducerPublishOptions | Per-publish options such as a retry strategy override. |
Returns
Promise<T>