Here is the test message sender that I am using...

public class Sender {

    public static final String JMS_SERVER_URL = "tcp://127.0.0.1:61616";
    public static final String JMS_DEST = "example.A";
    private Session session;
    private MessageProducer producer;
    private Destination destination;

    public Sender() throws JMSException {

        ActiveMQConnectionFactory connFactory = new
ActiveMQConnectionFactory(JMS_SERVER_URL);

        QueueConnection connection = connFactory.createQueueConnection();
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        destination = session.createQueue(JMS_DEST);
        producer = session.createProducer(destination);
        connection.start();
    }

    public void sendData() throws JMSException {

        int i = 0;
        for(int j=0; j<10; j++){

            System.out.println("Sending message " + i);
            TextMessage message = session.createTextMessage("Header " + i);
            System.out.println("Destination = " + producer.getDestination());
            producer.send(message);

            try {
                Thread.sleep(200);
            } catch (InterruptedException ex) {

Logger.getLogger(Sender.class.getName()).log(Level.SEVERE, null, ex);
            }

            i++;
        }
    }

    public static void main(String[] args) throws JMSException {

        Sender sender = new Sender();
        sender.sendData();
    }
}



On Tue, Jun 29, 2010 at 12:38 PM, James Carman
<[email protected]> wrote:
> How are you sending your message?  Can we see that code?
>
> On Tue, Jun 29, 2010 at 11:46 AM, Mark <[email protected]> wrote:
>> I tried putting in a Thread.sleep(60*1000), but the messages still do
>> not show up in the listener.
>>
>>
>>
>> On Mon, Jun 28, 2010 at 7:16 PM, Willem Jiang <[email protected]> wrote:
>>> After you started the camel context, you need to use some sleep to avoid the
>>> main thread exits otherwise camel route will stop work,
>>>
>>> Willem
>>> ----------------------------------
>>> Apache Camel, Apache CXF committer
>>> Open SOA http://www.fusesource.com
>>> Blog http://willemjiang.blogspot.com
>>> Tiwtter http://twitter.com/willemjiang
>>>
>>> Mark wrote:
>>>>
>>>> Hello,
>>>>
>>>> I am working on creating a simple route using camel and java.  I have
>>>> the following code:
>>>>
>>>> public class CamelMain {
>>>>        public static void main(String[] args) throws Exception {
>>>>                CamelContext context = new DefaultCamelContext();
>>>>                ConnectionFactory connectionFactory = new
>>>> ActiveMQConnectionFactory("tcp://127.0.0.1:61616");
>>>>                context.addComponent("test-jms",
>>>> JmsComponent.jmsComponent(connectionFactory));
>>>>
>>>>                context.addRoutes(new RouteBuilder() {
>>>>                        public void configure() {
>>>>
>>>>  from("test-jms:queue:example.A").to("test-jms:queue:example.B");
>>>>                        }
>>>>                });
>>>>
>>>>                context.start();
>>>>        }
>>>> }
>>>>
>>>> When I go to the camel admin page (http://127.0.0.1:8161/camel), it
>>>> shows that the route has been created.  The problem is that when I try
>>>> and send a message to the "example.A" queue, it never seems to get
>>>> picked up by the MessageListener that is listening to the "example.B"
>>>> queue.  The sender and listener are running in separate JVM's if that
>>>> makes a difference.
>>>>
>>>> Where am I going wrong?
>>>>
>>>
>>>
>>
>

Reply via email to