axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asan...@apache.org
Subject svn commit: r520555 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms: JMSConnectionFactory.java JMSMessageReceiver.java JMSSender.java
Date Tue, 20 Mar 2007 20:27:54 GMT
Author: asankha
Date: Tue Mar 20 13:27:53 2007
New Revision: 520555

URL: http://svn.apache.org/viewvc?view=rev&rev=520555
Log:
fix AXIS2-2030 and AXIS2-2277 after review
thanks John Turner

Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSConnectionFactory.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSMessageReceiver.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSSender.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSConnectionFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSConnectionFactory.java?view=diff&rev=520555&r1=520554&r2=520555
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSConnectionFactory.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSConnectionFactory.java
Tue Mar 20 13:27:53 2007
@@ -18,12 +18,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.Session;
+import javax.jms.*;
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NameNotFoundException;
@@ -87,9 +82,13 @@
      */
     private String jndiName = null;
     /**
-     * A map of destinations to service names they belong to
+     * Map of destination JNDI names to service names
      */
-    private Map destinations = null;
+    private Map serviceJNDINameMapping = null;
+    /**
+     * Map of destinations to service names
+     */
+    private Map serviceDestinationMapping = null;
     /**
      * The JMS Sessions listening for messages
      */
@@ -124,7 +123,8 @@
     JMSConnectionFactory(String name, String jndiName) {
         this.name = name;
         this.jndiName = jndiName;
-        destinations = new HashMap();
+        serviceJNDINameMapping = new HashMap();
+        serviceDestinationMapping = new HashMap();        
         properties = new Hashtable();
         jmsSessions = new HashMap();
     }
@@ -176,17 +176,24 @@
      * @param serviceName     the service to which it belongs
      */
     public void addDestination(String destinationJndi, String serviceName) {
-        destinations.put(destinationJndi, serviceName);
+        serviceJNDINameMapping.put(destinationJndi, serviceName);
+        serviceDestinationMapping.put(getDestinationName(destinationJndi), serviceName);
     }
 
     /**
      * Remove listen destination on this connection factory
      *
      * @param destinationJndi the JMS destination to be removed
+     * @throws if an error occurs trying to stop listening for messages before removal
      */
     public void removeDestination(String destinationJndi) throws JMSException {
+        // find and save provider specific Destination name before we delete
+        String providerSpecificDestination = getDestinationName(destinationJndi);
         stoplistenOnDestination(destinationJndi);
-        destinations.remove(destinationJndi);
+        serviceJNDINameMapping.remove(destinationJndi);
+        if (providerSpecificDestination != null) {
+            serviceDestinationMapping.remove(providerSpecificDestination);
+        }
     }
 
     /**
@@ -227,12 +234,12 @@
     }
 
     /**
-     * Get the list of destinations associated with this connection factory
+     * Get the list of destinations (JNDI) associated with this connection factory
      *
      * @return destinations to service maping
      */
     public Map getDestinations() {
-        return destinations;
+        return serviceJNDINameMapping;
     }
 
     /**
@@ -271,7 +278,7 @@
             }
         }
 
-        Iterator iter = destinations.keySet().iterator();
+        Iterator iter = serviceJNDINameMapping.keySet().iterator();
         while (iter.hasNext()) {
             String destinationJndi = (String) iter.next();
             listenOnDestination(destinationJndi);
@@ -306,7 +313,7 @@
             log.warn("Error looking up destination : " + destinationJndi, e);
             // mark service as faulty
             JMSUtils.markServiceAsFaulty(
-                    (String) destinations.get(destinationJndi),
+                    (String) serviceJNDINameMapping.get(destinationJndi),
                     "Error looking up JMS destination : " + destinationJndi,
                     this.msgRcvr.getAxisConf().getAxisConfiguration());
         }
@@ -334,7 +341,7 @@
      */
     public String getServiceNameForDestination(String destination) {
 
-        return (String) destinations.get(destination);
+        return (String) serviceJNDINameMapping.get(destination);
     }
 
     /**
@@ -346,6 +353,34 @@
         } catch (JMSException e) {
             log.warn("Error shutting down connection factory : " + name, e);
         }
+    }
+
+    /**
+     * Return the provider specific Destination name if any for the destination with the
given
+     * JNDI name
+     * @param destinationJndi the JNDI name of the destination
+     * @return the provider specific Destination name or null if cannot be found
+     */
+    public String getDestinationName(String destinationJndi) {
+        try {
+            Destination destination = (Destination) context.lookup(destinationJndi);
+            if (destination != null && destination instanceof Queue) {
+                return ((Queue) destination).getQueueName();
+            } else if (destination != null && destination instanceof Topic) {
+                return ((Topic) destination).getTopicName();
+            }
+        } catch (JMSException e) {
+            log.warn("Error reading provider specific JMS destination name for destination
" +
+                "with JNDI name : " + destinationJndi, e);
+        } catch (NamingException e) {
+            log.warn("Error looking up destination with JNDI name : " + destinationJndi +
+                " to map its corresponding provider specific Destination name");
+        }
+        return null;
+    }
+
+    public String getServiceByDestination(String destinationName) {
+        return (String) serviceDestinationMapping.get(destinationName);
     }
 
     private void handleException(String msg) throws AxisJMSException {

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSMessageReceiver.java?view=diff&rev=520555&r1=520554&r2=520555
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSMessageReceiver.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSMessageReceiver.java
Tue Mar 20 13:27:53 2007
@@ -19,6 +19,7 @@
 import org.apache.axiom.om.util.UUIDGenerator;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.RelatesTo;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.ContextFactory;
 import org.apache.axis2.context.MessageContext;
@@ -130,7 +131,7 @@
                 destinationName = ((Topic) dest).getTopicName();
             }
 
-            String serviceName = jmsConFac.getServiceNameForDestination(destinationName);
+            String serviceName = jmsConFac.getServiceByDestination(destinationName);
 
             // hack to get around the crazy Active MQ dynamic queue and topic issues
             if (serviceName == null) {
@@ -165,6 +166,7 @@
 
             msgContext.setServerSide(true);
             msgContext.setServiceGroupContextId(UUIDGenerator.getUUID());
+            msgContext.setMessageID(message.getJMSMessageID());
 
             String soapAction = JMSUtils.getProperty(message, JMSConstants.SOAPACTION);
             if (soapAction != null) {
@@ -173,6 +175,14 @@
 
             msgContext.setEnvelope(
                     JMSUtils.getSOAPEnvelope(message, msgContext, in));
+
+            // set correlation id
+            String correlationId = message.getJMSCorrelationID();
+            if (correlationId != null && correlationId.length() > 0) {
+                msgContext.setProperty(JMSConstants.JMS_COORELATION_ID, correlationId);
+                msgContext.setRelationships(
+                    new RelatesTo[] { new RelatesTo(correlationId) });
+            }
 
             return msgContext;
 

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSSender.java?view=diff&rev=520555&r1=520554&r2=520555
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSSender.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSSender.java
Tue Mar 20 13:27:53 2007
@@ -243,6 +243,10 @@
 
         // set the JMS correlation ID if specified
         String correlationId = getProperty(msgContext, JMSConstants.JMS_COORELATION_ID);
+        if (correlationId == null) {
+            correlationId = msgContext.getRelatesTo().getValue();
+        }
+
         if (correlationId != null) {
             message.setJMSCorrelationID(correlationId);
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message