Thanks dannyyates I tried by seting the persistence mode to message, didn't work. Then I tried setting the persistence mode for both QueuSender and Message, still no luck
Can u pls. take a look at the code or Please copy&paste ur code here that works for you. I am using to the file system persistence public class SimpleQueueSender { /** * Main method. * * @param args the queue used by the example and, * optionally, the number of messages to send */ public static void main(String[] args) { String queueName = null; Context jndiContext = null; QueueConnectionFactory queueConnectionFactory = null; QueueConnection queueConnection = null; QueueSession queueSession = null; Queue queue = null; QueueSender queueSender = null; TextMessage message = null; final int NUM_MSGS; // Initial context strings String PROVIDER_URL = "java.naming.provider.url"; String NAMING_FACTORY = "java.naming.factory.initial"; String CONTEXT_FACTORY = "org.jnp.interfaces.NamingContextFactory"; String jndiHost = "localhost:1099"; NUM_MSGS = 5; queueName = "queue/orafin/OrafinServices"; Properties props = new Properties(); props.put(NAMING_FACTORY, CONTEXT_FACTORY); props.put(PROVIDER_URL, jndiHost); /* * Create a JNDI API InitialContext object if none exists * yet. */ try { jndiContext = new InitialContext(props); } catch (NamingException e) { System.out.println("Could not create JNDI API " + "context: " + e.toString()); System.exit(1); } /* * Look up connection factory and queue. If either does * not exist, exit. */ try { queueConnectionFactory = (QueueConnectionFactory) jndiContext.lookup("ConnectionFactory"); queue = (Queue) jndiContext.lookup(queueName); } catch (NamingException e) { System.out.println("JNDI API lookup failed: " + e.toString()); System.exit(1); } /* * Create connection. * Create session from connection; false means session is * not transacted. * Create sender and text message. * Send messages, varying text slightly. * Send end-of-messages message. * Finally, close connection. */ try { queueConnection = queueConnectionFactory.createQueueConnection(); queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); queueSender = queueSession.createSender(queue); queueSender.setDeliveryMode(DeliveryMode.PERSISTENT); message = queueSession.createTextMessage(); for (int i = 0; i < NUM_MSGS; i++) { message.setText("This is message " + (i + 1)); System.out.println("Sending message: " + message.getText()); message.setJMSDeliveryMode(DeliveryMode.PERSISTENT); queueSender.send(message); } /* * Send a non-text control message indicating end of * messages. */ queueSender.send(queueSession.createMessage()); } catch (JMSException e) { System.out.println("Exception occurred: " + e.toString()); } finally { if (queueConnection != null) { try { queueConnection.close(); } catch (JMSException e) {} } } } } import javax.jms.*; import javax.naming.*; import java.util.*; public class SimpleQueueReceiver { /** * Main method. * * @param args the queue used by the example */ public static void main(String[] args) { String queueName = null; Context jndiContext = null; QueueConnectionFactory queueConnectionFactory = null; QueueConnection queueConnection = null; QueueSession queueSession = null; Queue queue = null; QueueReceiver queueReceiver = null; TextMessage message = null; // Initial context strings String PROVIDER_URL = "java.naming.provider.url"; String NAMING_FACTORY = "java.naming.factory.initial"; String CONTEXT_FACTORY = "org.jnp.interfaces.NamingContextFactory"; String jndiHost = "localhost:1099"; queueName = "queue/orafin/OrafinServices"; Properties props = new Properties(); props.put(NAMING_FACTORY, CONTEXT_FACTORY); props.put(PROVIDER_URL, jndiHost); System.out.println("Queue name is " + queueName); /* * Create a JNDI API InitialContext object if none exists * yet. */ try { jndiContext = new InitialContext(props); } catch (NamingException e) { System.out.println("Could not create JNDI API " + "context: " + e.toString()); System.exit(1); } /* * Look up connection factory and queue. If either does * not exist, exit. */ try { queueConnectionFactory = (QueueConnectionFactory) jndiContext.lookup("ConnectionFactory"); queue = (Queue) jndiContext.lookup(queueName); } catch (NamingException e) { System.out.println("JNDI API lookup failed: " + e.toString()); System.exit(1); } /* * Create connection. * Create session from connection; false means session is * not transacted. * Create receiver, then start message delivery. * Receive all text messages from queue until * a non-text message is received indicating end of * message stream. * Close connection. */ try { queueConnection = queueConnectionFactory.createQueueConnection(); queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); queueReceiver = queueSession.createReceiver(queue); queueConnection.start(); Message m = queueReceiver.receive(1); while (m != null) { if (m != null) { if (m instanceof TextMessage) { message = (TextMessage) m; System.out.println("Reading message: " + message.getText()); } } m = queueReceiver.receive(1); } } catch (JMSException e) { System.out.println("Exception occurred: " + e.toString()); } finally { if (queueConnection != null) { try { queueConnection.close(); } catch (JMSException e) {} } } } } View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3839137#3839137 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3839137 ------------------------------------------------------- This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user