Hello Andy, The test for the first case involves using HermesJMS to look at the queue and make sure it is empty. And then running the following code:
| | | import java.util.Date; | import java.util.Properties; | | | import java.io.IOException; | | import javax.jms.Connection; | import javax.jms.DeliveryMode; | import javax.jms.Destination; | import javax.jms.MessageProducer; | import javax.jms.Session; | import javax.jms.TextMessage; | import javax.naming.Context; | import javax.naming.InitialContext; | | /** | * A simple tool for publishing messages | * | * @version $Revision: 1.2 $ | */ | | public class ProducerJBM | { | | private Destination destination; | private int messageCount; | private long sleepTime; | private boolean verbose = true; | private int messageSize; | private long timeToLive; | private String queueName; | private String providerURL; | private String connectionFactoryBinding; | private boolean transacted; | | | /**************************************************************************/ | public static void main(String[] args) | { | ProducerJBM producer = new ProducerJBM(); | producer.run(); | } | /**************************************************************************/ | public ProducerJBM() | { | Properties props = new Properties(); | try | { | props.load(this.getClass().getClassLoader().getResourceAsStream("jbm.properties")); | } | catch (IOException ioe) | { | System.err.println("Error loading jbm.properties."); | ioe.printStackTrace(System.err); | System.exit(-1); | } | | providerURL = props.getProperty("provider_url"); | messageCount = Integer.parseInt(props.getProperty("num_messages_to_send")); | if (messageCount == -1) | messageCount = Integer.MAX_VALUE; | queueName = props.getProperty("queue_name"); | messageSize = Integer.parseInt(props.getProperty("message_size")); | sleepTime = Long.parseLong(props.getProperty("producer.sleep_time_ms")); | connectionFactoryBinding = props.getProperty("connection_factory_binding"); | transacted = Boolean.parseBoolean(props.getProperty("producer.transacted").trim()); | } | /**************************************************************************/ | public void run() | { | Connection connection = null; | | try | { | // System.out.println("Connecting to URL: " + url); | System.out.println("Publishing a Message with size " | + messageSize + " to queue" + ": " | + queueName); | System.out.println("Sleeping between publish " + sleepTime + " ms"); | if (timeToLive != 0) { | System.out.println("Messages time to live " + timeToLive + " ms"); | } | | Properties props = new Properties(); | props.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory"); | props.setProperty(Context.PROVIDER_URL, providerURL); | props.setProperty(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces"); | | | javax.naming.Context ctx = new InitialContext(props); | | javax.jms.ConnectionFactory factory = | (javax.jms.ConnectionFactory)ctx.lookup(connectionFactoryBinding); | | connection = factory.createConnection(); | | connection.start(); | | // Create the session | Session session = connection.createSession( | transacted, | Session.AUTO_ACKNOWLEDGE); | System.err.println("Session transaction mode: " + transacted); | | destination = session.createQueue(queueName); | | // Create the producer. | MessageProducer producer = session.createProducer(destination); | producer.setDeliveryMode(DeliveryMode.PERSISTENT); | | if (timeToLive != 0) { | producer.setTimeToLive(timeToLive); | } | | // Start sending messages | sendLoop(session, producer); | | if (transacted) | { | System.err.println("About to commit the session."); | session.commit(); | System.err.println("Finished commiting the session."); | } | System.out.println("Done."); | | } | catch (Exception e) | { | System.out.println("Caught: " + e); | e.printStackTrace(); | } | finally | { | System.err.println(); | System.err.println("We have reached the finally block."); | try | { | System.err.println("About to close JMS connection."); | connection.close(); | System.err.println("Finished closing the JMS connection."); | } | catch (Throwable ignore) | { | } | } | } | /**************************************************************************/ | protected void sendLoop(Session session, MessageProducer producer) | throws Exception | { | | for (int i = 0; i < messageCount || messageCount == 0; i++) | { | /*if (i == 20) | throw new Exception("This is an intentionl test exception thrown by Vishal");*/ | TextMessage message = session.createTextMessage(i+""); | | String msg = message.getText(); | System.out.println("Sending message: " + msg); | message.setJMSMessageID("ID:"+messageCount); | message.setJMSCorrelationID("JMS CID:"+messageCount); | producer.send(message); | | | Thread.sleep(sleepTime); | | } | } | /**************************************************************************/ | } | | | | Here is my jbm.properties file. It's used by a few different client programs, but I post it here in its entirety for the sake of not smudging the evidence ;) For the sake of the current issue we are discussing, I am only running the above client program. | provider_url = jnp://162.10.170.78:1399 | | connection_factory_binding = ConnectionFactory | | queue_name = FR.SYNC.RESPONSE | num_messages_to_send = 200 | message_size = 255 | | | producer.sleep_time_ms = 10 | | | consumer.sleep_time_ms = 100 | | | producer.transacted = true | consumer.transacted = true | | | consumer.even.num_threads = 4 | consumer.even.sleep_time_ms = 1000 | | consumer.odd.num_threads = 4 | consumer.odd.sleep_time_ms = 1000 | | I run the program, notice that it has completed successfully (no exception) and then notice in HermesJMS that 200 messages show up. All this time, I have confirmed that MaxSize==20 in JBoss JMX MBean page for the queue. Thanks, Vishal View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4162920#4162920 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4162920 _______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user