Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CachedMessageQueue

Message queue that caches received messages in memory to allow peek operations that may not be supported by the undelying queue.

This queue is users as a base implementation for other queues

Hierarchy

Implements

Index

Constructors

constructor

Properties

Protected _autoSubscribe

_autoSubscribe: boolean

Protected _capabilities

_capabilities: MessagingCapabilities

Protected _connectionResolver

_connectionResolver: ConnectionResolver = new ConnectionResolver()

Protected _counters

_counters: CompositeCounters = new CompositeCounters()

Protected _credentialResolver

_credentialResolver: CredentialResolver = new CredentialResolver()

Protected _logger

_logger: CompositeLogger = new CompositeLogger()

Protected _messages

_messages: MessageEnvelope[] = []

Protected _name

_name: string

Protected _receiver

_receiver: IMessageReceiver

Methods

Abstract abandon

  • Returnes 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.

    Parameters

    • message: MessageEnvelope

      a message to return.

    • Optional callback: function

      (optional) callback function that receives an error or null for success.

        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns void

beginListen

Protected checkOpen

  • checkOpen(correlationId: string): any
  • Checks if the queue has been opened

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    Returns any

    Error if queue wasn't opened or null otherwise

clear

  • clear(correlationId: string, callback: function): void
  • Clears component state.

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • callback: function

      callback function that receives error or null no errors occured.

        • (err?: any): void
        • Parameters

          • Optional err: any

          Returns void

    Returns void

close

  • close(correlationId: string, callback?: function): void
  • Closes component and frees used resources.

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • Optional callback: function

      callback function that receives error or null no errors occured.

        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns void

Abstract complete

  • Permanently removes a message from the queue. This method is usually used to remove the message after successful processing.

    Parameters

    • message: MessageEnvelope

      a message to remove.

    • Optional callback: function

      (optional) callback function that receives an error or null for success.

        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns void

configure

  • configure(config: ConfigParams): void
  • Configures component by passing configuration parameters.

    Parameters

    • config: ConfigParams

      configuration parameters to be set.

    Returns void

endListen

  • endListen(correlationId: string): void
  • Ends listening for incoming messages. When this method is call listen unblocks the thread and execution continues.

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    Returns void

getCapabilities

getName

  • getName(): string

Abstract isOpen

  • isOpen(): boolean
  • Checks if the component is opened.

    Returns boolean

    true if the component has been opened and false otherwise.

listen

  • Listens for incoming messages and blocks the current thread until queue is closed.

    see

    IMessageReceiver

    see

    receive

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • receiver: IMessageReceiver

      a receiver to receive incoming messages.

    Returns void

Abstract moveToDeadLetter

  • Permanently removes a message from the queue and sends it to dead letter queue.

    Parameters

    • message: MessageEnvelope

      a message to be removed.

    • Optional callback: function

      (optional) callback function that receives an error or null for success.

        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns void

open

  • open(correlationId: string, callback?: function): void
  • Opens the component.

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • Optional callback: function

      callback function that receives error or null no errors occured.

        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns void

Protected openWithParams

  • openWithParams(correlationId: string, connections: ConnectionParams[], credential: CredentialParams, callback: function): void
  • Opens the component with given connection and credential parameters.

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • connections: ConnectionParams[]
    • credential: CredentialParams

      credential parameters

    • callback: function

      callback function that receives error or null no errors occured.

        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns void

peek

  • peek(correlationId: string, callback: function): void
  • Peeks a single incoming message from the queue without removing it. If there are no messages available in the queue it returns null.

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • callback: function

      callback function that receives a message or error.

    Returns void

peekBatch

  • peekBatch(correlationId: string, messageCount: number, callback: function): void
  • Peeks multiple incoming messages from the queue without removing them. If there are no messages available in the queue it returns an empty list.

    Important: This method is not supported by MQTT.

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • messageCount: number

      a maximum number of messages to peek.

    • callback: function

      callback function that receives a list with messages or error.

    Returns void

readMessageCount

  • readMessageCount(callback: function): void
  • Reads the current number of messages in the queue to be delivered.

    Parameters

    • callback: function

      callback function that receives number of messages or error.

        • (err: any, count: number): void
        • Parameters

          • err: any
          • count: number

          Returns void

    Returns void

receive

  • receive(correlationId: string, waitTimeout: number, callback: function): void
  • Receives an incoming message and removes it from the queue.

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • waitTimeout: number

      a timeout in milliseconds to wait for a message to come.

    • callback: function

      callback function that receives a message or error.

    Returns void

Abstract renewLock

  • renewLock(message: MessageEnvelope, lockTimeout: number, callback?: function): void
  • 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.

    Parameters

    • message: MessageEnvelope

      a message to extend its lock.

    • lockTimeout: number

      a locking timeout in milliseconds.

    • Optional callback: function

      (optional) callback function that receives an error or null for success.

        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns void

Abstract send

  • send(correlationId: string, envelope: MessageEnvelope, callback?: function): void
  • Sends a message into the queue.

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • envelope: MessageEnvelope

      a message envelop to be sent.

    • Optional callback: function

      (optional) callback function that receives error or null for success.

        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns void

sendAsObject

  • sendAsObject(correlationId: string, messageType: string, message: any, callback?: function): void
  • Sends an object into the queue. Before sending the object is converted into JSON string and wrapped in a MessageEnvelope.

    see

    send

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • messageType: string

      a message type

    • message: any
    • Optional callback: function

      (optional) callback function that receives error or null for success.

        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns void

Protected sendMessageToReceiver

setReferences

  • setReferences(references: IReferences): void
  • Sets references to dependent components.

    Parameters

    • references: IReferences

      references to locate the component dependencies.

    Returns void

Protected Abstract subscribe

  • subscribe(correlationId: string, callback: function): void
  • Subscribes to the message broker.

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • callback: function

      callback function that receives error or null no errors occured.

        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns void

toString

  • toString(): string
  • Gets a string representation of the object.

    Returns string

    a string representation of the object.

Protected Abstract unsubscribe

  • unsubscribe(correlationId: string, callback: function): void
  • Unsubscribes from the message broker.

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • callback: function

      callback function that receives error or null no errors occured.

        • (err: any): void
        • Parameters

          • err: any

          Returns void

    Returns void

Generated using TypeDoc