Thanks for the quick response Dejan/mkeenan. Yes we are using auto_acknowledge mode for both consumer and producer. Could this be a problem?
Dejan,Here is my producer code: public class SynchMessageProducer { private static int deliveryMode; private static int ackMode; private static boolean transacted = false; static { ackMode = Session.AUTO_ACKNOWLEDGE; deliveryMode = DeliveryMode.PERSISTENT; } public static void main(String args[]) { FileSystemXmlApplicationContext ctx = new FileSystemXmlApplicationContext("etc/messaging/example-config.xml"); JmsTemplate jmsTemplate = (JmsTemplate)ctx.getBean("jmsTemplate"); String tradeID = args[0]; Connection connection = jmsTemplate.getConnectionFactory().createConnection(); Session session = connection.createSession(transacted,ackMode); //Setup a message producer MessageProducer producer = session.createProducer(jmsTemplate.getDefaultDestination()); producer.setDeliveryMode(deliveryMode); connection.start(); //Create a temporary queue that this client will listen for responses // then create a consumer that consumes message from this temporary queue TemporaryQueue responseQueue = session.createTemporaryQueue(); System.out.println("Temporary queue created:" + responseQueue.toString()); //create the message to be sent Message mes = session.createMapMessage(); mes.setStringProperty("contract-revno-list",tradeID); //Set the reply to field to the temporary queue you created above, //this is the queue the consumer will respond to mes.setJMSReplyTo(responseQueue); String correlationId = createRandomString(); mes.setJMSCorrelationID(correlationId); //send the message producer.send(mes); // Wait for the response from the seed application MessageConsumer consumer = session.createConsumer(responseQueue); Message response = null; System.out.println("Waiting for Response....."); response = consumer.receive(); connection.close(); session.close(); } Below is the snippet from example-config.xml used by above producer: --------------------------- <bean id="jmsFactory" class="org.apache.activemq.pool.PooledConnectionFactory" destroy-method="stop"> <property name="connectionFactory"> <bean class="org.apache.activemq.ActiveMQConnectionFactory"> <property name="brokerURL"> <value>failover:(tcp://master_host:61616,tcp://slave_host:61616)?randomize=false</value> </property> </bean> </property> </bean> ------------------------------------------------------------- mKeenan, Broker restart certainly does the job but problem is this messages are struck too frequently say after 10-11 messages so restarting the broker would not be feasible n our case :( guptaviv wrote: > > Hi, > > We are having the messaging setup where we are using one Listener and one > one producer. > I am trying to repeatedly send the messages through the same producer. > The problem is, very frequently the messages are stuck in the queue with > the broker. > The listener is absolutely free and but still the broker is not > dispatching the messages to the Listener. > Following is the configuration that we are using for producer: > deliverymode : persistent > ackMode: auto_acknowledge > > We are not setting any other configuration parameters(using default). > > The problem gets fixed after some time when you restart the broker or > Listener but the issue reappears after some time again. > > Is there any solution/workaround to this issue. Please let me know if > anyone has thoughts/advices on this. > > Thanks, > Vivek > -- View this message in context: http://www.nabble.com/Messages-Stuck-in-the-queue%28with-the-broker%29-tp24589627p24619679.html Sent from the ActiveMQ - User mailing list archive at Nabble.com.