With the following code messages are sent to a queue (using an Apache connection pool for JMS connections):
| private void sendMessage(MASMessage message, String destinationNameQueue) throws JMSException{ | | if (connectionFactory != null) { | QueueSession queueSession = null; | QueueConnection queueConnection = null; | try{ | queueConnection = (QueueConnection)queueConnectionPool.borrowObject(); | queueSession = queueConnection.createQueueSession(true, Session.AUTO_ACKNOWLEDGE); | QueueSender sender = queueSession.createSender((Queue)getDestination(destinationNameQueue)); | ObjectMessage objectMessage = queueSession.createObjectMessage(message); | | sender.send(objectMessage, DeliveryMode.PERSISTENT, 4, 0); | Log.debug("Message sent of type: " + message.getClass().getName() + " to queue " + destinationNameQueue, JmsUtil.class); | queueConnection.start(); | queueSession.commit(); | } catch (Exception jmsexc){ | // exception handling | } finally { | // ... | } | } else { | // ... | } | } | A message driven bean acts as listener and receives these messages: | @MessageDriven( | name="MCSAccountingMessageBean", | activationConfig = { | @ActivationConfigProperty( | propertyName="destinationType", | propertyValue="javax.jms.Queue" | ), | @ActivationConfigProperty( | propertyName="sessionTransacted", | propertyValue="true" | ), | @ActivationConfigProperty( | propertyName="providerAdapterJNDI", | propertyValue="java:/JMSSecureProvider" | ) | /* see additional dynamic properties in deployment descriptor */ | } | ) | public class MCSAccountingMessageBean implements MessageListener { | | public void onMessage(Message message) { | Log.debug("Received message of type: " + message.getClass().getName() + " at " + new Date(), MCSAccountingMessageBean.class); | if (message instanceof ObjectMessage) { | ObjectMessage om = (ObjectMessage) message; | if (om != null) { | try { | if (om.getObject() instanceof MASWalletTransactionMessage) { | MASWalletTransactionMessage transactionMessage = (MASWalletTransactionMessage) om.getObject(); | // dispatch message now | }else{ | Log.error("Cannot process object message with object of unexpected type: " + om.getObject().getClass().getName(), MCSAccountingMessageBean.class); | } | } catch (JMSException e) { | Log.error("Cannot receive JMS message: \n" + e.toString(), MCSAccountingMessageBean.class); | throw new RuntimeException("Unable to receive or process wallet transaction message!"); | } | } | } else { | Log.error("Cannot process message of unexpected type: " + message.getClass().getName(), MCSAccountingMessageBean.class); | } | Log.debug("Finished processing message at " + new Date(), MCSAccountingMessageBean.class); | } | } | After starting both application servers sending and receiving messages works fine for a while. After several hours of service the MDB stops receiving messages. We can see the messages in the messaging tables JBM_MSG and JBM_MSG_REF of the database (hence sending works), but the MDB shows no reaction. No error messages in the log files on both sides. We must stop and restart the MDB using JMX console. Sometimes we must restart the queue in order to get messaging working. Hope to be more clearly now. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4204336#4204336 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4204336 _______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user