How to Receive a Message from an Apache ActiveMQ Queue with JMS

import static java.lang.System.out;

import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.Session;

import org.apache.activemq.ActiveMQConnectionFactory;

public final class ActiveMQSample {

  public static void main(final String[] args) throws Exception {
    final ConnectionFactory connFactory = new ActiveMQConnectionFactory();

    final Connection conn = connFactory.createConnection();

    final Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);

    final Destination dest = sess.createQueue("SampleQueue");

    final MessageConsumer cons = sess.createConsumer(dest);


    final Message msg = cons.receive();




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.