Created
May 9, 2017 15:21
-
-
Save arehmandev/6f5aff40091375f29fa8e8291f5e83a8 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
ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration( | |
InVMConnectorFactory.class.getName())); | |
// In this simple example, we just use one session for both producing and receiving | |
ClientSessionFactory factory = locator.createClientSessionFactory(); | |
ClientSession session = factory.createSession(); | |
// A producer is associated with an address ... | |
ClientProducer producer = session.createProducer("example"); | |
ClientMessage message = session.createMessage(true); | |
message.getBodyBuffer().writeString("Hello"); | |
// We need a queue attached to the address ... | |
session.createQueue("example", "example", true); | |
// And a consumer attached to the queue ... | |
ClientConsumer consumer = session.createConsumer("example"); | |
// Once we have a queue, we can send the message ... | |
producer.send(message); | |
// We need to start the session before we can -receive- messages ... | |
session.start(); | |
ClientMessage msgReceived = consumer.receive(); | |
System.out.println("message = " + msgReceived.getBodyBuffer().readString()); | |
session.close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment