[jboss-svn-commits] JBL Code SVN: r7518 - in labs/jbossesb/trunk/product/core: listeners/src/org/jboss/soa/esb/actions rosetta/src/org/jboss/internal/soa/esb/couriers rosetta/src/org/jboss/soa/esb/couriers

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Nov 9 14:52:12 EST 2006


Author: kurt.stam at jboss.com
Date: 2006-11-09 14:52:10 -0500 (Thu, 09 Nov 2006)
New Revision: 7518

Added:
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierUtil.java
Modified:
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/CbrProxyAction.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java
Log:
Moving getReplySelector to Utility class.

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/CbrProxyAction.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/CbrProxyAction.java	2006-11-09 19:21:50 UTC (rev 7517)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/CbrProxyAction.java	2006-11-09 19:52:10 UTC (rev 7518)
@@ -26,7 +26,6 @@
 import java.net.URISyntaxException;
 import java.util.Collection;
 import java.util.Iterator;
-import java.util.UUID;
 
 import org.apache.log4j.Logger;
 import org.apache.log4j.Priority;
@@ -37,6 +36,7 @@
 import org.jboss.soa.esb.couriers.CourierException;
 import org.jboss.soa.esb.couriers.CourierFactory;
 import org.jboss.soa.esb.couriers.CourierTimeoutException;
+import org.jboss.soa.esb.couriers.CourierUtil;
 import org.jboss.soa.esb.helpers.ConfigTree;
 import org.jboss.soa.esb.listeners.ListenerTagNames;
 import org.jboss.soa.esb.message.Message;
@@ -45,6 +45,7 @@
 import org.jboss.soa.esb.services.registry.RegistryException;
 import org.jboss.soa.esb.services.registry.RegistryFactory;
 import org.jboss.soa.esb.services.routing.MessageRouter;
+import org.jboss.soa.esb.services.routing.MessageRouterException;
 
 
 /**
@@ -112,7 +113,7 @@
      * @param message
      * @return message, a collection of service destinations is added to the message.
      */
-    public Message route(Message message) 
+    public Message route(Message message) throws MessageRouterException
     {
     	message.getProperties().setProperty(MessageRouter.DELIVER_MESSAGES, Boolean.FALSE);
     	Message replyMessage=null;
@@ -130,7 +131,7 @@
 						JMSEpr jpr = (JMSEpr)epr;
 						JMSEpr replyEpr =  new JMSEpr(jpr.getDestinationType()  ,jpr.getDestinationName()
 							                         ,jpr.getConnectionFactory(),jpr.getJndiType()
-							                         ,jpr.getJndiURL()          ,getReplySelector());
+							                         ,jpr.getJndiURL()          ,CourierUtil.getReplySelector());
 						if (message.getHeader().getCall()==null) {
 							Call call = new Call();
 							message.getHeader().setCall(call);
@@ -140,8 +141,12 @@
 						if (courier.deliver(message)) 
 						{
 							courier.setReplyToEpr(replyEpr);
-							try { replyMessage = courier.pickup(_replyListenerTimeout); }
-							catch (CourierTimeoutException e) {}
+							try { 
+								replyMessage = courier.pickup(_replyListenerTimeout);
+						    } catch (CourierTimeoutException e) {
+								throw new MessageRouterException(e.getLocalizedMessage(),e);
+							}
+						    //if we get here we were successful so we can break from the loop and reply.
 							break;
 						} else {
 							_logger.warn("Could not deliver the message, maybe there is another JMS-EPR we can use.");
@@ -229,21 +234,5 @@
 	public Serializable getOkNotification(Message message) {
 		// TODO Auto-generated method stub
 		return null;
-	}  
-	public static final String CORRELATION_ID_TAG = "messageCorrelationId";
-    /**
-     * 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 static String getReplySelector()
-	{
-    	String uuId = UUID.randomUUID().toString();
-    	String uniqueReplySelector = new StringBuilder()
-		.append(CORRELATION_ID_TAG).append("='")
-		.append(uuId).append("'").toString();
-    	return uniqueReplySelector;
 	}
 } 
\ No newline at end of file

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java	2006-11-09 19:21:50 UTC (rev 7517)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java	2006-11-09 19:52:10 UTC (rev 7518)
@@ -143,7 +143,7 @@
 	 * send/publish a javax.jms.ObjectMessage (that will contain the serialized ESB Message)
 	 * @param jmsMessage
 	 */
-	protected void sendMessage(javax.jms.Message jmsMessage) throws JMSException
+	private void sendMessage(javax.jms.Message jmsMessage) throws JMSException
     {
     	if (_messageProducer instanceof TopicPublisher)
     		((TopicPublisher)_messageProducer).publish(jmsMessage);
@@ -182,7 +182,7 @@
 		}
     } //________________________________
     
-    protected void createMessageProducer() throws Exception
+    private void createMessageProducer() throws Exception
     {
         String sJndiType = _epr.getJndiType();
         if (Util.isNullString(sJndiType))
@@ -277,7 +277,7 @@
     	return null;
     } //________________________________
 
-    protected void createMessageConsumer() throws Exception
+    private void createMessageConsumer() throws Exception
     {
         String sJndiType = _epr.getJndiType();
         if (Util.isNullString(sJndiType))

Added: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierUtil.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierUtil.java	2006-11-09 19:21:50 UTC (rev 7517)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierUtil.java	2006-11-09 19:52:10 UTC (rev 7518)
@@ -0,0 +1,74 @@
+/*
+ * 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.couriers;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import org.jboss.soa.esb.helpers.KeyValuePair;
+import org.jboss.soa.esb.util.Util;
+
+public class CourierUtil
+{
+	public static final String CORRELATION_ID_TAG = "messageCorrelationId";
+	
+	private CourierUtil()
+	{
+	}
+
+	
+    public static List<KeyValuePair> propertiesFromSelector(String selector) throws Exception 
+    {
+		// No problem if selector is null - everything in queue will be returned
+		List<KeyValuePair> oRet = new ArrayList<KeyValuePair>();
+		if (! Util.isNullString(selector)) {
+			for (String sCurr : selector.split(",")) {
+				String[] sa = sCurr.split("=");
+				if (sa.length!=2
+				||  sa[1].charAt(0)!='\''
+				||  sa[1].charAt(-1+sa[1].length())!='\'')
+					throw new Exception("Illegal message selector syntax <"+selector+">");
+				KeyValuePair oNew = new KeyValuePair
+					(sa[0],sa[1].substring(0,-1+sa[1].length()).substring(1));
+				oRet.add(oNew);
+			}
+    	}
+		return oRet;
+    }
+    /**
+     * 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 static String getReplySelector()
+	{
+    	String uuId = UUID.randomUUID().toString();
+    	String uniqueReplySelector = new StringBuilder()
+		.append(CORRELATION_ID_TAG).append("='")
+		.append(uuId).append("'").toString();
+    	return uniqueReplySelector;
+	}
+}




More information about the jboss-svn-commits mailing list