UNPKG

solclientjs

Version:

Solace Messaging API for Node.js

1 lines 232 kB
import { EventEmitter } from "events"; import Long = require("long"); declare namespace solace { /** * <b>This class is not exposed for construction by API users. Users should obtain an instances from * one of the following:</b> * * {@link solace.SolclientFactory.createTopicDestination} * * {@link solace.SolclientFactory.createDurableQueueDestination} * * {@link solace.MessageConsumer#getDestination} * * {@link solace.SDTField#getValue} when {@link solace.SDTField#getType} returns * {@link solace.SDTFieldType.DESTINATION}. * * Represents a message destination. * * Publishers can send messages to topics or queues, to which subscribers can subscribe or * bind. A Destination specifies the target of such an operation. */ class Destination { /** @protected */ protected constructor(); readonly name: string; readonly type: solace.DestinationType; /** * @returns {string} The destination name specified at creation time. */ getName(): string; /** * @returns {solace.DestinationType} The destination type */ getType(): solace.DestinationType; /** * @returns {string} A generic description of the Destination. */ toString(): string; } /** * <b>This class is not exposed for construction by API users.</b> * An error thrown when calling an API that has not been implemented. */ class NotImplementedError extends solace.SolaceError { /** @protected */ protected constructor(); /** * Error Message. */ message: string; /** * The name of the error. */ name: string; } /** * <b>This class is not exposed for construction by API users.</b> * An error thrown by the API when an operational error is encountered. */ class OperationError extends solace.SolaceError { /** @protected */ protected constructor(); /** * 'OperationError' */ readonly name: string; /** * The subcode for the error. @see {@link solace.ErrorSubcode} */ subcode: solace.ErrorSubcode; /** * The reason for the error: an embedded error object or exception. */ reason: object; /** * Error Message. */ message: string; } /** * <b>This class is not exposed for construction by API users.</b> * * Represents a request failure event; request failure events are passed to the application * event handling callback provided when sending the request {@link solace.Session#sendRequest} */ class RequestError extends solace.OperationError { /** @protected */ protected constructor(); /** * 'RequestError' */ readonly name: string; /** * A code that provides more information about the error event. */ requestEventCode: solace.SessionEventCode; /** * The subcode for the error. @see {@link solace.ErrorSubcode} */ subcode: solace.ErrorSubcode; /** * The reason for the error: an embedded error object or exception. */ reason: object; /** * Error Message. */ message: string; } /** * <b>This class is not exposed for construction by API users.</b> * The base class for all errors thrown by the API. */ class SolaceError { /** @protected */ protected constructor(); /** * Error Message. */ message: string; /** * The name of the error. */ name: string; } /** * Properties used during initialization of {@link solace.SolclientFactory}. */ class SolclientFactoryProperties { /** * Creates an instance of SolclientFactoryProperties. * @param {object} options The property names and values to apply to this instance * @param {solace.LogLevel} options.logLevel logLevel (default={@link solace.LogLevel.INFO} * @param {solace.LogImpl} options.logger log implementation (default=NULL) * @param {solace.SolclientFactoryProfiles} options.profile Javascript profile (default={@link solace.SolclientFactoryProfiles.version7}) */ constructor(options?: { logLevel?: solace.LogLevel; logger?: solace.LogImpl; profile?: solace.SolclientFactoryProfiles; }); /** * The factory profile to use. The following factory profiles are available: * * {@link solace.SolclientFactoryProfiles.version7}, a backwards-compatible profile * for existing solClientJS 7.x applications * * {@link solace.SolclientFactoryProfiles.version10}, the recommended profile * for new applications */ profile: solace.SolclientFactoryProfiles; /** * The logging level to use for filtering log events. Messages with a level of lesser importance * than this will be filtered out and not logged. */ logLevel: solace.LogLevel; /** * The logging implementation to use. In the debug API, the log implementation will be called * for every log statement not filtered out by the log level. If no implementation is supplied, * the default implementation will be used, which logs to the global console object. */ logger: solace.LogImpl; } /** * A class that provides a binding to a log implementation. Applications that need to * control API logging must construct a LogImpl * instance, a log implementation that can be set in * {@link solace.SolclientFactoryProperties#logger}. * The binding will call the supplied log methods with the * parameters supplied to each. */ class LogImpl { /** * @param {typeof solace.LogImpl.loggingCallback} trace Callback for {@link solace.LogLevel.TRACE} logs. * @param {typeof solace.LogImpl.loggingCallback} debug Callback for {@link solace.LogLevel.DEBUG} logs. * @param {typeof solace.LogImpl.loggingCallback} info Callback for {@link solace.LogLevel.INFO} logs. * @param {typeof solace.LogImpl.loggingCallback} warn Callback for {@link solace.LogLevel.WARN} logs. * @param {typeof solace.LogImpl.loggingCallback} error Callback for {@link solace.LogLevel.ERROR} logs. * @param {typeof solace.LogImpl.loggingCallback} fatal Callback for {@link solace.LogLevel.FATAL} logs. */ constructor( trace: typeof solace.LogImpl.loggingCallback, debug: typeof solace.LogImpl.loggingCallback, info: typeof solace.LogImpl.loggingCallback, warn: typeof solace.LogImpl.loggingCallback, error: typeof solace.LogImpl.loggingCallback, fatal: typeof solace.LogImpl.loggingCallback ); /** * A logging callback. It must accept any valid number of arguments of any type. It must not throw. * @param {any} args The arguments to log. Typically this is a mixture of strings and objects to be inspected. A simple implementation might call .toString() on each argument. */ static loggingCallback(args: any): void; } /** * Message consumer event objects. A {@link solace.MessageConsumer} will emit * these events related to queue subscription management: * MessageConsumerEventName.SUBSCRIPTION_OK and * MessageConsumerEventName.SUBSCRIPTION_ERROR. * * Similar to SessionEvent. * Also compatible with RequestError. */ class MessageConsumerEvent { constructor(); /** * the appropriate MessageConsumerEventName * * MessageConsumerEventName.SUBSCRIPTION_OK or * MessageConsumerEventName.SUBSCRIPTION_ERROR. */ messageConsumerEventName: string; /** * the appropriate MessageConsumerEventName * * MessageConsumerEventName.SUBSCRIPTION_OK or * MessageConsumerEventName.SUBSCRIPTION_ERROR. */ name: string; /** * if applicable, an information string returned by the Solace Message Router. */ infoStr: string; /** * if applicable, a response code returned by the Solace Message Router. */ responseCode: number; /** * if applicable, an error subcode. Defined in {@link solace.ErrorSubcode} * same as subcode. */ errorSubcode: solace.ErrorSubcode; /** * if applicable, an error subcode. Defined in {@link solace.ErrorSubcode} * Same as errorSubcode. */ subcode: solace.ErrorSubcode; /** * A user-specified object * made available in the response or confirmation event by including it as a * parameter in the orignal API call. If the user did not specify a * correlationKey, it will be <code>null</code>. */ correlationKey?: object; /** * Additional information if it is applicable. * * In case of subscribe or publish events, it constains the topic. */ reason: string; /** * Only here for compatibility with the RequestError exception class. * Always returns undefined for a MessageConsumerEvent. */ requestEventCode: solace.SessionEventCode; } /** * Defines the properties for a {@link solace.MessageConsumer}. */ class MessageConsumerProperties { constructor(); /** * Defines the queue from which to consume. * * For durable queues and durable topic endpoints, this must be a * {@link solace.QueueDescriptor} unless * {@link solace.MessageConsumerProperties#createIfMissing} is set. * * When an {@link solace.AbstractQueueDescriptor} is used, the name is generated when * the {@link solace.MessageConsumer} is connected. The generated descriptor can be queried * from the consumer after it has successfully connected by calling * {@link solace.MessageConsumer#getProperties}. */ queueDescriptor: solace.QueueDescriptor; /** * Gets the properties of the remote queue. * * For temporary queues and temporary topic endpoints, * or if {@link solace.MessageConsumerProperties#createIfMissing} is true, * these properties define the endpoint that is created. * * For durable queues, these must be unset on consumer creation * unless {@link solace.MessageConsumerProperties#createIfMissing} is set. * The values will be populated * after the queue is connected and can be retrieved by calling * {@link solace.MessageConsumer#getProperties}. */ queueProperties?: solace.QueueProperties | null | undefined; /** * The bind timeout in milliseconds when creating a connection to the Solace Message Router. * * The valid range is >= 50. */ connectTimeoutInMsecs?: number; /** * Gets and sets the maximum number of bind attempts when creating a connection to the * Solace Message Router. * * The valid range is >= 1. */ connectAttempts?: number; /** * This must be undefined if the type of the * {@link solace.MessageConsumerProperties#queueDescriptor} is not * {@link solace.QueueType.TOPIC_ENDPOINT}. * * If {@link solace.MessageConsumerProperties#queueDescriptor} is * not durable, or {@link solace.MessageConsumerProperties#createIfMissing} is true, * this may be left undefined to generate the topic endpoint's * destination. When generated, the destination can be obtained from * the {@link solace.MessageConsumer} after it is connected by calling * {@link solace.MessageConsumer#getDestination}. */ topicEndpointSubscription?: solace.Destination; /** * The Application Acknowledgement mode for the Message Consumer. * * When the acknowledgement mode is {@link solace.MessageConsumerAcknowledgeMode.CLIENT}, * a message is Application Acknowledged when the application calls * {@link solace.Message#acknowledge} on that message. * * When the acknowledge mode is {@link solace.MessageConsumerAcknowledgeMode.AUTO}, a message is * Application Acknowledged by the API after all * {@link solace.MessageConsumerEventName#event:MESSAGE} * listeners are called and none throw an exception. If a message handler throws, the message * can still be acknowledged by calling {@link solace.Message#acknowledge}, but this would not be * a recommended practice. * * When received messages are Application Acknowledged they are removed from the Guaranteed * Message storage on the Solace Message Router. Message Consumer Application Acknowledged, * <b>only</b> remove messages from the Solace Message Router. * * In particular, withholding Message Consumer Acknowledgemnts does not stop * message delivery. For Message Consumer flow control (aka transport acknowledgemeent) see * {@link solace.MessageConsumer#stop}/{@link solace.MessageConsumer#start}. Message Consumer * flow control may also be imlpemented by removing the * {@link solace.MessageConsumerEventName#event:MESSAGE} listener. * * Flow control and transport acknowledgements characteristics are defined by * {@link solace.MessageConsumerProperties#transportAcknowledgeThresholdPercentage} and * {@link solace.MessageConsumerProperties#transportAcknowledgeTimeoutInMsecs} */ acknowledgeMode?: solace.MessageConsumerAcknowledgeMode; /** * The required settlement outcomes for the Message Consumer. * * A session is created with SUPPORTED_MESSAGE_ACK_CLIENT by setting * the requiredSettlementOutcomes property to support negative acknowledgment outcomes. * * The {@link solace.MessageOutcome.ACCEPTED} outcome is not required to be set and is always * supported as a settlement outcome. * * When the requiredSettlementOutcomes include either {@link solace.MessageOutcome.FAILED} * or {@link solace.MessageOutcome.REJECTED}, a message can be settled with any of these outcomes. * * The {@link solace.Message#acknowledge} method internally calls the {@link solace.Message#settle} * with the {@link solace.MessageOutcome.ACCEPTED} passed as the settlement outcome for that message. * * When received messages are Application Acknowledged/Settled with * a {@link solace.MessageOutcome.ACCEPTED} outcome, they are removed from the Guaranteed * Message storage on the Solace Message Router. * * In particular, withholding Message Consumer Acknowledgemnts does not stop * message delivery. For Message Consumer flow control (aka transport acknowledgemeent) see * {@link solace.MessageConsumer#stop}/{@link solace.MessageConsumer#start}. Message Consumer * flow control may also be imlpemented by removing the * {@link solace.MessageConsumerEventName#event:MESSAGE} listener. * * Flow control and transport acknowledgements characteristics are defined by * {@link solace.MessageConsumerProperties#transportAcknowledgeThresholdPercentage} and * {@link solace.MessageConsumerProperties#transportAcknowledgeTimeoutInMsecs} */ requiredSettlementOutcomes?: solace.MessageOutcome[]; /** * The transport acknowledgement timeout for guaranteed messaging. * When the {@link solace.MessageConsumerProperties.transportAcknowledgeTimeoutInMsecs} * is not exceeded, acknowledgements will be returned to the router at intervals not less than * this value. * * The valid range is 20 <= transportAcknowledgeTimeoutInMsecs <= 1500. */ transportAcknowledgeTimeoutInMsecs?: number; /** * The threshold for sending an acknowledgement, as a percentage. * The API sends a transport acknowledgment every * N messages where N is calculated as this percentage of the transport * window size if the endpoint's max-delivered-unacked-msgs-per-flow * setting at bind time is greater than or equal to the transport * window size. Otherwise, N is calculated as this percentage of the * endpoint's max-delivered-unacked-msgs-per-flow setting at bind time. * * The valid range is 1 <= transportAcknowledgeThresholdPercentage <= 75. */ transportAcknowledgeThresholdPercentage?: number; /** * When enabled, a Guaranteed Messaging Consumer requests Active and Inactive * events from the router and emits them to interested listeners. */ activeIndicationEnabled?: boolean; /** * When enabled, a Guaranteed Messaging Consumer does not receive messages published * in the same Session, even if the endpoint contains a subscription that matches the published * message. */ noLocal?: boolean; /** * The window size for Guaranteed Message delivery. This is the maximum number of messages that * will be prefetched from the Solace Messaging Router and queued internally by the API while * waiting for the application to accept delivery of the messages. * * The valid range is 1 <= windowSize <= 255. */ windowSize?: number; /** * When a Flow is created, the application may request replay of messages from the replay log, * even messages that have been previously delivered and removed the from topic endpoint or queue. * The default is undefined, and indicates that no replay is requested. * * When defined the replay start location must be a {@link solace.ReplayStartLocation} object * as returned by * {@link solace.SolClientFactory.createReplayStartLocationBeginning} or * {@link solace.SolClientFactory.createReplayStartLocationDate}. * * The {@link solace.ReplayStartLocation} returned by * {@link solace.SolClientFactory.createReplayStartLocationBeginning} * indicate that all messages available should be replayed. * * The replay start location returned by * {@link solace.SolClientFactory.createReplayStartLocationDate} * indicates that all messages logged since a given date must be retrieved. */ replayStartLocation?: solace.ReplayStartLocation; /** * When a connected flow receives an unsolicited unbind event with subcode * REPLAY_STARTED or GM_UNAVAILABLE, the SDK can reconnect the flow automatically. * This property controls the flow auto reconnect feature: * 0: Disable flow auto reconnect for this consumer flow. * -1: Enable flow auto reconnect for this consumer flow, infiinite retries (default) * <n, positive number>: Enable flow auto reconnect for this consumer flow, n retries. * * When the flow auto rebind is enabled, DOWN_ERRORs with REPLAY_STARTED and GM_UNAVAILABLE * are handled internally, and not (immediately) emitted to the application. * A RECONNECTING event (with the same subcode) is emitted instead, * ideally followed by a RECONNECTED event when the reconnect succeedes. * In case of REPLAY_STARTED, the window of message IDs and acknowledgements are reset * to allow replay packets to be passed to the application without marking them as duplicates. * In case of GM_UNAVAILABLE, flow state is preserved. * * If reconnecting fails after exhausting the number of retries, a DOWN_ERROR is emitted * with the details of the last retry. */ reconnectAttempts?: number; /** * Time to wait between flow auto reconnect attempts, in milliseconds. * See {@link solace.MessageConsumerProperties.reconnectAttempts} * Defaults to 3 seconds (3000) * * The valid range is >= 50. */ reconnectIntervalInMsecs?: number; /** * If the endpoint is durable, it won't be auto-created unless this flag is set. * This flag has no effect for temporary endpoints, those are always created if missing. * This flag has no effect for existing endpoints. * * Off by default for backwards compatibility. */ createIfMissing?: boolean; } interface MessageConsumer { on<U extends keyof solace.MessageConsumerEventNameEvents>( event: U, listener: solace.MessageConsumerEventNameEvents[U] ): this; } /** * <b>This class is not exposed for construction by API users.</b> * A Message Consumer is created by calling {@link solace.Session#createMessageConsumer}. * * A MessageConsumer controls Guaranteed Message delivery to this client. * * Consumer characteristics and behavior are defined by {@link solace.MessageConsumerProperties}. * The properties can also be supplied as a simple key-value {Object}. The queue descriptor, * {@link solace.MessageConsumerProperties#queueDescriptor} must be specified to identify the * Guaranteed Message Queue or Guaranteed Message Topic Endpoint on the Solace Message Router. * * The MessageConsumer object is an EventEmitter, and will emit events to which the * application may choose to subscribe, such as the connection to the Solace Message Router * going up or down. * * If a registered listener for an emitted event throws an exception, this is caught and emitted as * an 'error'. * @fires solace.MessageConsumerEventName#event:ACTIVE * @fires solace.MessageConsumerEventName#event:CONNECT_FAILED_ERROR * @fires solace.MessageConsumerEventName#event:DISPOSED * @fires solace.MessageConsumerEventName#event:DOWN * @fires solace.MessageConsumerEventName#event:DOWN_ERROR * @fires solace.MessageConsumerEventName#event:GM_DISABLED * @fires solace.MessageConsumerEventName#event:INACTIVE * @fires solace.MessageConsumerEventName#event:MESSAGE * @fires solace.MessageConsumerEventName#event:UP * @fires solace.MessageConsumerEventName#event:SUBSCRIPTION_OK * @fires solace.MessageConsumerEventName#event:SUBSCRIPTION_ERROR */ class MessageConsumer extends EventEmitter { /** @protected */ protected constructor(); /** * After the MessageConsumer has connected to an endpoint * ({@link solace.MessageConsumerEventName#UP}), accesstype represents * the access type for the endpoint to which this Message Consumer is bound. */ static accessType: solace.QueueAccessType; /** * After the MessageConsumer has connected as indicated by the event * {@link solace.MessageConsumerEventName#event:UP}, queueDiscardBehavior represents * the discard behavior flags for the endpoint to which this Message Consumer is bound. */ static queueDiscardBehaviour: solace.QueueDiscardBehavior; /** * After the MessageConsumer has connected as indicated by the event * {@link solace.MessageConsumerEventName#event:UP} * respectsTTL is `true` when the endpoint respects Time To Live on messages * and 'false' otherwise. */ static respectsTTL: boolean; /** * After the MessageConsumer has connected as indicated by the event * {@link solace.MessageConsumerEventName#event:UP}, this property represents * permissions granted by the router to this user on this Message Consumer */ static permissions: solace.QueuePermissions; /** * Returns `true` if this Guaranteed Message Consumer was disposed. */ readonly disposed: boolean; readonly session: void; /** * Begins delivery of messages to this consumer. This method opens the protocol window * to the Solace Message Router so further messages can be received. * * A newly created consumer is in started state. * * If the consumer was already started, this method has no effect. * * A consumer is stopped by calling {@link solace.MessageConsumer.stop} * @throws {solace.OperationError} * if the Message Consumer is disposed. subcode = {@link solace.ErrorSubcode.INVALID_OPERATION} * if the Message Consumer is disconnected. subcode = {@link solace.ErrorSubcode.INVALID_OPERATION} */ start(): void; /** * Stops messages from being delivered to this consumer from the Solace Message Router. * Messages may continue to be prefetched by the API and queued internally * until {@link solace.MessageConsumer#start} is called. * * If the consumer was already stopped, this method has no effect. * @throws {solace.OperationError} * if the Message Consumer is disconnected. subcode = {@link solace.ErrorSubcode.INVALID_OPERATION} */ stop(): void; /** * Connects the consumer immediately. The application should add event listeners (see * {@link solace.MessageConsumerEventName}). If there is no listener added for * {@link solace.MessageConsumerEventName#event:MESSAGE} then up to a window * {@link solace.MessageConsumerProperties.windowSize} of messages can be queued internally. * to the {@link solace.MessageConsumer} before calling this method. * @throws {solace.OperationError} * if consumer is not supported by router for this client. subcode = {@link solace.ErrorSubcode.INVALID_OPERATION} */ connect(): void; /** * Initiates an orderly disconnection of the Message Consumer. The API will send any pending * client acknowledgements on the Message Consumer, then send an unbind request. * Any messages subsequently * received are discarded silently. When the unbind message is acknowledged, the application * receives a {@link solace.MessageConsumerEventName#event:DOWN} event if it has set a listener * for that event. * @throws {solace.OperationError} * if the Message Consumer is disconnected. subcode = {@link solace.ErrorSubcode.INVALID_OPERATION} */ disconnect(): void; /** * Returns the destination that should be used to publish messages that this consumer * will receive. * * For topic endpoints, this is the topic to which the topic endpoint is subscribed. * * For queues, this is the associated queue destination. * * The destination returned can * be used to set the ReplyTo field in a message, or otherwise communicated * to partners that need to send messages to this Message Consumer. This is especially useful * for temporary endpoints (Queues and Topic Endpoints), as the destination * is unknown before the endpoint is created. * * This method will succeed after {@link solace.MessageConsumerEventName#event:UP} for temporaries * with generated destinations. * @returns {solace.Destination} The publishing destination that delivers to this consumer. * @throws {solace.OperationError} * if the {@link solace.MessageConsumer} is disconnected and the destination is temporary. */ getDestination(): solace.Destination; /** * Creates and returns copy of the properties for this MessageConsumer. * * If the object was constructed using an {@link solace.AbstractQueueDescriptor}, * and the queue descriptor was subsequently connected to an endpoint, the * `MessageConsumerProperties` returned will include a {@link solace.QueueDescriptor} * that contains the resolved name. * * A new copy of the properties object is returned each time this property is accessed. * The returned object cannot be polled for mutations such as the one described above. * @returns {solace.MessageConsumerProperties} The properties associated with this object. */ getProperties(): solace.MessageConsumerProperties; /** * Subscribe the queue to a topic, always requesting confirmation from the router. * * {@link solace.MessageConsumerEventName.SUBSCRIPTION_OK} is generated when subscription is * added successfully; otherwise, session event * {@link solace.MessageConsumerEventName.SUBSCRIPTION_ERROR} is generated. * * When the application receives the event * {@link solace.MessageConsumerEventName.SUBSCRIPTION_ERROR}, it * can obtain the failed topic subscription by calling * {@link solace.MessageConsumerEvent#reason}. * The returned string is in the format of "Topic: <failed topic subscription>". * @param {solace.Destination} topic The topic destination subscription to add. * @param {object | string | null | undefined} correlationKey If specified, this value is echoed in the messageConsumer event within {@link MessageConsumerEvent}. * @param {number} requestTimeout The request timeout period (in milliseconds). If specified, this value overwrites readTimeoutInMsecs property in {@link SessionProperties}. * @throws {solace.OperationError} * if the session is disposed or disconnected, or the consumer is inactive, down, disconnected, or disposed. Or if the consumer is bound to a topic endpoint instead of a queue. Subcode: {@link solace.ErrorSubcode.INVALID_OPERATION}. * if the parameters have an invalid type. Subcode: {@link solace.ErrorSubcode.PARAMETER_INVALID_TYPE}. * if the parameters have an invalid value. Subcode: {@link solace.ErrorSubcode.PARAMETER_OUT_OF_RANGE}. * if the topic has invalid syntax. Subcode: {@link solace.ErrorSubcode.INVALID_TOPIC_SYNTAX}. * if there's no space in the transport to send the request. Subcode: {@link solace.ErrorSubcode.INSUFFICIENT_SPACE}. See: {@link solace.SessionEventCode#event:CAN_ACCEPT_DATA}. * if the topic is a shared subscription and the peer router does not support Shared Subscriptions. Subcode: {@link solace.ErrorSubcode.SHARED_SUBSCRIPTIONS_NOT_SUPPORTED}. * if the topic is a shared subscription and the client does not allowed Shared Subscriptions. Subcode: {@link solace.ErrorSubcode.SHARED_SUBSCRIPTIONS_NOT_ALLOWED}. */ addSubscription( topic: solace.Destination, correlationKey: object | string | null | undefined, requestTimeout: number ): void; /** * Unsubscribe the queue from a topic, requesting confirmation from the router. * * {@link solace.MessageConsumerEventName.SUBSCRIPTION_OK} is generated when subscription is * removed successfully; otherwise, session event * {@link solace.MessageConsumerEventName.SUBSCRIPTION_ERROR} is generated. * * When the application receives the message consumer event * {@link solace.MessageConsumerEventName.SUBSCRIPTION_ERROR}, it * can obtain the failed topic subscription by calling * {@link solace.MessageConsumerEvent#reason}. The returned * string is in the format "Topic: <failed topic subscription>". * @param {solace.Destination} topic The topic destination subscription to remove. * @param {object | string | null | undefined} correlationKey If <code>null</code> or undefined, a Correlation Key is not set in the confirmation session event. * @param {number} requestTimeout The request timeout period (in milliseconds). If specified, this value overwrites readTimeoutInMsecs property in {@link SessionProperties}. * @throws {solace.OperationError} * if the session is disposed or disconnected, or the consumer is inactive, down, disconnected, or disposed. Or if the consumer is bound to a topic endpoint instead of a queue. Subcode: {@link solace.ErrorSubcode.INVALID_OPERATION}. * if the parameters have an invalid type. Subcode: {@link solace.ErrorSubcode.PARAMETER_INVALID_TYPE}. * if the parameters have an invalid value. Subcode: {@link solace.ErrorSubcode.PARAMETER_OUT_OF_RANGE}. * if the topic has invalid syntax. Subcode: {@link solace.ErrorSubcode.INVALID_TOPIC_SYNTAX}. * if there's no space in the transport to send the request. Subcode: {@link solace.ErrorSubcode.INSUFFICIENT_SPACE}. See: {@link solace.SessionEventCode#event:CAN_ACCEPT_DATA}. * if the topic is a shared subscription and the peer router does not support Shared Subscriptions. Subcode: {@link solace.ErrorSubcode.SHARED_SUBSCRIPTIONS_NOT_SUPPORTED}. * if the topic is a shared subscription and the client does not allowed Shared Subscriptions. Subcode: {@link solace.ErrorSubcode.SHARED_SUBSCRIPTIONS_NOT_ALLOWED}. */ removeSubscription( topic: solace.Destination, correlationKey: object | string | null | undefined, requestTimeout: number ): void; /** * Clears all statistics for this Guaranteed Message Connection. All previous Guaranteed * Message Connection statistics are lost * when this is called. * @throws {solace.OperationError} * if the Message Consumer is disposed. subcode = {@link solace.ErrorSubcode.INVALID_OPERATION} */ clearStats(): void; /** * Disposes the Guaranteed Message connection, removing all listeners and releasing references. */ dispose(): void; /** * Returns a statistic for this Guaranteed Message connection. * @param {solace.StatType} statType The statistic to return. * @returns {number} The value for the statistic. */ getStat(statType: solace.StatType): number; /** * @returns {string} A description of this Guaranteed Message Connection */ toString(): string; } /** * Defines the properties for a {@link solace.QueueBrowser}. */ class QueueBrowserProperties { constructor(); /** * Defines the queue from which to consume. * * For durable queues and durable topic endpoints, this must be a * {@link solace.QueueDescriptor}. */ queueDescriptor: solace.QueueDescriptor; /** * The bind timeout in milliseconds when creating a connection to the Solace Message Router. * * The valid range is >= 50. */ connectTimeoutInMsecs?: number; /** * Gets and sets the maximum number of bind attempts when creating a connection to the * Solace Message Router. * * The valid range is >= 1. */ connectAttempts?: number; /** * The window size for Guaranteed Message delivery. This is the maximum number of messages that * will be prefetched from the Solace Messaging Router and queued internally by the API while * waiting for the application to accept delivery of the messages. * * The valid range is 1 <= windowSize <= 255. */ windowSize?: number; /** * The transport acknowledgement timeout for guaranteed messaging in milliseconds. * When the {@link solace.QueueBrowserProperties.transportAcknowledgeTimeoutInMsecs} is not * exceeded, acknowledgements will be returned to the router at intervals not less than * this value. * * The valid range is 20 <= transportAcknowledgeTimeoutInMsecs <= 1500. */ transportAcknowledgeTimeoutInMsecs?: number; /** * The threshold for sending an acknowledgement, as a percentage. * The API sends a transport acknowledgment every * N messages where N is calculated as this percentage of the transport * window size if the endpoint's max-delivered-unacked-msgs-per-flow * setting at bind time is greater than or equal to the transport * window size. Otherwise, N is calculated as this percentage of the * endpoint's max-delivered-unacked-msgs-per-flow setting at bind time. * * The valid range is 1 <= transportAcknowledgeThresholdPercentage <= 75. */ transportAcknowledgeThresholdPercentage?: number; } interface QueueBrowser { on<U extends keyof solace.QueueBrowserEventNameEvents>( event: U, listener: solace.QueueBrowserEventNameEvents[U] ): this; } /** * <b>This class is not exposed for construction by API users.</b> * A Queue Browser is created by calling {@link solace.Session#createQueueBrowser}. * * A Queue Browser allows client applications to look at messages spooled on Endpoints * without removing them. Messages are browsed from oldest to newest. * After being browsed, messages are still available for consumption over normal flows. * However, it is possible to selectively remove messages from the persistent store of an Endpoint. * In this case, these removed messages will no longer be available for consumption. * Note: If browsing a queue with an active consumer, no guarantee is made that the browser will * receive all messages published to the queue. The consumer can receive and acknowledge messages * before they are delivered to the browser. * * One typical application is to use Browsers to allow message bus administrators to remove “stuck” * Guaranteed messages from an Endpoint without having to modify or disrupt existing applications. * A message can get stuck if: * * 1) It has been received by an application, but for some reason, that application has failed to * acknowledge it. * 2) All active message selectors have failed to match this particular message and therefore the * message bus has not delivered it to any client yet. The current release only supports * browsing Endpoints of type Queue. * * Note that the delivery restrictions imposed by the queue’s Access type * (exclusive or non-exclusive), do not apply when browsing messages with a Browser. * * Browser characteristics and behavior are defined by {@link solace.QueueBrowserProperties}. * The properties can also be supplied as a simple key-value {Object}. The queue descriptor, * {@link solace.QueueBrowserProperties#queueDescriptor} must be specified to identify the * Guaranteed Message Queue on the Solace Message Router. * * The Browser is an EventEmitter, and will emit events to which the application may choose to * subscribe, such as the connection to the Solace Message Router going up or down. * * If a registered listener for an emitted event throws an exception, this is caught and emitted as * an 'error'. * @fires solace.QueueBrowserEventName#event:CONNECT_FAILED_ERROR * @fires solace.QueueBrowserEventName#event:DISPOSED * @fires solace.QueueBrowserEventName#event:DOWN * @fires solace.QueueBrowserEventName#event:DOWN_ERROR * @fires solace.QueueBrowserEventName#event:GM_DISABLED * @fires solace.QueueBrowserEventName#event:MESSAGE * @fires solace.QueueBrowserEventName#event:UP */ class QueueBrowser extends EventEmitter { /** @protected */ protected constructor(); /** * Connects the queue browser immediately. The application should add event listeners (see * {@link solace.QueueBrowserEventName}). If there is no listener added for * {@link solace.QueueBrowserEventName#event:MESSAGE} then up to a window * {@link solace.QueueBrowserProperties.windowSize} of messages can be queued internally. * before calling this method. * @throws {solace.OperationError} * if consumer is not supported by router for this client. subcode = {@link solace.ErrorSubcode.INVALID_OPERATION} */ connect(): void; /** * Initiates an orderly disconnection of the queue browser. The API will send an unbind request. * Any messages subsequently received are discarded silently. * When the unbind message is acknowledged, the application * receives a {@link solace.QueueBrowserEventName#event:DOWN} event if it has set a listener * for that event. * @throws {solace.OperationError} * if the Message Consumer is disconnected. subcode = {@link solace.ErrorSubcode.INVALID_OPERATION} */ disconnect(): void; /** * Begins delivery of messages to this queue browser. This method opens the protocol window * to the Solace Message Router so further messages can be received. * * A newly created queue browser is in started state. * * If the queue browser was already started, this method has no effect. * * A consumer is stopped by calling {@link solace.QueueBrowser.stop} * @throws {solace.OperationError} * if the Queue BrowserMessage Consumer is disposed. subcode = {@link solace.ErrorSubcode.INVALID_OPERATION} * if the Message Consumer is disconnected. subcode = {@link solace.ErrorSubcode.INVALID_OPERATION} */ start(): void; /** * Stops messages from being delivered to this queue browser from the Solace Message Router. * Messages may continue to be prefetched by the API and queued internally * until {@link solace.QueueBrowser#start} is called. * * If the queue browser was already stopped, this method has no effect. * @throws {solace.OperationError} * if the Queue Browser is disconnected. subcode = {@link solace.ErrorSubcode.INVALID_OPERATION} */ stop(): void; /** * Removes a message from the queue by acknowledging it. * * The {@link solace.QueueBrowser} does not automatically acknowledge messages. * once they have been received. * * The API does not send acknowledgments immediately. It stores the state for * acknowledged messages internally and acknowledges messages, in bulk, when a * threshold or timer is reached. * @param {Message} message The message to remove */ removeMessageFromQueue(message: Message): void; } /** * Properties that define the configuration for a guaranteed message publisher. */ class MessagePublisherProperties { /** * @param {object} options Properties to apply to the newly constructed object. */ constructor(options: object); /** * When enabled, a Guaranteed Messaging Publisher * is automatically created when a session is connected. * * The default value is the same as the value provided to * {@link solace.SolclientFactory.init}, * in the profile, {@link solace.SolclientFactoryProperties#profile}, * in the field {@link solace.FactoryProfile#guaranteedMessagingEnabled}. */ enabled: boolean; /** * Maximum number of messages that can be published * without acknowledgment. * * The valid range is 1 <= value <= 255 */ windowSize?: number; /** * The time to wait for an acknowledgement, * in milliseconds, before retransmitting unacknowledged * messages. * * The valid range is 20 <= value <= 60000. */ acknowledgeTimeoutInMsecs?: number; /** * The message-router sends windowed acknowledgements * which the API converts to per-message acknowledgement by default. If * acknowledgeMode is Windowed, then the API will simply pass through * the message-router acknowledgements. */ acknowledgeMode?: solace.MessagePublisherAcknowledgeMode; } /** * <b>This class abstracts baggage metadata used for distributed * message tracing with Solace messaging APIs types. * This class is for internal use only. * <p> */ class Baggage { /** @protected */ protected constructor(); } /** * <b>This class abstracts settable metadata used for * distributed message tracing with Solace messaging APIs * types. This class is for internal use only. * <p> */ class TraceContextSetter { /** @protected */ protected constructor(); /** * The length of the traceId bytes in the binary message */ static TRACE_ID_BYTES_LENGTH: void; /** * The length of the spanId bytes in the binary message */ static SPAN_ID_BYTES_LENGTH: void; /** * The version which for now is 1. -> 0001 */ version: void; /** * Clone this TraceContextSetter object. * @returns {TraceContextSetter} the cloned TraceContextSetter instance */ clone(): TraceContextSetter; /** * Sets the version * @param {number} value The version encoded as Hex value */ setVersion(value: number): void; /** * Sets the value of the trace identifier associated with the message. * @param {string} value The trace identifier encoded as a 16-length Hex string */ setTraceId(value: string): void; /** * Sets the value of the span identifier associated with the message. * @param {string} value The trace identifier encoded as a 8-length Hex string */ setSpanId(value: string): void; /** * Turns on or off sampling for the associated message. * @param {boolean} value if true sampling is on, off otherwise */ setSampled(value: boolean): void; /** * Sets the value of the trace state associated with the message. * @param {string} value The value of trace state associated with the message */ setTraceState(value: string): void; /** * Gets a new instance of the Message Trace Context Setter * from the values in the SMF header associated with the message. * @param {Buffer | Uint8Array | string | null} traceContextValue The value of trace context associated with the message * @returns {solace.TraceContextSetter | null} Context setter object */ static fromTraceContext( traceContextValue: Buffer | Uint8Array | string | null ): solace.TraceContextSetter | null; } /** * <b>This class abstracts readonly view on a metadata used for * distributed message tracing with Solace messaging APIs * types. This class is for internal use only. * <p> */ class TraceContext { /** @protected */ protected constructor(); /** * The version which for now is 1. */ version: void; /** * The maximum allowed string size of trace state to propagate. * * Refer: https://www.w3.org/TR/trace-context/#tracestate-limits */ MAX_TRACE_STATE_LENGTH: void; /** * The tranceId property as a 16-length string */ traceId: void; /** * The spanId property a 8-length string */ spanId: void; /** * The isSampled boolean property */ isSampled: void; /** * The traceState property */ traceState: void; /** * Clone the a TraceContext object used * for distributed message tracing. * @param {TraceContext} toClone {TraceContext} * @returns {TraceContext} the newly cloned TraceContext instance */ static clone(toClone: TraceContext): TraceContext; /** * Gets the version associated with the message trace. * @returns {number} The version encoded as Hex value */ getVersion(): number; /** * Gets the value of the trace identifier associated with the message. * @returns {string} value of trace identifier associated with the message as 16-length string. */ getTraceId(): string; /** * Gets the value of the span identifier associated with the message. * @returns {string} value of span identifier associated with the message as 8-length string. */ getSpanId(): string; /** * Returns true if the sampling for the associated message is on, * otherwise false. * @returns {boolean} indicates whether the sampling is on or off */ getIsSampled(): boolean; /** * Gets the value of the trace state associated with the message. * @returns {string} The value of trace state associated with the message */ getTraceState(): string | null; /** * Gets the value of the trace state associated with the message. * @returns {string} The value of trace state associated with the message */ getTruncatedTraceState(): string | null; /** * It returns the encoded bytes that is * passed to the SMF header to be encoded in * SMF for the message. * @returns {Uint8Array} The value of encoded trace span context */ getEncodedTraceContext(): Uint8Array | null; /** * Returns the string representation of this object */ toString(): void; } /** * <b>This class is not exposed for construction by API users. Users should obtain an instance from * {@link solace.SolclientFactory.createMessage}</b> * <p> * A message is a container that can be used to store and send messages to and from the * Solace Message Router. * * Applications manage the lifecycle of a message; a message is created by calling * {@link solace.SolclientFactory.createMessage} and is freed by dereferencing it. * * API operations that cache or mutate messages always take a copy. A message may * be created, mutated by the API user, and sent multiple times. * * The Message Object provides methods to manipulate the common Solace * message header fields that are optionally sent in the binary metadata * portion of the Solace message. * * Applications can also use the structured data API {@link solace.Message#setSdtContainer} * to add containers (maps or streams) and their fields to the binary payload or * to the User Property map contained within the binary metadata. * * This does not prevent applications from ignoring these * methods and sending payload in the binary payload as an opaque binary field for * end-to-end communications */ class Message { /** @protected */ protected constructor(); /** * Returns whether settle(solace.MessageOutcome) has been called on this message. */ readonly isSettled: boolean; /** * Returns whether acknowledge() has been called on this message. */ readonly isAcknowledged: boolean; /** * A standard property key that clients should use if they want to * group messages into different queue partitions. * Expected value is UTF-8 encoded up to 255 bytes long string. */ static SOLCLIENT_USER_PROP_QUEUE_PARTITION_KEY: void; /** * Gets the payload type ({@link solace.MessageType}) of the message. A message has a * structured payload if one was attached via {@link solace.Message#setSdtContainer} otherwise * if the payload is attached via {@link Message@setBinaryAttachment} then it * is unstructured ({@link solace.MessageType#BINARY}) * @returns {solace.MessageType} The structured payload type. */ getType(): solace.MessageType; /** * Sets the application-provided message ID. * @param {string} value The new value for the application-provided message ID. */ setApplicationMessageId(value: string): void; /** * Gets the application-provided message ID. * @returns {string} The application provided message ID. */ getApplicationMessageId(): string | null; /** * Sets the application message type. This value is used by applications * only, and is passed through the API and Solace Message Router untouched. * @param {string} value The application message type. */ setApplicationMessageType(value: string): void; /** * Gets the application message type. This value is used by applications * only, and is passed through the API and Solace Message Router untouched. * @returns {string} The app