6 Replies Latest reply on Oct 22, 2007 6:29 AM by ejb3workshop

    Using DeliveryMode.NON_PERSISTENT

    ejb3workshop

      I have a MDB configured as shown below. I am sending a large number of messages to the MDB and do not require persistent queue. Searching the forum I found several suggestion to set DeliveryMode.NON_PERSISTENT, yet when I use the HSQL Database Manager I still find entries created in the JMS_Messages table. Ideally I would like to avoid any kind of persistence to achieve a performance gain. My requirements do not require persistence for this service.

      ...
      @MessageDriven(name = "LogMessageProcessor",mappedName="LogMessageProcessor", activationConfig = {
       @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
       @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
       @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/LogMessageProcessors"),
       @ActivationConfigProperty(propertyName = "maxSession", propertyValue = "5"),
       @ActivationConfigProperty(propertyName = "maxMessages", propertyValue="5"),
       @ActivationConfigProperty(propertyName = "subscriptionDurability", propertyValue="Non-Durable")
      })
      public class LogMessageProcessor implements MessageListener
      ...
      


      Properties properties = new Properties();
      properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      properties.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
      properties.put(Context.PROVIDER_URL, "jnp://localhost:1100");
      InitialContext ctx = new InitialContext(properties);
      Queue queue = (Queue) ctx.lookup("/queue/LogMessageProcessors");
      
      QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
      cnn = factory.createQueueConnection();
      sess = cnn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
      MapMessage msg = sess.createMapMessage();
      
      QueueConnection connection = factory.createQueueConnection();
      QueueSession session = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
      QueueSender sender = session.createSender(queue);
      sender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
      for (int index=0; index<2000; index++)
      {
       ObjectMessage message = session.createObjectMessage();
       LogMessage logMessage = new LogMessage();
       logMessage.setMessage("Log Message : "+System.currentTimeMillis());
       message.setObject(logMessage);
       message.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
       sender.send(message,DeliveryMode.NON_PERSISTENT,10,20000);
       //logger.log(Level.INFO,"Dispatched message : "+logMessage.getMessage());
      }
      
      sender.close();
      session.close();
      connection.close();
      


      Any assistance in improving the performance and avoid persisting the messages will help me a lot. Thanks in advance.
      alex