MessageQueue

Abstract message queue that is used as a basis for specific message queue implementations.

Implements: IMessageQueue

Description

The MessageQueue class allows you to create a message queue that is used as a basis for specific message queue implementions.

Configuration parameters

  • name: name of the message queue

connection(s):

  • discovery_key: key to retrieve parameters from discovery service
  • protocol: connection protocol like http, https, tcp, udp
  • host: host name or IP address
  • port: port number
  • uri: resource URI or connection string with all parameters in it

credential(s):

  • store_key: key to retrieve parameters from credential store
  • username: username
  • password: user’s password
  • access_id: application access id
  • access_key: application secret key

References

  • *:logger:*:*:1.0 - (optional) ILogger components to pass log messages
  • *:counters:*:*:1.0 - (optional) ICounters components to pass collected measurements
  • *:discovery:*:*:1.0 - (optional) IDiscovery components to discover connection(s)
  • *:credential-store:*:*:1.0 - (optional) ICredentialStore componetns to lookup credential(s)

Constructors

Creates a new instance of the message queue.

InheritMessageQueue(overrides IMessageQueueOverrides, name string, capabilities *MessagingCapabilities) *MessageQueue

  • overrides: IMessageQueueOverrides - overrides IMessageQueue.
  • name: string - (optional) queue name
  • capabilities: *MessagingCapabilities - (optional) capabilities of this message queue

Fields

Logger

Component used to pass log messages.

Logger: *CompositeLogger

Counters

Component to pass collected measurements.

Counters: *CompositeCounters

ConnectionResolver

Component used to resolve connections.

ConnectionResolver: *ConnectionResolver

CredentialResolver

Component used to resolve credentials.

CredentialResolver: *CredentialResolver

name

Name of the message queue.

name: string

capabilities

Component used to store the message queue.

capabilities: *MessagingCapabilities

Methods

BeginListen

Listens for incoming messages without blocking the current thread.
See also Listen, IMessageReceiver

(c *MessageQueue) BeginListen(ctx context.Context, correlationId string, receiver IMessageReceiver)

  • ctx: context.Context - operation context.
  • correlationId: string - (optional) transaction id used to trace execution through the call chain.
  • receiver: IMessageReceiver - receiver used to receive incoming messages.

CheckOpen

Checks if the queue has been opened. Raise an exception if queue wasn’t opened or nil otherwise

(c *MessageQueue) CheckOpen(correlationId string) error

  • correlationId: string - (optional) transaction id used to trace execution through the call chain.
  • returns: error - error or nil no errors occured.

Configure

Configures the component by passing its configuration parameters.

(c *MessageQueue) Configure(ctx context.Context, config [*cconf.ConfigParams](../../../components/config/config_params

  • ctx: context.Context - operation context.
  • config: *cconf.ConfigParams - configuration parameters to be set.

Capabilities

Gets the queue capabilities

(c *MessageQueue) Capabilities() *MessagingCapabilities

Name

Gets the queue name

(c *MessageQueue) Name() string

  • returns: string - queue name.

Open

Opens the component.

(c *MessageQueue) Open(ctx context.Context, correlationId string) error

  • ctx: context.Context - operation context.
  • correlationId: string - (optional) transaction id used to trace execution through the call chain.
  • returns: error - error or nil no errors occured.

SendAsObject

Sends an object into the queue. Before sending the object is converted into JSON string and wrapped in a MessageEnvelope.

(c *MessageQueue) SendAsObject(ctx context.Context, correlationId string, messageType string, message any) (err error)

  • ctx: context.Context - operation context.
  • correlationId: string - (optional) transaction id used to trace execution through the call chain.
  • messageType: string - a message type.
  • message: any - an object value to be sent.
  • returns: (err error) - error or nil no errors occured.

SetReferences

Sets references to dependent components.

(c *MessageQueue) SetReferences(ctx context.Context, references cref.IReferences)

  • ctx: context.Context - operation context.
  • references: cref.IReferences - references to locate the component dependencies.

String

Gets a string representation of the object.

(c *MessageQueue) String() string

  • returns: string - string representation of the object.

OpenWithParams

Opens the component with the given connection and credential parameters.

OpenWithParams(ctx context.Context, correlationId string, connections []*cconn.ConnectionParams, credential *cauth.CredentialParams) error

  • ctx: context.Context - operation context.
  • correlationId: string - (optional) transaction id used to trace execution through the call chain.
  • connections: []*cconn.ConnectionParams - connection parameters.
  • credentials: *cauth.CredentialParams - credential parameters.
  • returns: error - error or nil no errors occured.