Hi,

I am trying to send one String message to ActiveMQ JMS queue using JAVA
application, but it's not showing in JMS queue.

my JAVA client program is as follows:-

import javax.jms.Connection;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQQueue;


public class JMSClient {

        private static final String MESSAGE_1 = "<hello id='1' />";
        private static final String MESSAGE_2 = "<hello id='2' />";
        private static final String MESSAGE_3 = "<hello id='3' />";
        private static final String MESSAGE_4 = "<hello id='4' />";
        private static final long WAIT_TIME = 5 * 1000L;

        
    public static void main(String[] args) throws Exception {
        message m = new message();
        ActiveMQConnectionFactory factory = new
ActiveMQConnectionFactory("tcp://localhost:61616");

        ActiveMQQueue pubTopic = new ActiveMQQueue("queue/A");
        ActiveMQQueue subTopic = new ActiveMQQueue("queue/B");
        
        System.out.println("Connecting to JMS server.");
        Connection connection = factory.createConnection();
        Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
        MessageProducer producer = session.createProducer(pubTopic);
        MessageConsumer consumer = session.createConsumer(subTopic);
        connection.start();

        System.out.println("Sending request: " + MESSAGE_1);
       
        
    producer.send(session.createTextMessage(MESSAGE_1));

                synchronized(Thread.currentThread()){
                        System.out.println("Waiting " + WAIT_TIME + " millis 
before next
message...");
                        Thread.currentThread().wait(WAIT_TIME);
                }

        System.out.println("Sending request: " + MESSAGE_2);
        producer.send(session.createTextMessage(MESSAGE_2));

                synchronized(Thread.currentThread()){
                        System.out.println("Waiting " + WAIT_TIME + " millis 
before next
message...");
                        Thread.currentThread().wait(WAIT_TIME);
                }

        System.out.println("Sending request: " + MESSAGE_3);
        producer.send(session.createTextMessage(MESSAGE_3));

                synchronized(Thread.currentThread()){
                        System.out.println("Waiting " + WAIT_TIME + " millis 
before next
message...");
                        Thread.currentThread().wait(WAIT_TIME);
                }

        System.out.println("Sending request: " + MESSAGE_4);
        producer.send(session.createTextMessage(MESSAGE_4));

        System.out.println("Closing.");
        connection.close();
    }
}



I am trying to access those message in ActiveMQ console, but it's not there.
please give some suggestion how to solve this problem.


Thanks,
Manish


-- 
View this message in context: 
http://www.nabble.com/problem-while-sending-message-to-ActiveMQ-JMS-queue-tp20380069p20380069.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to