Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 57855 invoked from network); 29 Mar 2007 17:54:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 Mar 2007 17:54:08 -0000 Received: (qmail 50504 invoked by uid 500); 29 Mar 2007 17:54:14 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 50406 invoked by uid 500); 29 Mar 2007 17:54:14 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 50392 invoked by uid 500); 29 Mar 2007 17:54:14 -0000 Delivered-To: apmail-ws-axis2-cvs@ws.apache.org Received: (qmail 50388 invoked by uid 99); 29 Mar 2007 17:54:14 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Mar 2007 10:54:14 -0700 X-ASF-Spam-Status: No, hits=-98.6 required=10.0 tests=ALL_TRUSTED,INFO_TLD,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Mar 2007 10:54:06 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 24F071A9838; Thu, 29 Mar 2007 10:53:46 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r523781 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2: Constants.java transport/jms/JMSConnectionFactory.java transport/jms/JMSConstants.java transport/jms/JMSMessageReceiver.java transport/jms/JMSSender.java Date: Thu, 29 Mar 2007 17:53:45 -0000 To: axis2-cvs@ws.apache.org From: asankha@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070329175346.24F071A9838@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: asankha Date: Thu Mar 29 10:53:45 2007 New Revision: 523781 URL: http://svn.apache.org/viewvc?view=rev&rev=523781 Log: Fix AXIS2-2434 and AXIS2-2266 Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java 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/JMSConstants.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/Constants.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java?view=diff&rev=523781&r1=523780&r2=523781 ============================================================================== --- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java (original) +++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java Thu Mar 29 10:53:45 2007 @@ -266,8 +266,6 @@ public static final String CONTENT_TYPE = "ContentType"; public static final String CONTENT_TYPE_OF_FAULT = "ContentTypeOfFault"; - public static final String IS_USING_SEPARATE_LISTENER = "IsUsingSeparateListener"; - public static final String CONFIG_CONTEXT_TIMOUT_INTERVAL = "ConfigContextTimeoutInterval"; public static final String TRANSPORT_IN_URL = "TransportInURL"; 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=523781&r1=523780&r2=523781 ============================================================================== --- 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 Thu Mar 29 10:53:45 2007 @@ -17,6 +17,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.axis2.addressing.EndpointReference; import javax.jms.*; import javax.naming.Context; @@ -176,8 +177,38 @@ * @param serviceName the service to which it belongs */ public void addDestination(String destinationJndi, String serviceName) { + serviceJNDINameMapping.put(destinationJndi, serviceName); - serviceDestinationMapping.put(getDestinationName(destinationJndi), serviceName); + String destinationName = getDestinationName(destinationJndi); + log.warn("JMS Destination with JNDI name : " + destinationJndi + " does not exist"); + + Connection con = null; + try { + con = conFactory.createConnection(); + Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE); + Queue queue = session.createQueue(destinationJndi); + destinationName = queue.getQueueName(); + log.warn("JMS Destination with JNDI name : " + destinationJndi + " created"); + + } catch (JMSException e) { + log.error("Unable to create a Destination with JNDI name : " + destinationJndi, e); + // mark service as faulty + JMSUtils.markServiceAsFaulty( + (String) serviceJNDINameMapping.get(destinationJndi), + "Error looking up JMS destination : " + destinationJndi, + msgRcvr.getAxisConf().getAxisConfiguration()); + + } finally { + if (con != null) { + try { + con.close(); + } catch (JMSException ignore) {} + } + } + + serviceDestinationMapping.put(destinationName, serviceName); + log.info("Mapping JNDI name : " + destinationJndi + " and JMS Destination name : " + + destinationName + " against service : " + serviceName); } /** @@ -377,6 +408,28 @@ " to map its corresponding provider specific Destination name"); } return null; + } + + /** + * Return the EPR for the JMS Destination with the given JNDI name and using + * this connection factory + * @param destination the JNDI name of the JMS Destionation + * @return the EPR + */ + public EndpointReference getEPRForDestination(String destination) { + + StringBuffer sb = new StringBuffer(); + sb.append(JMSConstants.JMS_PREFIX).append(destination); + sb.append("?").append(JMSConstants.CONFAC_JNDI_NAME_PARAM). + append("=").append(getJndiName()); + Iterator props = getProperties().keySet().iterator(); + while (props.hasNext()) { + String key = (String) props.next(); + String value = (String) getProperties().get(key); + sb.append("&").append(key).append("=").append(value); + } + + return new EndpointReference(sb.toString()); } public String getServiceByDestination(String destinationName) { Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSConstants.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSConstants.java?view=diff&rev=523781&r1=523780&r2=523781 ============================================================================== --- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSConstants.java (original) +++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSConstants.java Thu Mar 29 10:53:45 2007 @@ -28,9 +28,14 @@ public static final String JMS_PREFIX = "jms:/"; /** - * The Parameter name indicating a JMS destination + * The Parameter name indicating a JMS destination for requests */ public static final String DEST_PARAM = "transport.jms.Destination"; + + /** + * The Parameter name indicating the response JMS destination + */ + public static final String REPLY_PARAM = "transport.jms.ReplyDestination"; /** * The Parameter name indicating the JMS destination type 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=523781&r1=523780&r2=523781 ============================================================================== --- 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 Thu Mar 29 10:53:45 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.description.Parameter; import org.apache.axis2.addressing.RelatesTo; import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.context.ContextFactory; @@ -101,8 +102,14 @@ public void onMessage(Message message) { // directly create a new worker and delegate processing try { - log.debug("Received JMS message to destination : " + - message.getJMSDestination()); + if (log.isDebugEnabled()) { + StringBuffer sb = new StringBuffer(); + sb.append("Received JMS message to destination : " + message.getJMSDestination()); + sb.append("\nMessage ID : " + message.getJMSMessageID()); + sb.append("\nCorrelation ID : " + message.getJMSCorrelationID()); + sb.append("\nReplyTo ID : " + message.getJMSReplyTo()); + log.debug(sb.toString()); + } } catch (JMSException e) { e.printStackTrace(); } @@ -168,6 +175,19 @@ msgContext.setServerSide(true); msgContext.setServiceGroupContextId(UUIDGenerator.getUUID()); msgContext.setMessageID(message.getJMSMessageID()); + + Destination replyTo = message.getJMSReplyTo(); + String jndiDestinationName = null; + if (replyTo == null) { + Parameter param = msgContext.getAxisService().getParameter(JMSConstants.REPLY_PARAM); + if (param != null && param.getValue() != null) { + jndiDestinationName = (String) param.getValue(); + } + } + + if (jndiDestinationName != null) { + msgContext.setReplyTo(jmsConFac.getEPRForDestination(jndiDestinationName)); + } String soapAction = JMSUtils.getProperty(message, JMSConstants.SOAPACTION); if (soapAction != null) { 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=523781&r1=523780&r2=523781 ============================================================================== --- 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 Thu Mar 29 10:53:45 2007 @@ -22,6 +22,8 @@ import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.context.MessageContext; import org.apache.axis2.description.TransportOutDescription; +import org.apache.axis2.description.WSDL2Constants; +import org.apache.axis2.description.Parameter; import org.apache.axis2.handlers.AbstractHandler; import org.apache.axis2.transport.TransportSender; import org.apache.commons.logging.Log; @@ -38,8 +40,13 @@ import javax.jms.Session; import javax.jms.TextMessage; import javax.xml.stream.XMLStreamException; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.naming.Context; +import javax.naming.NameNotFoundException; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.util.Hashtable; /** * The TransportSender for JMS @@ -83,17 +90,6 @@ msgContext.getProperty(Constants.OUT_TRANSPORT_INFO); } - // should we wait and listen for a response? - boolean waitForResponse = false; - - Object seprLisn = msgContext.getProperty( - Constants.Configuration.IS_USING_SEPARATE_LISTENER); - if (Boolean.TRUE.equals(seprLisn)) { - waitForResponse = false; - } else if (!msgContext.isServerSide()) { - waitForResponse = !msgContext.getOptions().isUseSeparateListener(); - } - // get the ConnectionFactory to be used for the send ConnectionFactory connectionFac = transportInfo.getConnectionFactory(); @@ -119,14 +115,45 @@ MessageProducer producer = session.createProducer(dest); Destination replyDest = null; + boolean waitForResponse = + msgContext.getOperationContext() != null && + WSDL2Constants.MEP_URI_OUT_IN.equals( + msgContext.getOperationContext().getAxisOperation().getMessageExchangePattern()); + if (waitForResponse) { - try { - // create temporary queue to receive reply - replyDest = session.createTemporaryQueue(); - message.setJMSReplyTo(replyDest); - } catch (JMSException e) { - handleException("Error creating temporary queue for response"); + String replyToJNDIName = (String) msgContext.getProperty(JMSConstants.REPLY_PARAM); + if (replyToJNDIName != null && replyToJNDIName.length() > 0) { + Context context = null; + Hashtable props = JMSUtils.getProperties(targetAddress); + try { + context = new InitialContext(props); + } catch (NamingException e) { + handleException("Could not get the initial context", e); + } + + try { + replyDest = (Destination) context.lookup(replyToJNDIName); + + } catch (NameNotFoundException e) { + log.warn("Cannot get or lookup JMS response destination : " + + replyToJNDIName + " : " + e.getMessage() + + ". Attempting to create a Queue named : " + replyToJNDIName); + replyDest = session.createQueue(replyToJNDIName); + + } catch (NamingException e) { + handleException("Cannot get JMS response destination : " + + replyToJNDIName + " : ", e); + } + + } else { + try { + // create temporary queue to receive reply + replyDest = session.createTemporaryQueue(); + } catch (JMSException e) { + handleException("Error creating temporary queue for response"); + } } + message.setJMSReplyTo(replyDest); } try { --------------------------------------------------------------------- To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org For additional commands, e-mail: axis-cvs-help@ws.apache.org