Extends: MessageQueue
Implements: IReferenceable, IUnreferenceable, IConfigurable, IOpenable, ICleanable
Description
The NatsAbstractMessageQueue class allows you to define abstract NATS message queues with the ability to connect to NATS servers.
Constructors
Creates a new instance of the component.
public
constructor(name?: string, capabilities?: MessagingCapabilities)
- name: string - (optional) queue name.
- capabilities: MessagingCapabilities - supported capabilities
Fields
Instance methods
abandon
Returns a message into the queue and makes it available for all subscribers to receive it again. This method is usually used to return a message which could not be processed at the moment to repeat the attempt. Messages that cause unrecoverable errors shall be removed permanently or/and send to dead letter queue.
- Important: This method is not supported by NATS.
public
abandon(message: MessageEnvelope): Promise<void>
- message: MessageEnvelope - message to return.
clear
Clears a component’s state.
public
clear(correlationId: string): Promise<void>
- correlationId: string - (optional) transaction id used to trace execution through the call chain.
close
Closes a component and frees the used resources.
public
close(correlationId: string): Promise<void>
- correlationId: string - (optional) transaction id used to trace execution through the call chain.
complete
Permanently removes a message from the queue. This method is usually used to remove the message after successful processing.
- Important: This method is not supported by NATS.
public
complete(message: MessageEnvelope): Promise<void>
- message: MessageEnvelope - message to remove.
configure
Configures a component by passing its configuration parameters.
public
configure(config: ConfigParams): void
- config:: ConfigParams - configuration parameters to be set.
fromMessage
Returns the headers and data from a message.
protected
fromMessage(message: MessageEnvelope): any
- message: MessageEnvelope - message
- returns: any - message headers and data.
getSubject
Gets the subject.
protected
getSubject(): string
- returns: string - subject
isOpen
Checks if the component is open.
public
isOpen(): boolean
- returns: boolean - true if the component is open and false otherwise.
moveToDeadLetter
Permanently removes a message from the queue and sends it to the dead letter queue.
- Important: This method is not supported by NATS.
public
moveToDeadLetter(message: MessageEnvelope): Promise<void>
- message: MessageEnvelope - message to be removed.
open
Opens the component.
public
open(correlationId: string): Promise<void>
- correlationId: string - (optional) transaction id used to trace execution through the call chain.
readMessageCount
Reads the current number of messages in the queue to be delivered.
public
readMessageCount(): Promise<number>
- *returns: Promise<number> - number of messages in the queue.
renewLock
Renews a lock on a message that makes it invisible from other receivers in the queue. This method is usually used to extend the message processing time.
- Important: This method is not supported by NATS.
public
renewLock(message: MessageEnvelope, lockTimeout: number): Promise<void>
- message: MessageEnvelope - message to extend its lock.
- lockTimeout: number - locking timeout in milliseconds.
send
Sends a message into the queue.
public
send(correlationId: string, message: MessageEnvelope): Promise<void>
- correlationId: string - (optional) transaction id used to trace execution through the call chain.
- message: MessageEnvelope - message envelop to be sent.
setReferences
Sets references to dependent components.
public
setReferences(references: IReferences): void
- references: IReferences - references to locate the component’s dependencies.
toMessage
If the message is null, it returns null. Otherwise, it returns the message.
protected
toMessage(msg: any): MessageEnvelope
- msg: any - message
- returns: MessageEnvelope - message
unsetReferences
Unsets (clears) previously set references to dependent components.
public
unsetReferences(): void