-
1. Re: Scheduled messages not delayed
timfox Jun 19, 2007 5:51 AM (in response to jpansier)Can you please post your code, or an example that fails?
In the mean time, please take a look at org.jboss.test.messaging.jms.ScheduledDeliveryTest to see scheduled delivery in action. -
2. Re: Scheduled messages not delayed
jpansier Jun 19, 2007 6:24 AM (in response to jpansier)Indeed, I have look the unit test org.jboss.test.messaging.jms.ScheduledDeliveryTest.
my code :@Stateless @Clustered(partition="MyPartition") @RemoteBinding(jndiBinding="JMSManagerBean/remote") @TransactionManagement(value=TransactionManagementType.BEAN) public class JMSManagerBean implements JMSManager { private static final long serialVersionUID = 1L; private static Logger log = Logger.getLogger(JMSManagerBean.class); private QueueConnectionFactory qcf; private QueueConnection qc = null; private QueueSession session = null; private QueueSender qs = null; private Queue queue; private int connect() { String nomFileOut = "queue/myQueue"; Hashtable<String, String> properties = new Hashtable<String,String>(); properties.put(InitialContext.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); properties.put(InitialContext.PROVIDER_URL, "localhost:"+HAJNDI_PORT.intValue()); Context ictx = new InitialContext(properties); qcf = (QueueConnectionFactory) ictx.lookup("ClusteredConnectionFactory"); log.debug("Queue Out Name : " + nomFileOut); queue = (Queue) ictx.lookup(nomFileOut); qc = qcf.createQueueConnection(); session = qc.createQueueSession(true, Session.CLIENT_ACKNOWLEDGE); qs = session.createSender(queue); return 0; } public int sendMessage() { try { connect(); TextMessage messageOut; messageOut = session.createTextMessage(); messageOut.setText("My message"); messageOut.setJMSType(String.class.getName()); try { long dateSchedule = current.getDeliveryDate().getTime(); log.debug("*********** dateSchedule : " + dateSchedule); messageOut.setLongProperty(JBossMessage.JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME, dateSchedule); } catch (Exception e) { log.error("Problem with Schedule Property ",e); } messageOut.setLongProperty("JMS_JBOSS_REDELIVERY_DELAY", 10000); messageOut.setIntProperty("JMS_JBOSS_REDELIVERY_LIMIT", 3); qs.send(messageOut); log.debug("SYSTEM.CURRENTTIMEMILLIS : " + System.currentTimeMillis()); session.commit(); } catch (Exception e) { log.error(getClass().getName()+" unable to send message on queue.",e); retour = ErrorManager.CAN_NOT_SEND_MT; } finally { disconnect(); } return 0; } private int disconnect() { if (qs != null) { try { qs.close(); session.close(); qc.close(); queue = null; qcf = null; } catch (Exception e) { log.error("",e); logNetcool.error("KO"); } } return 0; } }
Also, I tried with the AUTO_ACKNOWLEDGE mode, but the result is the same.
Thanks,
joel -
3. Re: Scheduled messages not delayed
timfox Jun 19, 2007 6:33 AM (in response to jpansier)Please can you post a full runnable example showing messages being sent and consumed earlier than they should be.
Something we can copy and paste and run.
A JUnitTest would be ideal. -
4. Re: Scheduled messages not delayed
jpansier Jun 19, 2007 7:31 AM (in response to jpansier)When I send a jms schedule message (without consumer), it doesn't appear in jboss jmx-console scheduleMessageCount.
But if I restart jboss server, this message appear correctly in jboss jmx-console scheduleMessageCount and I don't consume this.
The junit test :import java.util.Date; import java.util.Hashtable; import javax.jms.Queue; import javax.jms.QueueConnection; import javax.jms.QueueConnectionFactory; import javax.jms.QueueSender; import javax.jms.QueueSession; import javax.jms.Session; import javax.jms.TextMessage; import javax.naming.Context; import javax.naming.InitialContext; import junit.framework.TestCase; public class APITest extends TestCase { private QueueConnectionFactory qcf; private QueueConnection qc = null; private QueueSession session = null; private QueueSender qs = null; private Queue queue; public APITest() { super("APITest"); } protected void setUp() throws Exception { super.setUp(); Hashtable<String, String> properties = new Hashtable<String, String>(); properties.put(InitialContext.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); properties.put(InitialContext.PROVIDER_URL, "localhost:1100"); Context jndiContext = new InitialContext(properties); qcf = (QueueConnectionFactory) jndiContext.lookup("ClusteredConnectionFactory"); queue = (Queue) jndiContext.lookup("queue/pcsapiMsgOutDefault"); qc = qcf.createQueueConnection(); session = qc.createQueueSession(true, Session.CLIENT_ACKNOWLEDGE); qs = session.createSender(queue); } protected void tearDown() throws Exception { super.tearDown(); if (qs != null) { try { qs.close(); session.close(); qc.close(); queue = null; qcf = null; } catch (Exception e) { System.err.println(""+e); } } } public void test() throws Exception { try { TextMessage messageOut; messageOut = session.createTextMessage(); messageOut.setText("My message"); messageOut.setJMSType(String.class.getName()); try { long dateSchedule = (new Date()).getTime()+1000*3600*2; messageOut.setLongProperty("JMS_JBOSS_SCHEDULED_DELIVERY", dateSchedule); } catch (Exception e) { System.err.println("Problem with Schedule Property "+e); } messageOut.setLongProperty("JMS_JBOSS_REDELIVERY_DELAY", 10000); messageOut.setIntProperty("JMS_JBOSS_REDELIVERY_LIMIT", 3); qs.send(messageOut); session.commit(); } catch (Exception e) { System.err.println(getClass().getName()+" unable to send message on queue."+e); } } }
Queue Configuration :<mbean code="org.jboss.jms.server.destination.QueueService" name="jboss.messaging.destination:service=Queue,name=pcsapiMsgOutDefault" xmbean-dd="xmdesc/Queue-xmbean.xml"> <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends> <depends>jboss.messaging:service=PostOffice</depends> <attribute name="Clustered">true</attribute> </mbean>
The consumer is a mdb. -
5. Re: Scheduled messages not delayed
fbastos1 Jun 22, 2007 6:01 AM (in response to jpansier)Hi,
I have the same problem, I wonder if it's a bug ?
Fab -
6. Re: Scheduled messages not delayed
timfox Jun 22, 2007 6:07 AM (in response to jpansier)Looking at the code I can see an issue.
To verify, can you try sending your scheduled message *outside* a transaction. -
8. Re: Scheduled messages not delayed
fbastos1 Jun 25, 2007 6:25 AM (in response to jpansier)I try to send a jms message outside transaction, creating a session with transaction attribute = false and acknowlegement mode to AUTO_ACKNOWLEDGE but the result is identic ....
Fab -
9. Re: Scheduled messages not delayed
timfox Jun 25, 2007 8:30 AM (in response to jpansier)Are you sure? That is what our tests do.
-
10. Re: Scheduled messages not delayed
timfox Jun 25, 2007 8:31 AM (in response to jpansier)In any case, someone will invetsigate this shortly... bogged down on other things right now.
-
11. Re: Scheduled messages not delayed
fbastos1 Jun 25, 2007 9:56 AM (in response to jpansier)yes,
the junit test in post by joel doesn't work with the transaction attribute = false and acknowledgement mode = Session.AUTO_ACKNOWLEDGE
Fab -
12. Re: Scheduled messages not delayed
timfox Jun 28, 2007 5:49 PM (in response to jpansier)I have verified with the exact test program posted before applying the fix and I can confirm that scheduled delivery did work as expect if the sending session was non transactional, but did not work if the sending session was transactional.
I have applied the fix, and can confirm it now works in both cases. I have also added test suite cases to cover this scenario.
Fix will be in the next release, 1.4.0.CR1, due out next week. -
13. Re: Scheduled messages not delayed
jpansier Jun 29, 2007 3:20 AM (in response to jpansier)Thanks a lot Tim.
Joel -
14. Re: Scheduled messages not delayed
jorgemoralespou_2 Jul 5, 2007 1:02 PM (in response to jpansier)Where can I download this release?
We are experiencing similar issues, and want to try the fix.