import ballerina/jms;
import ballerina/log;
jms:Connection jmsConnection = new ({
initialContextFactory: "wso2mbInitialContextFactory",
providerUrl: "amqp://admin:admin@carbon/carbon?brokerlist='tcp://localhost:5672'"
});
jms:Session jmsSession = new (jmsConnection, {
acknowledgementMode: "AUTO_ACKNOWLEDGE"
});endpoint jms:QueueSender queueSender {
session: jmsSession,
queueName: "MyQueue"
};public function main (string[] args) {
jms:Message m = check jmsSession.createTextMessage("Test Text");
var _ = queueSender -> send(m);
}
JMS Queue Message ProducerThis example shows you how to publish a message to a queue using a JMS publisher. |
|
import ballerina/jms;
import ballerina/log;
|
|
jms:Connection jmsConnection = new ({
initialContextFactory: "wso2mbInitialContextFactory",
providerUrl: "amqp://admin:admin@carbon/carbon?brokerlist='tcp://localhost:5672'"
});
|
Initialize a JMS connection with the provider |
jms:Session jmsSession = new (jmsConnection, {
acknowledgementMode: "AUTO_ACKNOWLEDGE"
});
|
Initialize a JMS session on top of the created connection |
endpoint jms:QueueSender queueSender {
session: jmsSession,
queueName: "MyQueue"
};
|
|
public function main (string[] args) {
|
|
jms:Message m = check jmsSession.createTextMessage("Test Text");
|
Create a Text message. |
var _ = queueSender -> send(m);
}
|
Send the Ballerina message to the JMS provider. |
$ ballerina run jms-queue-message-producer.bal
|
To run the program, put the code in |