This examples shows how to setup and run an embedded JMS server using ActiveMQ along with ActiveMQ configuration files.
To run the example, simply type mvn verify -Pexample
from this directory
EmbeddedJMS jmsServer = new EmbeddedJMS();
jmsServer.start();
At this point the JMS server is started and any JMS clients can look up JMS resources from the JNDI to send/receive messages from the server. To keep the example simple, we will send and receive a JMS message from the same JVM used to run the JMS server.
ConnectionFactory cf = (ConnectionFactory)context.lookup("/cf");
Queue queue = (Queue)context.lookup("/queue/queue1");
See the Queue Example for detailed steps to send and receive a JMS message
Finally, we stop the JMS server and its associated resources.
jmsServer.stop();
naming.stop();
jndiServer.stop();