activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tb0ne <activ...@dotquam.com>
Subject Multiple Scheduled Messages Not Firing
Date Wed, 20 Oct 2010 16:45:17 GMT

I ran into a scenario where I have multiple Scheduled Messages with a cron
string set to fire every minute that are created at different times. 
However, only one is firing every minute (cycles 0 to 9).  Is this as
intended?  

Here is some sample code to that generates the same behavior:

	String  url = "tcp://localhost:61616";
        ActiveMQConnectionFactory connectionFactory = new
ActiveMQConnectionFactory(null, null, url);
        Connection connection = connectionFactory.createConnection();
        Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
        connection.start();
	String cronEveryMinute = "* * * * *";
        for (int i = 0; i < 10; i++) {
            String queueName = "scheduled.test"+i;	
            Queue destination = session.createQueue(queueName);	
            MessageProducer producer = session.createProducer(destination);
   	    String msg = "Sample message for queue "+queueName;
   	    TextMessage message = session.createTextMessage(msg);
	    message.setStringProperty(ScheduledMessage.AMQ_SCHEDULED_CRON,
cronEveryMinute);
	    producer.send(message);
	    producer.close();
	    //wait a couple sec so cron start time is different for next job
	    Thread.sleep(2000);
        }
        connection.close();
-- 
View this message in context: http://activemq.2283324.n4.nabble.com/Multiple-Scheduled-Messages-Not-Firing-tp3004226p3004226.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Mime
View raw message