[jboss-user] [JBoss Messaging] - Re: Scheduled messages not delayed

jpansier do-not-reply at jboss.com
Tue Jun 19 07:31:08 EDT 2007


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.



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4055558#4055558

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4055558



More information about the jboss-user mailing list