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

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


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

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

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



More information about the jboss-user mailing list