ballerina/jms module
Module overview
The ballerina/jms
module provides an API to connect to an external JMS provider like Ballerina Message Broker or
ActiveMQ.
The module provides consumer and producer endpoint types for queues and topics. Following are the endpoint types supported by this module:
- QueueReceiver
- TopicSubscriber
- DurableTopicSubscriber
- SimpleQueueReceiver
- SimpleTopicSubscriber
- SimpleDurableTopicSubscriber
- QueueSender
- TopicPublisher
- SimpleQueueSender
- SimpleTopicPublisher
The endpoints prefixed with Simple
will automatically create a JMS connection and a JMS session when the endpoint is
initialized. For other endpoints, the developer must explicitly provide a properly initialized JMS Session.
Samples
JMS Simple Queue Consumer
Following is a simple listener program that consumes messages from a Ballerina Message Broker queue named MyQueue
.
import ballerina/jms;
import ballerina/log;
// Create a simple queue receiver.
listener jms:SimpleQueueReceiver consumerEP = new({
initialContextFactory: "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory",
providerUrl: "tcp://localhost:61616",
acknowledgementMode: "AUTO_ACKNOWLEDGE",
queueName: "MyQueue"
});
// Bind the created consumer to the listener service.
service jmsListener on consumerEP {
// The `OnMessage` resource gets invoked when a message is received.
resource function onMessage(jms:QueueReceiverCaller consumer, jms:Message message) {
var msg = message.getTextMessageContent();
if (msg is string) {
log:printInfo("Message : " + msg);
} else {
log:printError("Error occurred while reading message", err = msg);
}
}
}
JMS Simple Topic publisher.
Following is a simple topic publisher program that sends messages to a Ballerina Message Broker topic named MyTopic
.
import ballerina/jms;
import ballerina/log;
// Create a topic publisher.
jms:SimpleTopicPublisher topicPublisher = new({
initialContextFactory: "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory",
providerUrl: "tcp://localhost:61616",
acknowledgementMode: "AUTO_ACKNOWLEDGE",
topicPattern: "BallerinaTopic"
});
public function main(string... args) {
// Create a text message.
var msg = topicPublisher.session.createTextMessage("Hello from Ballerina");
if (msg is jms:Message) {
var result = topicPublisher->send(msg);
if (result is error) {
log:printError("Error occurred while sending message", err = result);
}
} else {
log:printError("Error occurred while creating message", err = msg);
}
}
JMS Queue Message Receiver
Following is a listener program that explicitly initializes a JMS session to be used in the consumer.
import ballerina/jms;
import ballerina/log;
// Initialize a JMS connection with the provider.
jms:Connection conn = new({
initialContextFactory: "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory",
providerUrl: "tcp://localhost:61616"
});
// Initialize a JMS session on top of the created connection.
jms:Session jmsSession = new(conn, {
// An optional property that defaults to `AUTO_ACKNOWLEDGE`.
acknowledgementMode: "AUTO_ACKNOWLEDGE"
});
// Initialize a queue receiver using the created session.
listener jms:QueueReceiver consumerEP = new(jmsSession, queueName = "MyQueue");
// Bind the created consumer to the listener service.
service jmsListener on consumerEP {
// The `OnMessage` resource gets invoked when a message is received.
resource function onMessage(jms:QueueReceiverCaller consumer, jms:Message message) {
// Retrieve the text message.
var msg = message.getTextMessageContent();
if (msg is string) {
log:printInfo("Message : " + msg);
} else {
log:printError("Error occurred while reading message", err = msg);
}
}
}
JMS Queue Message Producer
Following is a queue sender program that explicitly initializes a JMS session to be used in the producer.
import ballerina/jms;
import ballerina/log;
// Initialize a JMS connection with the provider.
jms:Connection jmsConnection = new({
initialContextFactory: "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory",
providerUrl: "tcp://localhost:61616"
});
// Initialize a JMS session on top of the created connection.
jms:Session jmsSession = new(jmsConnection, {
acknowledgementMode: "AUTO_ACKNOWLEDGE"
});
jms:QueueSender queueSender = new(jmsSession, queueName = "MyQueue");
public function main(string... args) {
// Create a text message.
var msg = jmsSession.createTextMessage("Hello from Ballerina");
if (msg is error) {
log:printError("Error occurred while creating message", err = msg);
} else {
var result = queueSender->send(msg);
if (result is error) {
log:printError("Error occurred while sending message", err = result);
}
}
}
JMS Topic Subscriber
Following is a topic subscriber program that subscribes to a particular JMS topic.
import ballerina/jms;
import ballerina/log;
jms:Connection conn = new({
initialContextFactory: "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory",
providerUrl: "tcp://localhost:61616"
});
jms:Session jmsSession = new(conn, {
acknowledgementMode: "AUTO_ACKNOWLEDGE"
});
listener jms:TopicSubscriber subscriberEndpoint = new(jmsSession, topicPattern = "MyTopic");
service jmsListener on subscriberEndpoint {
resource function onMessage(jms:TopicSubscriberCaller subscriber, jms:Message message) {
var msg = message.getTextMessageContent();
if (msg is string) {
log:printInfo("Message : " + msg);
} else {
log:printError("Error occurred while reading message", err = msg);
}
}
}
JMS Topic Producer
Following is a topic producer program that publishes to a particular JMS topic.
import ballerina/jms;
import ballerina/log;
jms:Connection jmsConnection = new({
initialContextFactory: "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory",
providerUrl: "tcp://localhost:61616"
});
jms:Session jmsSession = new(jmsConnection, {
acknowledgementMode: "AUTO_ACKNOWLEDGE"
});
jms:TopicPublisher topicPublisher = new(jmsSession, topicPattern = "MyTopic");
public function main(string... args) {
var msg = jmsSession.createTextMessage("Hello from Ballerina");
if (msg is error) {
log:printError("Error occurred while creating message", err = msg);
} else {
var result = topicPublisher->send(msg);
if (result is error) {
log:printError("Error occurred while sending message", err = result);
}
}
}
Type Definitions
Type | Values | Description | |
---|---|---|---|
DestinationType | topic | queue | Defines the possible values for the destination type in JMS
|
Records Summary
Record | Description | ||
---|---|---|---|
ConnectionConfiguration | Configurations related to a JMS connection | ||
ConsumerEndpointConfiguration | Configurations related to a JMS consumer object | ||
ReceiverEndpointConfiguration | Configuration related to simple topic subscriber endpoint | ||
SenderEndpointConfiguration | Configurations related to the sender | ||
SessionConfiguration | Configurations related to a JMS session |
Objects Summary
Object | Description | ||
---|---|---|---|
Connection | Represents JMS Connection |
||
Consumer | JMS consumer service object. This has the capability to bind multiple types of JMS consumer endpoints. |
||
ConsumerActions | JMS consumer action handling object |
||
ConsumerTemplate | Represent a JMS consumer endpoint |
||
Destination | Destination object |
||
DurableTopicSubscriber | JMS DurableTopicSubscriber endpoint |
||
Message | Represent the JMS message used to send and receive content from the a JMS provider. Most message-oriented middleware (MOM) products treat messages as lightweight entities that consist of a header and a body. The header contains fields used for message routing and identification; the body contains the application data being sent. |
||
QueueReceiver | Queue Receiver endpoint |
||
Session | Represents JMS session |
||
TopicSubscriber | JMS TopicSubscriber endpoint |
Endpoints Summary
Endpoint | Description | ||
---|---|---|---|
DurableTopicSubscriberCaller | Caller actions related to DurableTopicSubscriber endpoint |
||
QueueReceiverCaller | Caller actions related to queue receiver endpoint. |
||
QueueSender | JMS QueueSender Endpoint |
||
TopicPublisher | JMS TopicPublisher endpoint |
||
TopicSubscriberCaller | Remote functions that topic subscriber endpoint could perform |
Constants
Name | Data Type | Value | Description | |
---|---|---|---|---|
QUEUE | queue | Constant for JMS destination type queue |
||
TOPIC | topic | Constant for JMS destination type topic |
||
JMS_ERROR_CODE | string | {ballerina/jms}JMSError |
public type ConnectionConfiguration record
Configurations related to a JMS connection
Field Name | Data Type | Default Value | Description |
---|---|---|---|
initialContextFactory | string | wso2mbInitialContextFactory | JMS provider specific inital context factory |
providerUrl | string | amqp://admin:admin@ballerina/default?brokerlist='tcp://localhost:5672' | JMS provider specific provider URL used to configure a connection |
connectionFactoryName | string | ConnectionFactory | JMS connection factory to be used in creating JMS connections |
username | string? | () | Username for the JMS connection |
password | string? | () | Password for the JMS connection |
properties | map | {} | Additional properties use in initializing the initial context |
public type ConsumerEndpointConfiguration record
Configurations related to a JMS consumer object
Field Name | Data Type | Default Value | Description |
---|---|---|---|
session | jms:Session? | () | JMS session used to create the consumer |
identifier | string | Unique identifier of the consumer |
public type ReceiverEndpointConfiguration record
Configuration related to simple topic subscriber endpoint
Field Name | Data Type | Default Value | Description |
---|---|---|---|
initialContextFactory | string | bmbInitialContextFactory | JMS provider specific inital context factory |
providerUrl | string | amqp://admin:admin@ballerina/default?brokerlist='tcp://localhost:5672' | JMS provider specific provider URL used to configure a connection |
connectionFactoryName | string | ConnectionFactory | JMS connection factory to be used in creating JMS connections |
acknowledgementMode | string | AUTO_ACKNOWLEDGE | Specifies the session mode that will be used. Legal values are "AUTO_ACKNOWLEDGE", "CLIENT_ACKNOWLEDGE", "SESSION_TRANSACTED" and "DUPS_OK_ACKNOWLEDGE" |
properties | map | {} | Additional properties used when initializing the initial context |
public type SenderEndpointConfiguration record
Configurations related to the sender
Field Name | Data Type | Default Value | Description |
---|---|---|---|
initialContextFactory | string | bmbInitialContextFactory | JMS provider specific inital context factory |
providerUrl | string | amqp://admin:admin@ballerina/default?brokerlist='tcp://localhost:5672' | JMS provider specific provider URL used to configure a connection |
connectionFactoryName | string | ConnectionFactory | JMS connection factory to be used in creating JMS connections |
acknowledgementMode | string | AUTO_ACKNOWLEDGE | Specifies the session mode that will be used. Legal values are "AUTO_ACKNOWLEDGE", "CLIENT_ACKNOWLEDGE", "SESSION_TRANSACTED" and "DUPS_OK_ACKNOWLEDGE" |
properties | map | {} | Additional properties used when initializing the initial context |
public type SessionConfiguration record
Configurations related to a JMS session
Field Name | Data Type | Default Value | Description |
---|---|---|---|
acknowledgementMode | string | AUTO_ACKNOWLEDGE | specifies the session mode that will be used. Legal values are "AUTO_ACKNOWLEDGE", "CLIENT_ACKNOWLEDGE", "SESSION_TRANSACTED" and "DUPS_OK_ACKNOWLEDGE" |
public type Connection object
Represents JMS Connection
Field Name | Data Type | Default Value | Description |
---|---|---|---|
config | jms:ConnectionConfiguration | {} | Used to store configurations related to a JMS Connection |
-
<Connection> __init(jms:ConnectionConfiguration c)
JMS Connection constructor
Parameter Name Data Type Default Value Description c jms:ConnectionConfiguration -
<Connection> start()
Starts (or restarts) a connection's delivery of incoming messages. A call to start on a connection that has already been started is ignored.
-
<Connection> stop()
Temporarily stops a connection's delivery of incoming messages. Delivery can be restarted using the connection's start method.
public type Consumer object
JMS consumer service object. This has the capability to bind multiple types of JMS consumer endpoints.
-
<Consumer> getEndpoint() returns (ConsumerTemplate)
Returns the endpoint bound to service
Return Type Description ConsumerTemplate JMS consumer endpoint bound to the service
public type ConsumerActions object
JMS consumer action handling object
-
<ConsumerActions> acknowledge(jms:Message message) returns (error<>|null)
Acknowledge the received message to JMS provider. This should be used only with acknowledgment modes which require explicit acknowledgements like CLIENT_ACKNOWLEDGMENT.
Parameter Name Data Type Default Value Description message jms:Message incoming message
Return Type Description error<>|null error upon failure to acknowledge the received message to JMS provider.
public type ConsumerTemplate object
Represent a JMS consumer endpoint
Field Name | Data Type | Default Value | Description |
---|---|---|---|
consumerActions | jms:ConsumerActions | BLangTypeInit: new null ([]) | Handle all the actions related to the endpoint |
config | jms:ConsumerEndpointConfiguration | {} | Used to store configurations related to a JMS connection |
-
<ConsumerTemplate> init(jms:ConsumerEndpointConfiguration c)
Initialize the consumer endpoint
Parameter Name Data Type Default Value Description c jms:ConsumerEndpointConfiguration Configurations related to the endpoint
-
<ConsumerTemplate> register(typedesc serviceType)
Registers consumer endpoint in the service
Parameter Name Data Type Default Value Description serviceType typedesc type descriptor of the service
-
<ConsumerTemplate> start()
Starts the consumer endpoint
-
<ConsumerTemplate> stop()
Stops the consumer endpoint
-
<ConsumerTemplate> getCallerActions() returns (ConsumerActions)
Returns the action object of ConsumerTemplate
Return Type Description ConsumerActions Returns consumer actions
public type Destination object
Destination object
Field Name | Data Type | Default Value | Description |
---|---|---|---|
destinationName | string | Name of the destination |
|
destinationType | string | Type of the destination, either queue or topic |
public type DurableTopicSubscriber object
JMS DurableTopicSubscriber endpoint
Field Name | Data Type | Default Value | Description |
---|---|---|---|
consumerActions | jms:DurableTopicSubscriberCaller | BLangTypeInit: new null ([]) | Object that handles network operations related to the subscriber |
session | jms:Session? | Session of the topic subscriber |
-
<DurableTopicSubscriber> __init(jms:Session|jms:ReceiverEndpointConfiguration c, string topicPattern, string identifier, string messageSelector)
Initialize DurableTopicSubscriber endpoint.
Parameter Name Data Type Default Value Description c jms:Session|jms:ReceiverEndpointConfiguration The JMS Session object or Configurations related to the receiver
topicPattern string Name or the pattern of the topic subscription
identifier string Unique identifier for the subscription
messageSelector string JMS selector statement
-
<DurableTopicSubscriber> __attach(service serviceType, string? name) returns (error<>|null)
Binds the durable topic subscriber endpoint to a service
Parameter Name Data Type Default Value Description serviceType service Type descriptor of the service
name string? () The name of the service
Return Type Description error<>|null Nil or error upon failure to register listener
-
<DurableTopicSubscriber> __start() returns (error<>|null)
Starts the endpoint. Function is ignored by the subscriber endpoint
Return Type Description error<>|null Nil or error upon failure to start
-
<DurableTopicSubscriber> getCallerActions() returns (DurableTopicSubscriberCaller)
Return the subscrber caller actions
Return Type Description DurableTopicSubscriberCaller DurableTopicSubscriber actions handler
-
<DurableTopicSubscriber> __stop() returns (error<>|null)
Ends consuming messages from the DurableTopicSubscriber endpoint
Return Type Description error<>|null Nil or error upon failure to close subscriber
public type Message object
Represent the JMS message used to send and receive content from the a JMS provider.
Most message-oriented middleware (MOM) products treat messages as lightweight entities that consist of a header and a body. The header contains fields used for message routing and identification; the body contains the application data being sent.
-
<Message> getTextMessageContent() returns (string|error<>)
Gets text content of the JMS message
Return Type Description string|error<> The string containing this message's data or a JMS error
-
<Message> getMapMessageContent() returns (map<any>|error<>)
Gets map content of the JMS message
Return Type Description map |error<> The string containing this message's data or a JMS error
-
<Message> setStringProperty(string key, string value) returns (error<>|null)
Sets a JMS transport string property from the message
Parameter Name Data Type Default Value Description key string The string property name
value string The string property value
Return Type Description error<>|null Nil or a JMS error
-
<Message> getStringProperty(string key) returns (string|error<>|null)
Gets a JMS transport string property from the message
Parameter Name Data Type Default Value Description key string The string property name
Return Type Description string|error<>|null The string property value, JMS error or nil if there is no property by this name
-
<Message> setIntProperty(string key, int value) returns (error<>|null)
Sets a JMS transport integer property from the message
Parameter Name Data Type Default Value Description key string The integer property name
value int The integer property value
Return Type Description error<>|null Nil or a JMS error
-
<Message> getIntProperty(string key) returns (int|error<>)
Gets a JMS transport integer property from the message
Parameter Name Data Type Default Value Description key string The integer property name
Return Type Description int|error<> The integer property value or JMS error
-
<Message> setBooleanProperty(string key, boolean value) returns (error<>|null)
Sets a JMS transport boolean property from the message
Parameter Name Data Type Default Value Description key string The boolean property name
value boolean The boolean property value
Return Type Description error<>|null Nil or a JMS error
-
<Message> getBooleanProperty(string key) returns (boolean|error<>)
Gets a JMS transport boolean property from the message
Parameter Name Data Type Default Value Description key string The boolean property name
Return Type Description boolean|error<> The boolean property value or JMS error
-
<Message> setFloatProperty(string key, float value) returns (error<>|null)
Sets a JMS transport float property from the message
Parameter Name Data Type Default Value Description key string The float property name
value float The float property value
Return Type Description error<>|null Nil or a JMS error
-
<Message> getFloatProperty(string key) returns (float|error<>)
Gets a JMS transport float property from the message
Parameter Name Data Type Default Value Description key string The float property name
Return Type Description float|error<> The float property value or JMS error
-
<Message> getMessageID() returns (string|error<>)
Gets JMS transport header MessageID from the message
Return Type Description string|error<> The header value or JMS error
-
<Message> getTimestamp() returns (int|error<>)
Gets JMS transport header Timestamp from the message
Return Type Description int|error<> The timestamp header value or JMS error
-
<Message> setDeliveryMode(int mode) returns (error<>|null)
Sets DeliveryMode JMS transport header to the message
Parameter Name Data Type Default Value Description mode int The header value
Return Type Description error<>|null nil or a JMS error
-
<Message> getDeliveryMode() returns (int|error<>)
Get JMS transport header DeliveryMode from the message
Return Type Description int|error<> The delivery mode header value or JMS error
-
<Message> setExpiration(int value) returns (error<>|null)
Sets Expiration JMS transport header to the message
Parameter Name Data Type Default Value Description value int The header value
Return Type Description error<>|null nil or a JMS error
-
<Message> getExpiration() returns (int|error<>)
Gets JMS transport header Expiration from the message
Return Type Description int|error<> The expiration header value or JMS error
-
<Message> setType(string messageType) returns (error<>|null)
Sets Type JMS transport header to the message
Parameter Name Data Type Default Value Description messageType string The message type header value
Return Type Description error<>|null nil or an JMS error if any JMS provider level internal error occur
-
<Message> getType() returns (string|error<>)
Gets JMS transport header Type from the message
Return Type Description string|error<> The JMS message type header value or JMS error
-
<Message> clearProperties() returns (error<>|null)
Clears JMS properties of the message
Return Type Description error<>|null nil or error if any JMS provider level internal error occur
-
<Message> clearBody() returns (error<>|null)
Clears body of the JMS message
Return Type Description error<>|null nil or a JMS error
-
<Message> setPriority(int value) returns (error<>|null)
Sets priority JMS transport header to the message
Parameter Name Data Type Default Value Description value int The header value
Return Type Description error<>|null nil or a JMS error
-
<Message> getPriority() returns (int|error<>)
Gets JMS transport header Priority from the message
Return Type Description int|error<> The JMS priority header value or error
-
<Message> getRedelivered() returns (boolean|error<>)
Gets JMS transport header Redelivered from the message
Return Type Description boolean|error<> The JMS redelivered header value or JMS error
-
<Message> setCorrelationID(string value) returns (error<>|null)
Sets CorrelationID JMS transport header to the message
Parameter Name Data Type Default Value Description value string The header value
Return Type Description error<>|null nil or a JMS error
-
<Message> getCorrelationID() returns (string|error<>|null)
Gets JMS transport header CorrelationID from the message
Return Type Description string|error<>|null The JMS correlation ID header value or JMS error or nil if header is not set
-
<Message> getReplyTo() returns (Destination|error<>|null)
Gets JMS replyTo header from the message
Return Type Description Destination|error<>|null The JMS replyTo Destination or JMS error or nil if header is not set
-
<Message> setReplyTo(jms:Destination replyTo) returns (error<>|null)
Set the replyTo destination from the message
Parameter Name Data Type Default Value Description replyTo jms:Destination replyTo destination.
Return Type Description error<>|null nil or JMS error
public type QueueReceiver object
Queue Receiver endpoint
Field Name | Data Type | Default Value | Description |
---|---|---|---|
consumerActions | jms:QueueReceiverCaller | BLangTypeInit: new null ([]) | handles all the caller actions related to the QueueReceiver endpoint |
session | jms:Session | Session of the queue receiver |
|
messageSelector | string | The message selector for the queue receiver |
|
identifier | string | Unique identifier for the reciever |
-
<QueueReceiver> __init(jms:Session|jms:ReceiverEndpointConfiguration c, string? queueName, string messageSelector, string identifier)
Initializes the QueueReceiver endpoint
Parameter Name Data Type Default Value Description c jms:Session|jms:ReceiverEndpointConfiguration The JMS Session object or Configurations related to the receiver
queueName string? () Name of the queue
messageSelector string The message selector for the queue
identifier string Unique identifier for the receiver
-
<QueueReceiver> __attach(service serviceType, string? name) returns (error<>|null)
Binds the queue receiver endpoint to a service
Parameter Name Data Type Default Value Description serviceType service The service instance
name string? () Name of the service
Return Type Description error<>|null Nil or error upon failure to register listener
-
<QueueReceiver> __start() returns (error<>|null)
Starts the endpoint
Return Type Description error<>|null Nil or error upon failure to start
-
<QueueReceiver> getCallerActions() returns (QueueReceiverCaller)
Retrieves the QueueReceiver consumer action handler
Return Type Description QueueReceiverCaller QueueReceiver actions handler
-
<QueueReceiver> __stop() returns (error<>|null)
Stops consuming messages through QueueReceiver endpoint
Return Type Description error<>|null Nil or error upon failure to close queue receiver
public type Session object
Represents JMS session
-
<Session> __init(jms:Connection connection, jms:SessionConfiguration c)
Default constructor of the JMS session
Parameter Name Data Type Default Value Description connection jms:Connection c jms:SessionConfiguration -
<Session> createTextMessage(string content) returns (Message|error<>)
Creates a JMS message which holds text content
Parameter Name Data Type Default Value Description content string the text content used to initialize this message
Return Type Description Message|error<> a text message or error in case of errors
-
<Session> createMapMessage(map content) returns (Message|error<>)
Creates a JMS message which holds Map content
Parameter Name Data Type Default Value Description content map the Map content used to initialize this message
Return Type Description Message|error<> a map message or error incase of errors
-
<Session> unsubscribe(string subscriptionId) returns (error<>|null)
Unsubscribes a durable subscription that has been created by a client. It is erroneous for a client to delete a durable subscription while there is an active (not closed) consumer for the subscription, or while a consumed message is part of a pending transaction or has not been acknowledged in the session.
Parameter Name Data Type Default Value Description subscriptionId string the name used to identify this subscription
Return Type Description error<>|null Cancel subscription
-
<Session> createTemporaryQueue() returns (Destination|error<>)
Creates a JMS Queue which can be used as temporary response destination.
Return Type Description Destination|error<> JMS destination for a temporary queue or error if fails
-
<Session> createTemporaryTopic() returns (Destination|error<>)
Creates a JMS Topic which can be used as temporary response destination.
Return Type Description Destination|error<> JMS destination for a temporary topic or error if fails
-
<Session> createQueue(string queueName) returns (Destination|error<>)
Creates a JMS Queue which can be used with a message producer.
Parameter Name Data Type Default Value Description queueName string name of the Queue
Return Type Description Destination|error<> JMS destination for a queue or error if fails
-
<Session> createTopic(string topicName) returns (Destination|error<>)
Creates a JMS Topic which can be used with a message producer.
Parameter Name Data Type Default Value Description topicName string name of the Topic
Return Type Description Destination|error<> JMS destination for a topic or error if fails
public type TopicSubscriber object
JMS TopicSubscriber endpoint
Field Name | Data Type | Default Value | Description |
---|---|---|---|
consumerActions | jms:TopicSubscriberCaller | BLangTypeInit: new null ([]) | Handles all the caller actions related to the TopicSubscriber endpoint |
session | jms:Session | Session of the topic subscriber |
|
messageSelector | string | The message selector for the topic subscriber |
-
<TopicSubscriber> __init(jms:Session|jms:ReceiverEndpointConfiguration c, string? topicPattern, string messageSelector)
Initialize the TopicSubscriber endpoint
Parameter Name Data Type Default Value Description c jms:Session|jms:ReceiverEndpointConfiguration The JMS Session object or Configurations related to the receiver
topicPattern string? () Name or the pattern of the topic subscription
messageSelector string JMS selector statement
-
<TopicSubscriber> __attach(service serviceType, string? name) returns (error<>|null)
Register TopicSubscriber endpoint
Parameter Name Data Type Default Value Description serviceType service The service instance
name string? () Name of the service
Return Type Description error<>|null Nil or error upon failure to register listener
-
<TopicSubscriber> __start() returns (error<>|null)
Start TopicSubscriber endpoint
Return Type Description error<>|null Nil or error upon failure to start
-
<TopicSubscriber> getCallerActions() returns (TopicSubscriberCaller)
Get TopicSubscriber actions handler
Return Type Description TopicSubscriberCaller TopicSubscriber actions handler
-
<TopicSubscriber> __stop() returns (error<>|null)
Stop TopicSubscriber endpoint
Return Type Description error<>|null Nil or error upon failure to close subscriber
Endpoint DurableTopicSubscriberCaller
Caller actions related to DurableTopicSubscriber endpoint
-
<DurableTopicSubscriberCaller> acknowledge(jms:Message message) returns (error<>|null)
Acknowledges a received message
Parameter Name Data Type Default Value Description message jms:Message JMS message to be acknowledged
Return Type Description error<>|null Error upon failure to acknowledge the received message
-
<DurableTopicSubscriberCaller> receive(int timeoutInMilliSeconds) returns (Message|error<>|null)
Synchronously receive a message from the JMS provider
Parameter Name Data Type Default Value Description timeoutInMilliSeconds int 0 Time to wait until a message is received
Return Type Description Message|error<>|null Returns a message or nil if the timeout exceeds, returns an error upon JMS provider internal error
Endpoint QueueReceiverCaller
Caller actions related to queue receiver endpoint.
Field Name | Data Type | Default Value | Description |
---|---|---|---|
queueReceiver | jms:QueueReceiver? | () | queue receiver endpoint |
-
<QueueReceiverCaller> acknowledge(jms:Message message) returns (error<>|null)
Acknowledges a received message
Parameter Name Data Type Default Value Description message jms:Message JMS message to be acknowledged
Return Type Description error<>|null error upon failure to acknowledge the received message
-
<QueueReceiverCaller> receive(int timeoutInMilliSeconds) returns (Message|error<>|null)
Synchronously receive a message from the JMS provider
Parameter Name Data Type Default Value Description timeoutInMilliSeconds int 0 time to wait until a message is received
Return Type Description Message|error<>|null Returns a message or nil if the timeout exceeds, returns an error on JMS provider internal error
-
<QueueReceiverCaller> receiveFrom(jms:Destination destination, int timeoutInMilliSeconds) returns (Message|error<>|null)
Synchronously receive a message from a given destination
Parameter Name Data Type Default Value Description destination jms:Destination destination to subscribe to
timeoutInMilliSeconds int 0 time to wait until a message is received
Return Type Description Message|error<>|null Returns a message or () if the timeout exceeds, returns an error on JMS provider internal error
Endpoint QueueSender
JMS QueueSender Endpoint
Field Name | Data Type | Default Value | Description |
---|---|---|---|
session | jms:Session? | Session of the queue sender |
-
<QueueSender> send(jms:Message message) returns (error<>|null)
Sends a message to the JMS provider
Parameter Name Data Type Default Value Description message jms:Message Message to be sent to the JMS provider
Return Type Description error<>|null Error if unable to send the message to the queue
-
<QueueSender> sendTo(jms:Destination destination, jms:Message message) returns (error<>|null)
Sends a message to a given destination of the JMS provider
Parameter Name Data Type Default Value Description destination jms:Destination Destination used for the message sender
message jms:Message Message to be sent to the JMS provider
Return Type Description error<>|null Error if sending to the given destination fails
Endpoint TopicPublisher
JMS TopicPublisher endpoint
Field Name | Data Type | Default Value | Description |
---|---|---|---|
session | jms:Session? | Session of the topic publisher |
-
<TopicPublisher> send(jms:Message message) returns (error<>|null)
Sends a message to the JMS provider
Parameter Name Data Type Default Value Description message jms:Message Message to be sent to the JMS provider
Return Type Description error<>|null Error upon failure to send the message to the JMS provider
-
<TopicPublisher> sendTo(jms:Destination destination, jms:Message message) returns (error<>|null)
Sends a message to the JMS provider
Parameter Name Data Type Default Value Description destination jms:Destination Destination used for the message sender
message jms:Message Message to be sent to the JMS provider
Return Type Description error<>|null Error upon failure to send the message to the JMS provider
Endpoint TopicSubscriberCaller
Remote functions that topic subscriber endpoint could perform
Field Name | Data Type | Default Value | Description |
---|---|---|---|
topicSubscriber | jms:TopicSubscriber? | () | JMS TopicSubscriber |
-
<TopicSubscriberCaller> acknowledge(jms:Message message) returns (error<>|null)
Acknowledges a received message
Parameter Name Data Type Default Value Description message jms:Message JMS message to be acknowledged
Return Type Description error<>|null error on failure to acknowledge a received message
-
<TopicSubscriberCaller> receive(int timeoutInMilliSeconds) returns (Message|error<>|null)
Synchronously receive a message from the JMS provider
Parameter Name Data Type Default Value Description timeoutInMilliSeconds int 0 Time to wait until a message is received
Return Type Description Message|error<>|null Returns a message or nil if the timeout exceeds, returns an error on JMS provider internal error.
-
<TopicSubscriberCaller> receiveFrom(jms:Destination destination, int timeoutInMilliSeconds) returns (Message|error<>|null)
Synchronously receive a message from the JMS provider
Parameter Name Data Type Default Value Description destination jms:Destination Destination to subscribe to
timeoutInMilliSeconds int 0 Time to wait until a message is received
Return Type Description Message|error<>|null Returns a message or nil if the timeout exceeds, returns an error on JMS provider internal error