-
-
Save ayeshLK/6737610b3703cf567fd749cee2f9fd47 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ballerinax/activemq.driver as _; | |
import ballerinax/java.jms; | |
public function main() returns error? { | |
jms:Connection connection = check new ( | |
initialContextFactory = "org.apache.activemq.jndi.ActiveMQInitialContextFactory", | |
providerUrl = "tcp://localhost:61616" | |
); | |
jms:Session session = check connection->createSession(); | |
jms:MessageConsumer consumer = check session.createConsumer(destination = { | |
'type: jms:QUEUE, | |
name: "test-queue" | |
}); | |
jms:Message? receivedMessage1 = check consumer->receive(); | |
if receivedMessage1 is jms:TextMessage { | |
// do something | |
} | |
jms:Message? receivedMessage2 = check consumer->receiveNoWait(); | |
if receivedMessage2 is jms:TextMessage { | |
// do something | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment