[jboss-svn-commits] JBL Code SVN: r7519 - labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Nov 9 14:54:52 EST 2006
Author: kurt.stam at jboss.com
Date: 2006-11-09 14:54:52 -0500 (Thu, 09 Nov 2006)
New Revision: 7519
Removed:
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/JmsQueueReplyListener.java
Log:
no longer needed after the new courier implementation.
Deleted: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/JmsQueueReplyListener.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/JmsQueueReplyListener.java 2006-11-09 19:52:10 UTC (rev 7518)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/JmsQueueReplyListener.java 2006-11-09 19:54:52 UTC (rev 7519)
@@ -1,178 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.soa.esb.listeners.message;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.net.URISyntaxException;
-import java.util.UUID;
-
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.ObjectMessage;
-import javax.jms.Queue;
-import javax.jms.QueueConnection;
-import javax.jms.QueueConnectionFactory;
-import javax.jms.QueueSession;
-import javax.naming.Context;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.addressing.eprs.JMSEpr;
-import org.jboss.soa.esb.helpers.AppServerContext;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.util.Util;
-import org.xml.sax.SAXException;
-
-
-/**
- * JMS based Reply Listener. This is a listenere which gets set up
- *
- * @author esteban
- * @author kstam at redhat.com
- *
- */
-public class JmsQueueReplyListener
-{
- public static final String CORRELATION_ID_TAG = "jmsCorrelationId";
-
- private static Logger _logger = Logger.getLogger(JmsQueueReplyListener.class);
- /** maybe we have network issues, sleep 5 seconds before trying again. */
- private static long SLEEP_FOR_RETRY = 5000;
- private QueueConnection _Qconn = null;
- private QueueSession _Qsess = null;
- private Queue _Queue = null;
- /**
- * We will be listening the same queue, but with a 'temporary' message selector
- * based of a UUID.
- *
- * @param message to which we ill add the CORRELATION_ID_TAG.
- * @return the generated unique reply selector.
- */
- public String getReplySelector()
- {
- String uuId = UUID.randomUUID().toString();
- String uniqueReplySelector = new StringBuilder()
- .append(CORRELATION_ID_TAG).append("='")
- .append(uuId).append("'").toString();
- return uniqueReplySelector;
- }
- /**
- *
- * @param epr
- * @param selector
- * @return
- */
- private MessageConsumer getConsumer(JMSEpr epr)
- {
- _Qconn = null;
- _Qsess = null;
- _Queue = null;
-
- Exception thrown = null;
- try
- {
- Context context = AppServerContext.getServerContext(epr.getJndiType(),epr.getJndiURL());
- Object tmp = context.lookup(epr.getConnectionFactory());
- QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
-
- _Qconn = qcf.createQueueConnection();
- _Queue = (Queue) context.lookup(epr.getDestinationName());
- _Qsess = _Qconn.createQueueSession(false,QueueSession.AUTO_ACKNOWLEDGE);
- _Qconn.start();
- return _Qsess.createReceiver(_Queue, epr.getMessageSelector());
- }
- catch (URISyntaxException e) { thrown = e; }
- catch (javax.naming.NamingException e) { thrown = e; }
- catch (JMSException e) { thrown = e; }
- _logger.error("Unable to create response consumer",thrown);
- return null;
- }
-
- public Message listen(JMSEpr epr, long replyListenerTimout)
- {
- MessageConsumer consumer = null;
- javax.jms.Message jmsMessage = null;
- {
- for (int i = 0; i < 3; i++)
- try
- {
- consumer = getConsumer(epr);
- jmsMessage = consumer.receive(replyListenerTimout);
- break;
- }
- catch (Exception e)
- {
- _logger.error("JMS error on receive. Attempting JMS Destination reconnect.", e);
- _logger.error("Reconnecting to Queue", e);
- try { Thread.sleep(SLEEP_FOR_RETRY); }
- catch (InterruptedException e1)
- { // Just return after logging
- _logger.error("Unexpected thread interupt exception.", e);
- break;
- }
- } finally {cleanupJms(); }
- }
- if (null == jmsMessage)
- return null;
-
- if (!(jmsMessage instanceof ObjectMessage))
- {
- _logger.error("Unsupported JMS message type: " + jmsMessage.getClass().getName());
- return null;
- }
- try
- {
- Serializable obj = (Serializable)((ObjectMessage)jmsMessage).getObject();
- return Util.deserialize(obj);
- }
- catch (JMSException e1)
- { _logger.error("Failed to read Serialized Object from JMS message.", e1);
- return null;
- }
- catch (ClassCastException e2)
- { _logger.error("Object in JMS message is not a org.jboss.soa.esb.message.Message", e2);
- }
- catch (IOException e3)
- { _logger.error("Object in JMS message is not a Serializeable", e3);
- }
- catch (ParserConfigurationException e4)
- { _logger.error("Object in JMS message has invalid XML", e4);
- }
- catch (SAXException e5)
- { _logger.error("Object in JMS message has invalid XML", e5);
- }
- return null;
- }
-
-
- private void cleanupJms()
- {
- if (null != _Qsess)
- try { _Qsess.close(); }
- catch (Exception e1) {/* Tried my best - Just continue */ }
- if (null != _Qconn)
- try { _Qconn.close(); }
- catch (Exception e2) {/* Tried my best - Just continue */ }
- }
-}
More information about the jboss-svn-commits
mailing list