solace
Module solace
API
Declarations
Definitions
ballerinax/solace Ballerina library
Overview
Solace PubSub+ is an advanced event-broker platform that enables event-driven communication across distributed applications using multiple messaging patterns such as publish/subscribe, request/reply, and queue-based messaging. It supports standard messaging protocols, including JMS, MQTT, AMQP, and REST, enabling seamless integration across diverse systems and environments.
The ballerinax/solace package provides APIs to interact with Solace PubSub+ brokers through the JMS API. It allows developers to programmatically produce and consume messages, manage topics and queues, and implement robust, event-driven solutions that leverage Solace’s high-performance messaging capabilities within Ballerina applications.
Quickstart
Step 1: Import the module
Import the solace module into the Ballerina project.
import ballerinax/solace;
Step 2: Instantiate a new connector
Initialize a solace:MessageProducer
configurable string brokerUrl = ?; configurable string messageVpn = ?; configurable string queueName = ?; configurable string username = ?; configurable string password = ?; solace:MessageProducer producer = check new (brokerUrl, destination = { queueName }, messageVpn = messageVpn, auth = { username, password } );
Initialize a solace:MessageConsumer
configurable string brokerUrl = ?; configurable string messageVpn = ?; configurable string queueName = ?; configurable string username = ?; configurable string password = ?; solace:MessageConsumer consumer = check new (brokerUrl, destination = { queueName }, messageVpn = messageVpn, auth = { username, password } );
Step 3: Invoke the connector operation
Now, you can use the available connector operations to interact with Solace broker.
Produce message to a queue
check producer->send({ payload: "This is a sample message" });
Retrieve a message from a queue
solace:Message? receivedMessage = check consumer->receive(5.0);
Step 4: Run the Ballerina application
Save the changes and run the Ballerina application using the following command.
bal run
Clients
solace: Caller
Represents a Solace caller, which can be used to mark Solace message as received.
acknowledge
Mark a Solace message as received.
Parameters
- message Message - Solace message record
Return Type
- Error? -
solace:Errorif there is an error in the execution or else '()'
'commit
function 'commit() returns Error?Commits all messages received in this transaction and releases any locks currently held.
check session->'commit();
Return Type
- Error? - A
solace:Errorif there is an error or else()
'rollback
function 'rollback() returns Error?Rolls back any messages received in this transaction and releases any locks currently held.
check session->'rollback();
Return Type
- Error? - A
solace:Errorif there is an error or else()
solace: MessageConsumer
Solace Message Consumer to receive messages from both queues and topics.
Constructor
Initializes a new Solace message consumer with the given broker URL and configuration.
solace:MessageConsumer consumer = check new (brokerUrl, {
subscriptionConfig: {queueName: "orders"}
});
init (string url, *ConsumerConfiguration config)- url string - The Solace broker URL in the format
<scheme>://[username]:[password]@<host>[:port]. Supported schemes aresmf(plain-text) andsmfs(TLS/SSL). Multiple hosts can be specified as a comma-separated list for failover support. Default ports: 55555 (standard), 55003 (compression), 55443 (SSL)
- config *ConsumerConfiguration - Consumer configuration including connection settings and subscription details
receive
Receives the next message from the Solace broker, waiting up to the specified timeout.
solace:Message? message = check consumer->receive(5.0);
Parameters
- timeout decimal (default 10.0) - The maximum time to wait for a message in seconds. Default is 10.0 seconds
Return Type
receiveNoWait
Receives the next message from the Solace broker if one is immediately available, without waiting.
solace:Message? message = check consumer->receiveNoWait();
Return Type
acknowledge
Acknowledges the specified message. This method should only be called when the consumer is configured
with sessionAckMode: CLIENT_ACKNOWLEDGE.
check consumer->acknowledge(message);
Parameters
- message Message - The message to acknowledge
Return Type
- Error? - A
solace:Errorif there is an error or else()
'commit
function 'commit() returns Error?Commits all messages received in this transaction and releases any locks currently held.
This method should only be called when the consumer is configured with sessionAckMode: SESSION_TRANSACTED.
check consumer->'commit();
Return Type
- Error? - A
solace:Errorif there is an error or else()
'rollback
function 'rollback() returns Error?Rolls back any messages received in this transaction and releases any locks currently held.
This method should only be called when the consumer is configured with sessionAckMode: SESSION_TRANSACTED.
check consumer->'rollback();
Return Type
- Error? - A
solace:Errorif there is an error or else()
close
function close() returns Error?Closes the message consumer and releases all resources.
check consumer->close();
Return Type
- Error? - A
solace:Errorif there is an error or else()
solace: MessageProducer
Solace Message Producer to send messages to both queues and topics.
Constructor
Initializes a new Solace message producer with the given broker URL and configuration.
solace:MessageProducer producer = check new (brokerUrl, {
destination: {queueName: "orders"},
transacted: false
});
init (string url, *ProducerConfiguration config)- url string - The Solace broker URL in the format
<scheme>://[username]:[password]@<host>[:port]. Supported schemes aresmf(plain-text) andsmfs(TLS/SSL). Multiple hosts can be specified as a comma-separated list for failover support. Default ports: 55555 (standard), 55003 (compression), 55443 (SSL)
- config *ProducerConfiguration - Producer configuration including connection settings and destination
send
Sends a message to the Solace broker.
check producer->send(message);
Parameters
- message Message - Message to be sent to the Solace broker
Return Type
- Error? - A
solace:Errorif there is an error or else()
'commit
function 'commit() returns Error?Commits all messages sent in this transaction and releases any locks currently held.
This method should only be called when the producer is configured with transacted: true.
check producer->'commit();
Return Type
- Error? - A
solace:Errorif there is an error or else()
'rollback
function 'rollback() returns Error?Rolls back any messages sent in this transaction and releases any locks currently held.
This method should only be called when the producer is configured with transacted: true.
check producer->'rollback();
Return Type
- Error? - A
solace:Errorif there is an error or else()
close
function close() returns Error?Closes the message producer.
check producer->close();
Return Type
- Error? - A
solace:Errorif there is an error or else()
Service types
solace: Service
The Solace service type.
Constants
solace: ECDHE_RSA_3DES_EDE_CBC_SHA
Cipher suite: TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
solace: ECDHE_RSA_AES128_CBC_SHA
Cipher suite: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
solace: ECDHE_RSA_AES128_CBC_SHA256
Cipher suite: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
solace: ECDHE_RSA_AES256_CBC_SHA
Cipher suite: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
solace: ECDHE_RSA_AES256_CBC_SHA384
Cipher suite: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
solace: JKS
Java KeyStore format
solace: PKCS12
PKCS12 format
solace: RSA_3DES_EDE_CBC_SHA
Cipher suite: SSL_RSA_WITH_3DES_EDE_CBC_SHA
solace: RSA_AES128_CBC_SHA
Cipher suite: TLS_RSA_WITH_AES_128_CBC_SHA
solace: RSA_AES128_CBC_SHA256
Cipher suite: TLS_RSA_WITH_AES_128_CBC_SHA256
solace: RSA_AES256_CBC_SHA
Cipher suite: TLS_RSA_WITH_AES_256_CBC_SHA
solace: RSA_AES256_CBC_SHA256
Cipher suite: TLS_RSA_WITH_AES_256_CBC_SHA256
solace: SSLv30
SSL protocol version 3.0
solace: TLSv10
TLS protocol version 1.0
solace: TLSv11
TLS protocol version 1.1
solace: TLSv12
TLS protocol version 1.2
Enums
solace: AcknowledgementMode
Defines the JMS session acknowledgement modes.
Members
commit or rollback methods.receive or when
the message listener the session has called to process the message successfully returns.acknowledge method. Acknowledging a consumed message
acknowledges all messages that the session has consumed.solace: ConsumerType
Defines the supported JMS message consumer types.
Members
Listeners
solace: Listener
Represents a Solace listener endpoint that can be used to receive messages from a Solace topic or a queue.
Constructor
Initializes a new Solace message listener with the given broker URL and configuration.
listener solace:Listener messageListener = check new (
url = "smf://localhost:55554",
messageVpn = "default",
auth = {
username: "admin",
password: "admin"
}
);
init (string url, *ListenerConfiguration config)- url string - The Solace broker URL in the format
<scheme>://[username]:[password]@<host>[:port]. Supported schemes aresmf(plain-text) andsmfs(TLS/SSL). Multiple hosts can be specified as a comma-separated list for failover support. Default ports: 55555 (standard), 55003 (compression), 55443 (SSL)
- config *ListenerConfiguration - configurations used when initializing the listener
attach
Attaches a Solace service to the listener.
check messageListener.attach(solaceSvc);
Return Type
- Error? -
solace:Errorif an error occurs or()otherwise
detach
Detaches a Solace service from the listener.
check messageListener.detach(solaceSvc);
Parameters
- 'service Service - service instance
Return Type
- Error? -
solace:Errorif an error occurs or()otherwise
'start
function 'start() returns Error?Starts the listener.
check messageListener.'start();
Return Type
- Error? -
solace:Errorif an error occurs or()otherwise
gracefulStop
function gracefulStop() returns Error?Gracefully stops the listener.
check messageListener.gracefulStop();
Return Type
- Error? -
solace:Errorif an error occurs or()otherwise
immediateStop
function immediateStop() returns Error?Immediately stops the listener.
check messageListener.immediateStop();
Return Type
- Error? -
solace:Errorif an error occurs or()otherwise
Annotations
solace: ServiceConfig
Annotation to configure the solace:Service.
Records
solace: BasicAuthConfig
Represents the basic authentication credentials for connecting to a Solace broker.
Fields
- username string - The username for authentication
- password? string - The password for authentication
solace: ConsumerConfiguration
Represents the configuration for a Solace message consumer.
Fields
- messageVpn string -
- secureSocket SecureSocket -
- transacted boolean -
- clientId string -
- clientDescription string -
- allowDuplicateClientId boolean -
- enableDynamicDurables boolean -
- directTransport boolean -
- directOptimized boolean -
- localhost string -
- connectTimeout decimal -
- readTimeout decimal -
- compressionLevel int -
- retryConfig RetryConfig -
- anydata... -
- subscriptionConfig QueueConfig|TopicConfig - The subscription configuration specifying either a queue or topic to consume messages from
solace: KerberosConfig
Represents the Kerberos (GSS-KRB) authentication configuration for connecting to a Solace broker
Fields
- serviceName string(default "solace") - The Kerberos service name used during authentication
- jaasLoginContext string(default "SolaceGSS") - The JAAS login context name to use for authentication
- mutualAuthentication boolean(default true) - Specifies whether to enable Kerberos mutual authentication
- jaasConfigReloadEnabled boolean(default false) - Specifies whether to enable automatic reload of the JAAS configuration file
solace: KeyStore
Represents a key store containing the client's private key and certificate.
Fields
- location string - The URL or path of the keystore file
- password string - The password for the key store
- keyPassword? string - The password for the private key within the key store. If not specified, the key store password is used
- keyAlias? string - The alias of the private key to use from the key store. If not specified, the first private key found is used
- format SslStoreFormat(default JKS) - The format of the key store file
solace: ListenerConfiguration
Represents the listener configuration for Ballerina Solace listener.
Fields
- messageVpn string -
- secureSocket SecureSocket -
- transacted boolean -
- clientId string -
- clientDescription string -
- allowDuplicateClientId boolean -
- enableDynamicDurables boolean -
- directTransport boolean -
- directOptimized boolean -
- localhost string -
- connectTimeout decimal -
- readTimeout decimal -
- compressionLevel int -
- retryConfig RetryConfig -
- anydata... -
solace: Message
Represent the Message used to send and receive content from the Solace broker.
Fields
- correlationId? string - Id which can be used to correlate multiple messages
- replyTo? Destination - JMS destination to which a reply to this message should be sent
- messageId? string - Unique identifier for a JMS message (Only set by the JMS provider)
- timestamp? int - Time a message was handed off to a provider to be sent (Only set by the JMS provider)
- destination? Destination - JMS destination of this message (Only set by the JMS provider)
- deliveryMode? int - Delivery mode of this message (Only set by the JMS provider)
- redelivered? boolean - Indication of whether this message is being redelivered (Only set by the JMS provider)
- jmsType? string - Message type identifier supplied by the client when the message was sent
- expiration? int - Message expiration time (Only set by the JMS provider)
- priority? int - Message priority level (Only set by the JMS provider)
solace: OAuth2Config
Represents the OAuth 2.0 authentication configuration for connecting to a Solace broker
Fields
- issuer string - The OAuth 2.0 issuer identifier URI
- accessToken? string - The OAuth 2.0 access token for authentication
- oidcToken? string - The OpenID Connect (OIDC) ID token for authentication
solace: ProducerConfiguration
Represents the configuration for a Solace message producer.
Fields
- messageVpn string -
- secureSocket SecureSocket -
- transacted boolean -
- clientId string -
- clientDescription string -
- allowDuplicateClientId boolean -
- enableDynamicDurables boolean -
- directTransport boolean -
- directOptimized boolean -
- localhost string -
- connectTimeout decimal -
- readTimeout decimal -
- compressionLevel int -
- retryConfig RetryConfig -
- anydata... -
- destination Destination - The destination (Topic or Queue) where messages will be published
solace: Queue
Represents a queue destination for point-to-point messaging.
Fields
- queueName string - The name of the queue
solace: QueueConfig
Represents configurations for a Solace queue subscription.
Fields
- sessionAckMode AcknowledgementMode - Configuration indicating how messages received by the session will be acknowledged
- messageSelector string - Only messages with properties matching the message selector expression are delivered.
If this value is not set that indicates that there is no message selector for the message consumer
For example, to only receive messages with a property
priorityset to'high', use:"priority = 'high'". If this value is not set, all messages in the queue will be delivered.
- queueName string - The name of the queue to consume messages from
solace: QueueServiceConfig
Represents configurations for a service configurations related to solace queue subscription.
Fields
- pollingInterval decimal - The polling interval in seconds
- receiveTimeout decimal - The timeout to wait till a
receiveaction finishes when there are no messages
- sessionAckMode AcknowledgementMode -
- messageSelector string -
- queueName string - The name of the queue to consume messages from
solace: RetryConfig
Represents the retry configuration for connection and reconnection attempts to a Solace broker
Fields
- connectRetries int(default 0) - The number of times to retry connecting to the broker during initial connection. A value of -1 means retry forever, 0 means no retries (fail immediately on first failure)
- connectRetriesPerHost int(default 0) - The number of connection retries per host when multiple hosts are specified in the URL. This applies to each host in a comma-separated host list
- reconnectRetries int(default 20) - The number of times to retry reconnecting after an established connection is lost. A value of -1 means retry forever
- reconnectRetryWait decimal(default 3.0) - The time to wait between reconnection attempts, in seconds
solace: SecureSocket
Represents the SSL/TLS configuration for secure connections to a Solace broker
Fields
- trustStore? TrustStore - The trust store configuration containing trusted CA certificates
- keyStore? KeyStore - The key store configuration containing the client's private key and certificate. When configured, enables client certificate authentication
- protocols Protocol[](default [SSLv30, TLSv10, TLSv11, TLSv12]) - The list of SSL/TLS protocol versions to enable for the connection. It is recommended to use only TLSv12 or higher for security
- cipherSuites? SslCipherSuite[] - The list of cipher suites to enable for the connection. If not specified, the default cipher suites for the JVM are used
- trustedCommonNames? string[] - The list of acceptable common names for broker certificate validation. If specified, the broker certificate's common name must match one of these values
solace: Topic
Represents a topic destination for publish/subscribe messaging.
Fields
- topicName string - The name of the topic. Topics support wildcard subscriptions and multi-level hierarchies using '/' as a delimiter (e.g., "orders/retail/usa")
solace: TopicConfig
Represents configurations for Solace topic subscription.
Fields
- sessionAckMode AcknowledgementMode - Configuration indicating how messages received by the session will be acknowledged
- messageSelector string - Only messages with properties matching the message selector expression are delivered.
If this value is not set that indicates that there is no message selector for the message consumer
For example, to only receive messages with a property
priorityset to'high', use:"priority = 'high'". If this value is not set, all messages in the queue will be delivered.
- topicName string - The name of the topic to subscribe to
- consumerType ConsumerType(default DEFAULT) - The message consumer type
- subscriberName? string - the name used to identify the subscription
If this value is not set that indicates that there is no message selector for the message consumer
For example, to only receive messages with a property
priorityset to'high', use:"priority = 'high'". If this value is not set, all messages in the queue will be delivered.
- noLocal boolean(default false) - If true then any messages published to the topic using this session's connection, or any other connection with the same client identifier, will not be added to the durable subscription.
solace: TopicServiceConfig
Represents configurations for a service configurations related to solace topic subscription.
Fields
- pollingInterval decimal - The polling interval in seconds
- receiveTimeout decimal - The timeout to wait till a
receiveaction finishes when there are no messages
- sessionAckMode AcknowledgementMode -
- messageSelector string -
- topicName string - The name of the topic to subscribe to
- consumerType ConsumerType(default DEFAULT) - The message consumer type
- subscriberName? string - the name used to identify the subscription
If this value is not set that indicates that there is no message selector for the message consumer
For example, to only receive messages with a property
priorityset to'high', use:"priority = 'high'". If this value is not set, all messages in the queue will be delivered.
- noLocal boolean(default false) - If true then any messages published to the topic using this session's connection, or any other connection with the same client identifier, will not be added to the durable subscription.
solace: TrustStore
Represents a trust store containing trusted CA certificates.
Fields
- location string - The URL or path of the truststore file
- password string - The password for the trust store
- format SslStoreFormat(default JKS) - The format of the trust store file
Errors
solace: Error
Represents a Solace distinct error.
Union types
solace: ServiceConfiguration
ServiceConfiguration
The service configuration type for the solace:Service.
solace: Destination
Destination
Represents a message destination in Solace. Can be either a Topic for publish/subscribe messaging or a Queue for point-to-point messaging.
solace: Protocol
Protocol
Represents the supported SSL/TLS protocol versions.
solace: SslCipherSuite
SslCipherSuite
The SSL Cipher Suite to be used for secure communication with the Solace broker.
solace: Property
Property
Represent the valid value types allowed in JMS message properties.
solace: Value
Value
Represents the allowed value types for entries in the map content of a JMS MapMessage.
Import
import ballerinax/solace;Other versions
0.1.0
Metadata
Released date: 6 days ago
Version: 0.1.0
License: Apache-2.0
Compatibility
Platform: java21
Ballerina version: 2201.12.0
GraalVM compatible: Yes
Pull count
Total: 1
Current verison: 1
Weekly downloads
Keywords
solace
messaging
network
pubsub
Contributors