Interface Publisher

See

Connection#createPublisher()

The underlying Channel is lazily created the first time a message is published.

Example

const pub = rabbit.createPublisher({
confirm: true,
exchanges: [{exchange: 'user', type: 'topic'}]
})

await pub.send({exchange: 'user', routingKey: 'user.create'}, userInfo)

await pub.close()

Hierarchy

  • EventEmitter
    • Publisher

Methods

Methods

  • Close the underlying channel

    Returns Promise<void>

  • An undeliverable message was published with the "immediate" flag set, or an unroutable message published with the "mandatory" flag set. The reply code and text provide information about the reason that the message was undeliverable.

    Parameters

    • name: "basic.return"
    • cb: ((msg) => void)

    Returns Publisher

  • See maxAttempts. Emitted each time a failed publish will be retried.

    Parameters

    • name: "retry"
    • cb: ((err, envelope, body) => void)
        • (err, envelope, body): void
        • Parameters

          Returns void

    Returns Publisher

  • Deprecated

    Alias for send

    Parameters

    Returns Promise<void>

  • This method publishes a message to a specific exchange. The message will be routed to queues as defined by the exchange configuration.

    If the body is a string then it will be serialized with contentType='text/plain'. If body is an object then it will be serialized with contentType='application/json'. Buffer objects are unchanged.

    If publisher-confirms are enabled, then this will resolve when the acknowledgement is received. Otherwise this will resolve after writing to the TCP socket, which is usually immediate. Note that if you keep publishing while the connection is blocked (see Connection#on('connection.blocked')) then the TCP socket buffer will eventually fill and this method will no longer resolve immediately.

    Parameters

    Returns Promise<void>

  • Send directly to a queue. Same as send({routingKey: queue}, body)

    Parameters

    • queue: string
    • body: any

    Returns Promise<void>

Generated using TypeDoc