Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IMessageQueue

Generic messaging queue implementation interface

example
import { IMessageQueue, EventEmitter, uuid } from '@imqueue/core';

class SomeMQAdapter implements IMessageQueue extends EventEmitter {
     public async start(): Promise<SomeMQAdapter> {
         // ... implementation goes here
         return this;
     }
     public async stop(): Promise<SomeMQAdapter> {
         // ... implementation goes here
         return this;
     }
     public async send(
         toQueue: string,
         message: IJson,
         delay?: number
     ): Promise<string> {
         const messageId = uuid();
         // ... implementation goes here
         return messageId;
     }
     public async destroy(): Promise<void> {
         // ... implementation goes here
     }
     public async clear(): Promise<SomeMQAdapter> {
         // ... implementation goes here
         return this;
     }
}

Hierarchy

  • EventEmitter
    • IMessageQueue

Implemented by

Index

Properties

Static defaultMaxListeners

defaultMaxListeners: number

Methods

addListener

  • addListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

clear

destroy

  • destroy(): Promise<void>
  • Safely destroys current queue, unregistered all set event listeners and connections. Supposed to be an async function.

    Returns Promise<void>

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

eventNames

  • eventNames(): Array<string | symbol>
  • Returns Array<string | symbol>

getMaxListeners

  • getMaxListeners(): number
  • Returns number

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

off

  • off(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

on

  • on(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

once

  • once(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependListener

  • prependListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • Parameters

    • Optional event: string | symbol

    Returns this

removeListener

  • removeListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

send

  • send(toQueue: string, message: IJson, delay?: undefined | number, errorHandler?: undefined | function): Promise<string>
  • Sends a message to given queue name with the given data. Supposed to be an async function.

    Parameters

    • toQueue: string

      queue name to which message should be sent to

    • message: IJson

      message data

    • Optional delay: undefined | number
    • Optional errorHandler: undefined | function

    Returns Promise<string>

    • message identifier

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

start

stop

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number