[jboss-svn-commits] JBL Code SVN: r11010 - in labs/jbossesb/trunk/product: core/listeners/src/org/jboss/soa/esb/listeners and 13 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Apr 16 10:30:30 EDT 2007


Author: tfennelly
Date: 2007-04-16 10:30:30 -0400 (Mon, 16 Apr 2007)
New Revision: 11010

Modified:
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/Aggregator.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/ListenerUtil.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/AbstractFileGateway.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/JBossRemotingGatewayListener.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListener.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/Invoker.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/MessageDeliveryAdapter.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/UncomposedMessageDeliveryAdapter.java
   labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/JBossRemotingGatewayListenerUnitTest.java
   labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/message/MessageDeliveryAdapterUnitTest.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java
   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/SqlTableCourier.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourierImpl.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/Courier.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierCollection.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierFactory.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierUtil.java
   labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/MockCourier.java
   labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/MockCourierFactory.java
   labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/RegistryFactory.java
   labs/jbossesb/trunk/product/install/build.xml
   labs/jbossesb/trunk/product/samples/quickstarts/quickstarts.properties
   labs/jbossesb/trunk/product/samples/quickstarts/webservice_jbossws_adapter_01/jbmq-service.xml
   labs/jbossesb/trunk/product/samples/quickstarts/webservice_war1/src/quickstart/webservice_war1/MyAction.java
   labs/jbossesb/trunk/product/samples/quickstarts/webservice_war1/war/src/quickstart/webservice_war1/webservice/HelloWorldWS.java
Log:
Added synchronous invocation support to the JBR Gateway.
Added reply-to support to the action processing pipeline.

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/Aggregator.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/Aggregator.java	2007-04-16 14:17:59 UTC (rev 11009)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/Aggregator.java	2007-04-16 14:30:30 UTC (rev 11010)
@@ -53,7 +53,7 @@
 
 /**
  * Simple Aggregator. The aggregator relies on 'aggregatorTags'. To puzzle the individual
- * back together. The aggregatorTag is set in the MessageRouter.deliver() method. The aggregator
+ * back together. The aggregatorTag is set in the MessageRouter.deliverAsync() method. The aggregator
  * adds a collected message in the series as attachements to a new message. When all
  * messages are received or if we are timeout an aggregated message is returned. 
  * In all other cases null is returned.

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/ListenerUtil.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/ListenerUtil.java	2007-04-16 14:17:59 UTC (rev 11009)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/ListenerUtil.java	2007-04-16 14:30:30 UTC (rev 11010)
@@ -82,7 +82,7 @@
 		String service = "[" + category + "," + name + "]";
 		String txt = (null == all || all.size() < 1) ? "No EPRs registered for "
 				+ service
-				: "Unable to deliver message to registered EPRs for " + service;
+				: "Unable to deliverAsync message to registered EPRs for " + service;
 		throw new CourierException(txt);
 	} // ________________________________
 

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/AbstractFileGateway.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/AbstractFileGateway.java	2007-04-16 14:17:59 UTC (rev 11009)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/AbstractFileGateway.java	2007-04-16 14:30:30 UTC (rev 11010)
@@ -224,18 +224,18 @@
 					thrown = e;
 					if (null != _courier)
 						text = "Courier <" + _courier.getClass().getName()
-								+ ".deliver(Message) FAILED";
+								+ ".deliverAsync(Message) FAILED";
 					else
-						text = "NULL courier can't deliver Message";
+						text = "NULL courier can't deliverAsync Message";
 				}
 				catch (MalformedEPRException e)
 				{
 					thrown = e;
 					if (null != _courier)
 						text = "Courier <" + _courier.getClass().getName()
-								+ ".deliver(Message) FAILED with malformed EPR.";
+								+ ".deliverAsync(Message) FAILED with malformed EPR.";
 					else
-						text = "NULL courier can't deliver Message";
+						text = "NULL courier can't deliverAsync Message";
 				}
 
 				if (null == thrown)

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/JBossRemotingGatewayListener.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/JBossRemotingGatewayListener.java	2007-04-16 14:17:59 UTC (rev 11009)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/JBossRemotingGatewayListener.java	2007-04-16 14:30:30 UTC (rev 11010)
@@ -130,6 +130,10 @@
      * Listener endpoint EPR.
      */
     private EPR endpointReference;
+    /**
+     * Is the listener synchronous.
+     */
+    private boolean synchronous = true;
 
     /**
      * Construct the threaded managed lifecycle.
@@ -142,6 +146,7 @@
         super(config);
         serviceCategory = config.getAttribute(ListenerTagNames.TARGET_SERVICE_CATEGORY_TAG);
         serviceName = config.getAttribute(ListenerTagNames.TARGET_SERVICE_NAME_TAG);
+        synchronous = !config.getAttribute("synchronous", "true").equalsIgnoreCase("false");
     }
 
     /**
@@ -173,13 +178,13 @@
      */
 
     protected void doInitialise() throws ManagedLifecycleException {
-        if(isInitialised()) {
+        if (isInitialised()) {
             throw new ManagedLifecycleException("Unexpected request to initialise JBoss Remoting Gateway listener '" + getConfig().getName() + "'.  Gateway already initialised.");
         }
 
         try {
             endpointReference = new EPR(getJbrServerLocatorURI());
-            initialiseESBDeliveryAdapter();
+            messageDeliveryAdapter = createDeliveryAdapter();
             initaliseJBRConnectorConfiguration(connectorConfig);
         } catch (ConfigurationException e) {
             throw new ManagedLifecycleException("Remoting Listener configuration failed.", e);
@@ -189,10 +194,10 @@
     }
 
     protected void doStart() throws ManagedLifecycleException {
-        if(!isInitialised()) {
+        if (!isInitialised()) {
             throw new ManagedLifecycleException("Unexpected request to start JBoss Remoting Gateway listener '" + getConfig().getName() + "'.  Gateway not initialised.");
         }
-        if(isStarted()) {
+        if (isStarted()) {
             throw new ManagedLifecycleException("Unexpected request to start JBoss Remoting Gateway listener '" + getConfig().getName() + "'.  Gateway already started.");
         }
 
@@ -210,7 +215,7 @@
     }
 
     protected void doStop() throws ManagedLifecycleException {
-        if(!isStarted()) {
+        if (!isStarted()) {
             throw new ManagedLifecycleException("Unexpected request to stop JBoss Remoting Gateway listener '" + getConfig().getName() + "'.  Gateway not running.");
         }
 
@@ -291,12 +296,18 @@
      */
     public Object invoke(InvocationRequest invocationRequest) throws Throwable {
         try {
-            messageDeliveryAdapter.deliver(invocationRequest);
+            if (synchronous) {
+                Message reply = messageDeliveryAdapter.deliverSync(invocationRequest, 20000); // TODO Fix magic number
+                // Here's good old getContents issue again :-(
+                return new String(reply.getBody().getContents(), "UTF-8");
+            } else {
+                messageDeliveryAdapter.deliverAsync(invocationRequest);
+            }
         } catch (Throwable t) {
-            logger.error("JBoss Remoting Gateway failed to deliver message to target service [" +
+            logger.error("JBoss Remoting Gateway failed to " + (synchronous ? "synchronously" : "asynchronously") + " deliver message to target service [" +
                     messageDeliveryAdapter.getServiceCategory() + ":" +
                     messageDeliveryAdapter.getServiceName() + "].", t);
-            
+
             throw t;
         }
 
@@ -386,13 +397,13 @@
         }
     }
 
-
     /**
-     * Initialise the message delivery adpter for the target service.
+     * Factory method for adapter creation.
      *
+     * @return The adapter instance.
      * @throws ConfigurationException Configuration error.
      */
-    private void initialiseESBDeliveryAdapter() throws ConfigurationException {
+    protected UncomposedMessageDeliveryAdapter createDeliveryAdapter() throws ConfigurationException {
         String targetServiceCategory = getConfig().getAttribute(ListenerTagNames.TARGET_SERVICE_CATEGORY_TAG);
         String targetServiceName = getConfig().getAttribute(ListenerTagNames.TARGET_SERVICE_NAME_TAG);
         String composerClass = getConfig().getAttribute(ListenerTagNames.GATEWAY_COMPOSER_CLASS_TAG);
@@ -412,7 +423,8 @@
             } else {
                 composer = new JBossRemotingMessageComposer();
             }
-            messageDeliveryAdapter = new UncomposedMessageDeliveryAdapter(targetServiceCategory, targetServiceName, composer);
+
+            return new UncomposedMessageDeliveryAdapter(targetServiceCategory, targetServiceName, composer);
         } catch (RegistryException e) {
             throw new ConfigurationException("Remoting Listener configuration failed.", e);
         } catch (MessageDeliverException e) {
@@ -449,10 +461,10 @@
 
             // Copy the request properties onto the message...
             Map properties = invocationRequest.getRequestPayload();
-            if(properties != null) {
+            if (properties != null) {
                 Set<Map.Entry> propertyEntrySet = properties.entrySet();
                 for (Map.Entry entry : propertyEntrySet) {
-                    if(entry.getValue() != null) {
+                    if (entry.getValue() != null) {
                         message.getProperties().setProperty(entry.toString(), entry.getValue());
                     }
                 }

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListener.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListener.java	2007-04-16 14:17:59 UTC (rev 11009)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListener.java	2007-04-16 14:30:30 UTC (rev 11010)
@@ -166,7 +166,7 @@
                                 .getName() + "> returned a null object");
                         continue;
                     }
-                    // try to deliver the composed message, using the
+                    // try to deliverAsync the composed message, using the
                     // appropriate courier
                     // to the target service
                     try {
@@ -197,7 +197,7 @@
                     }
                     catch (CourierException e) {
                         String text = (null != _courier) ? "Courier <" + _courier
-                                .getClass().getName() + ".deliver(Message) FAILED" : "NULL courier can't deliver Message";
+                                .getClass().getName() + ".deliverAsync(Message) FAILED" : "NULL courier can't deliverAsync Message";
                         _logger.error(text, e);
                         continue;
                     }

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java	2007-04-16 14:17:59 UTC (rev 11009)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java	2007-04-16 14:30:30 UTC (rev 11010)
@@ -214,12 +214,12 @@
 				catch (CourierException e)
 				{
 					thrown = e;
-					text = "Courier <" + _courier.getClass().getName() + ".deliver(Message) FAILED";
+					text = "Courier <" + _courier.getClass().getName() + ".deliverAsync(Message) FAILED";
 				}
 				catch (MalformedEPRException ex)
 				{
 					thrown = ex;
-					text = "Courier <" + _courier.getClass().getName() + ".deliver(Message) FAILED with malformed EPR.";
+					text = "Courier <" + _courier.getClass().getName() + ".deliverAsync(Message) FAILED with malformed EPR.";
 				}
 
 				if (null == thrown)

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java	2007-04-16 14:17:59 UTC (rev 11009)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java	2007-04-16 14:30:30 UTC (rev 11010)
@@ -27,6 +27,12 @@
 
 import org.apache.log4j.Logger;
 import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.couriers.Courier;
+import org.jboss.soa.esb.couriers.CourierFactory;
+import org.jboss.soa.esb.couriers.CourierUtil;
+import org.jboss.soa.esb.couriers.CourierException;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.MalformedEPRException;
 import org.jboss.soa.esb.actions.ActionLifecycle;
 import org.jboss.soa.esb.actions.ActionPipelineProcessor;
 import org.jboss.soa.esb.actions.ActionProcessingException;
@@ -64,8 +70,7 @@
 
     /**
      * public constructor
-     * @param message Message - The initial message to be run through the whole action 
-     * class chain
+     * @param config The pipeline configuration.
      */
     public ActionProcessingPipeline(final ConfigTree config)
     	throws ConfigurationException
@@ -202,7 +207,8 @@
             
             final int numProcessors = processors.length ;
             final Message[] messages = new Message[numProcessors] ;
-            
+            final EPR replyToAddress = getReplyToAddress(message);
+
             Message currentMessage = message ;
             
             for(int count = 0 ; count < numProcessors ; count++)
@@ -215,16 +221,23 @@
                     currentMessage = processor.process(currentMessage) ;
                     if ((currentMessage == null) && (count < numProcessors-1))
                     {
+                        // TODO: If there's a replyToAddress, what should we reply??
                         throw new ActionProcessingException("Null message returned from action processor") ;
                     }
                 }
                 catch (final Exception ex)
                 {
                     LOGGER.warn("Unexpected exception caught while processing the action pipeline", ex) ;
+                    // TODO: If there's a replyToAddress, what should we reply??
                     notifyException(count, ex, messages) ;
                     return false ;
                 }
             }
+
+            // Reply...
+            if(replyToAddress != null) {
+                replyTo(replyToAddress, currentMessage);
+            }
             
             notifySuccess(messages) ;
             return true ;
@@ -235,7 +248,33 @@
             return false ;
         }
     }
-    
+
+    private EPR getReplyToAddress(Message message) {
+        try {
+            return message.getHeader().getCall().getReplyTo();
+        } catch (NullPointerException e) {
+            // OK, it's not set... return null...
+        }
+
+        return null;
+    }
+
+    private void replyTo(EPR replyToAddress, Message message) {
+        Courier courier = null;
+        try {
+            courier = CourierFactory.getCourier(replyToAddress);
+            courier.deliver(message);
+        } catch (CourierException e) {
+            LOGGER.error("Failed to reply to address " + replyToAddress + ".", e) ;
+        } catch (MalformedEPRException e) {
+            LOGGER.error("Failed to reply to address " + replyToAddress + ".", e) ;
+        } finally {
+            if(courier != null) {
+                CourierUtil.cleanCourier(courier);
+            }
+        }
+    }
+
     /**
      * Handle the destruction of the pipeline from the specified position.
      * @param initialPosition The initial position to begin destruction. 

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/Invoker.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/Invoker.java	2007-04-16 14:17:59 UTC (rev 11009)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/Invoker.java	2007-04-16 14:30:30 UTC (rev 11010)
@@ -58,7 +58,7 @@
 public class Invoker {
 
 	/**
-	 * Encapsulate command in an ESB Message, and deliver.
+	 * Encapsulate command in an ESB Message, and deliverAsync.
 	 * 
 	 * @param command AbstractCommandMessage - Transform into an ESB Message, and send
 	 * @param category String - Service category name for Registry inquiry
@@ -78,7 +78,7 @@
 	} //________________________________
 	
 	/**
-	 * Encapsulate command in an ESB Message, deliver it, and wait for a response Message.
+	 * Encapsulate command in an ESB Message, deliverAsync it, and wait for a response Message.
 	 * 
 	 * @param command AbstractCommandMessage - Transform into an ESB Message, and send
 	 * @param category String - Service category name for Registry inquiry

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/MessageDeliveryAdapter.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/MessageDeliveryAdapter.java	2007-04-16 14:17:59 UTC (rev 11009)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/MessageDeliveryAdapter.java	2007-04-16 14:30:30 UTC (rev 11010)
@@ -24,10 +24,8 @@
 import org.jboss.soa.esb.addressing.MalformedEPRException;
 import org.jboss.soa.esb.services.registry.RegistryException;
 import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.couriers.CourierFactory;
-import org.jboss.soa.esb.couriers.CourierUtil;
-import org.jboss.soa.esb.couriers.Courier;
-import org.jboss.soa.esb.couriers.CourierException;
+import org.jboss.soa.esb.couriers.*;
+import org.jboss.soa.esb.ConfigurationException;
 import org.jboss.internal.soa.esb.assertion.AssertArgument;
 import org.apache.log4j.Logger;
 
@@ -51,12 +49,12 @@
 
     /**
      * The <b>category name</b> of the Service to which this instance will
-     * deliver messages.
+     * deliverAsync messages.
      */
     private String serviceCategory;
     /**
      * The <b>name</b> of the Service to which this instance will
-     * deliver messages.
+     * deliverAsync messages.
      */
     private String serviceName;
     /**
@@ -71,12 +69,17 @@
     private EPR lastSuccessfulEPR;
 
     /**
+     * Synchronous courier "pickup" deliverAsync timeout.
+     */
+    private ThreadLocal<Long> syncPickupDeliveryTimeout = new ThreadLocal<Long>();
+
+    /**
      * Public constructor.
      *
      * @param serviceCategory The <b>category name</b> of the Service to which this instance will
-     *                        deliver messages.
+     *                        deliverAsync messages.
      * @param serviceName     The <b>name</b> of the Service to which this instance will
-     *                        deliver messages.
+     *                        deliverAsync messages.
      * @throws RegistryException Failed to lookup EPRs for the specified Service.
      */
     public MessageDeliveryAdapter(String serviceCategory, String serviceName) throws RegistryException {
@@ -89,33 +92,64 @@
     }
 
     /**
-     * Deliver the supplied message to this instance instances target service.
+     * Synchronously deliverAsync the supplied message to the target service associated with this adapter instance.
      *
+     * @param message       The message to be delivered.
+     * @param timeoutMillis Number of milliseconds before synchronous reply pickup should timeout.
+     * @return Returns the reply message if the message was delivered
+     *         without error, otherwise an exception is thrown.
+     * @throws MessageDeliverException Failed to deliverAsync message, after trying all available EPRs.
+     */
+    public Message deliverSync(Message message, long timeoutMillis) throws MessageDeliverException {
+        syncPickupDeliveryTimeout.set(timeoutMillis);
+        return deliver(message, true);
+    }
+
+    /**
+     * Asynchronously deliverAsync the supplied message to the target service associated with this adapter instance.
+     *
      * @param message The message to be delivered.
-     * @throws MessageDeliverException Failed to deliver message, after trying all available EPRs.
+     * @throws MessageDeliverException Failed to deliverAsync message, after trying all available EPRs.
      */
-    public void deliver(Message message) throws MessageDeliverException {
+    public void deliverAsync(Message message) throws MessageDeliverException {
+        // Not interested in a reply
+        deliver(message, false);
+    }
 
+    /**
+     * Deliver the supplied message to the target service associated with this adapter instance.
+     *
+     * @param message     The message to be delivered.
+     * @param synchronous Is the message to be delivered synchronously or not (asynchronously).
+     * @return Returns the message (or a reply message if synchronous) if the message was delivered
+     *         without error, otherwise an exception is thrown.
+     * @throws MessageDeliverException Failed to deliverAsync message, after trying all available EPRs.
+     */
+    private Message deliver(Message message, boolean synchronous) throws MessageDeliverException {
+        Message replyMessage = null;
+
         // If we have a cached version of an EPR that previously worked, try it first...
         if (lastSuccessfulEPR != null) {
-            if (attemptDelivery(message, lastSuccessfulEPR)) {
+            replyMessage = attemptDelivery(message, lastSuccessfulEPR, synchronous);
+            if (replyMessage != null) {
                 // We've successully delivered the message using the same EPR as worked the
                 // the last time.  We're done!...
-                return;
+                return replyMessage;
             }
         }
 
         // Iterate over all the EPRs in the list...
         for (EPR epr : serviceEprs) {
-            if (attemptDelivery(message, epr)) {
+            replyMessage = attemptDelivery(message, epr, synchronous);
+            if (replyMessage != null) {
                 // We've delivered it, we're done!
                 lastSuccessfulEPR = epr;
-                return;
+                return replyMessage;
             }
         }
 
         // Throw exception if delivery failed...
-        new MessageDeliverException("Failed to deliver message to Service [" + serviceCategory + ":" + serviceName + "].  Check for errors.");
+        throw new MessageDeliverException("Failed to deliverAsync message to Service [" + serviceCategory + ":" + serviceName + "].  Check for errors.");
     }
 
     /**
@@ -137,14 +171,16 @@
     }
 
     /**
-     * Attempt to deliver the supplied message using the supplied EPR.
+     * Attempt to deliverAsync the supplied message using the supplied EPR.
      *
-     * @param message The message to be delivered.
-     * @param epr     The EPR to be used in the delivery attempt.
-     * @return True if the message was delivered without error, otherwise false.
+     * @param message     The message to be delivered.
+     * @param epr         The EPR to be used in the delivery attempt.
+     * @param synchronous Is the message to be delivered synchronously or not (asynchronously).
+     * @return Returns the message (or a reply message if synchronous) if the message was delivered
+     *         without error, otherwise null.
      */
-    private boolean attemptDelivery(Message message, EPR epr) {
-        Courier courier = null;
+    private Message attemptDelivery(Message message, EPR epr, boolean synchronous) {
+        TwoWayCourier courier = null;
 
         // Get a courier for the EPR...
         try {
@@ -160,7 +196,24 @@
         // Try delivering the message using the courier we just looked up....
         if (courier != null) {
             try {
-                return courier.deliver(message);
+                EPR replyToEPR = null;
+
+                if (synchronous) {
+                    replyToEPR = getReplyToAddress(epr);
+                    if(replyToEPR == null) {
+                        logger.debug("Not using epr [" + epr + "] for Service [" + serviceCategory + ":" + serviceName + "]. No reply-to address available for synchronous response.");
+                        return null;
+                    }
+                    message.getHeader().getCall().setReplyTo(replyToEPR);
+                }
+                if (courier.deliver(message)) {
+                    if (replyToEPR != null) {
+                        courier.setReplyToEpr(replyToEPR);
+                        return courier.pickup(syncPickupDeliveryTimeout.get());
+                    } else {
+                        return message;
+                    }
+                }
             } catch (CourierException e) {
                 logger.warn("Badly formed EPR [" + epr + "] for Service [" + serviceCategory + ":" + serviceName + "]. " + e.getMessage());
             } catch (MalformedEPRException e) {
@@ -174,11 +227,12 @@
             }
         }
 
-        return false;
+        return null;
     }
 
     /**
      * Get the last EPR that "worked" on this instance.
+     *
      * @return Last successfully used EPR, or null if there was none.
      */
     protected EPR getLastSuccessfulEPR() {
@@ -186,6 +240,24 @@
     }
 
     /**
+     * Get the reply to address for synchronous delivery.
+     *
+     * @param toEpr The to address.
+     * @return The replyTo address.
+     * @throws ConfigurationException
+     */
+    protected EPR getReplyToAddress(EPR toEpr) throws ConfigurationException {
+        // This method just allows us to override Courier lookup during unit testing.
+        try {
+            return CourierUtil.getDefaultReplyToEpr(toEpr);
+        } catch (CourierException e) {
+            throw new ConfigurationException("Bad configuration. Unable to support synchronous reply on 'to' address " + toEpr, e);
+        } catch (MalformedEPRException e) {
+            throw new ConfigurationException("Bad configuration. Unable to support synchronous reply on 'to' address " + toEpr, e);
+        }
+    }
+
+    /**
      * Get a {@link org.jboss.soa.esb.couriers.Courier} for the supplied EPR.
      *
      * @param epr The EPR for which a {@link org.jboss.soa.esb.couriers.Courier}
@@ -194,7 +266,7 @@
      * @throws CourierException      A courier implementation cannot be created.
      * @throws MalformedEPRException Bad EPR.
      */
-    protected Courier getCourier(EPR epr) throws CourierException, MalformedEPRException {
+    protected TwoWayCourier getCourier(EPR epr) throws CourierException, MalformedEPRException {
         // This method just allows us to override Courier lookup during unit testing.
         return CourierFactory.getInstance().getMessageCourier(epr);
     }

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/UncomposedMessageDeliveryAdapter.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/UncomposedMessageDeliveryAdapter.java	2007-04-16 14:17:59 UTC (rev 11009)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/UncomposedMessageDeliveryAdapter.java	2007-04-16 14:30:30 UTC (rev 11010)
@@ -40,9 +40,9 @@
      * Public constructor.
      *
      * @param serviceCategory The <b>category name</b> of the Service to which this instance will
-     *                        deliver messages.
+     *                        deliverAsync messages.
      * @param serviceName     The <b>name</b> of the Service to which this instance will
-     *                        deliver messages.
+     *                        deliverAsync messages.
      * @param composer        The the message composer class for this delivery instance.
      * @throws org.jboss.soa.esb.services.registry.RegistryException
      *          Failed to lookup EPRs for the specified Service.
@@ -53,18 +53,33 @@
         this.composer = composer;
     }
 
+    /**
+     * Synchronously deliverAsync the supplied message to the target service associated with this adapter instance.
+     *
+     * @param messagePayload Message payload to be packaged, or a channel specific
+     *                       container class for the message payload (e.g. a JMS message).
+     * @param timeoutMillis  Number of milliseconds before synchronous reply pickup should timeout.
+     * @return The reply {@link Message}.  The caller must decompose the message.
+     * @throws MessageDeliverException Failed to deliverAsync message, after trying all available EPRs.
+     */
+    public Message deliverSync(Object messagePayload, long timeoutMillis) throws MessageDeliverException {
+        AssertArgument.isNotNull(messagePayload, "messagePayload");
+        Message message = composer.compose(messagePayload);
 
+        return super.deliverSync(message, timeoutMillis);
+    }
+
     /**
-     * Deliver the supplied message to this instance instances target service.
+     * Asynchronously deliverAsync the supplied message to the target service associated with this adapter instance.
      *
      * @param messagePayload Message payload to be packaged, or a channel specific
      *                       container class for the message payload (e.g. a JMS message).
-     * @throws MessageDeliverException Failed to deliver message, after trying all available EPRs.
+     * @throws MessageDeliverException Failed to deliverAsync message, after trying all available EPRs.
      */
-    public void deliver(Object messagePayload) throws MessageDeliverException {
+    public void deliverAsync(Object messagePayload) throws MessageDeliverException {
         AssertArgument.isNotNull(messagePayload, "messagePayload");
         Message message = composer.compose(messagePayload);
 
-        super.deliver(message);
+        super.deliverAsync(message);
     }
 }

Modified: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/JBossRemotingGatewayListenerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/JBossRemotingGatewayListenerUnitTest.java	2007-04-16 14:17:59 UTC (rev 11009)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/JBossRemotingGatewayListenerUnitTest.java	2007-04-16 14:30:30 UTC (rev 11010)
@@ -22,9 +22,12 @@
 import junit.framework.TestCase;
 import org.jboss.soa.esb.helpers.ConfigTree;
 import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.services.registry.RegistryException;
+import org.jboss.soa.esb.addressing.EPR;
 import org.jboss.soa.esb.actions.ActionUtils;
 import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
 import org.jboss.soa.esb.listeners.ListenerTagNames;
+import org.jboss.soa.esb.listeners.message.UncomposedMessageDeliveryAdapter;
 import org.jboss.internal.soa.esb.couriers.MockCourierFactory;
 import org.jboss.internal.soa.esb.couriers.MockCourier;
 import org.jboss.internal.soa.esb.services.registry.MockRegistry;
@@ -33,6 +36,8 @@
 import org.xml.sax.SAXException;
 
 import java.net.InetAddress;
+import java.util.Map;
+import java.util.HashMap;
 
 /**
  * JBossRemotingGatewayListenerUnit unit tests.
@@ -44,16 +49,20 @@
 
     private MockCourier courier1;
     private MockCourier courier2;
-    
+    private EPR epr3 = new EPR();
+    private MockCourier courier3;
+
     protected void setUp() throws Exception {
         MockCourierFactory.install();
         MockRegistry.install();
 
         courier1 = new MockCourier(false); // Will fail
         courier2 = new MockCourier(true);  // Will work
+        courier3 = new MockCourier(true);  // Will work
         MockRegistry.register("cat", "servicex", courier1);
         MockRegistry.register("cat", "servicex", courier2);
-    }
+        MockRegistry.register("cat", "servicex", epr3, courier3);
+     }
 
     protected void tearDown() throws Exception {
         MockRegistry.uninstall();
@@ -123,22 +132,27 @@
         assertTrue(!listener.isStarted());
     }
 
-    public void test_http() throws Throwable {
-        test_delivery("http");
+    public void test_http_async() throws Throwable {
+        test_delivery("http", false);
     }
 
-    public void test_socket() throws Throwable {
-        test_delivery("socket");
+    public void x_test_http_sync() throws Throwable {
+        test_delivery("http", true);
+        System.out.println("Ho " + courier3);
     }
 
-    public void test_delivery(String protocol) throws Throwable {
-        startServer(protocol);
+    public void test_socket_() throws Throwable {
+        test_delivery("socket", false);
+    }
+
+    public void test_delivery(String protocol, boolean synchronous) throws Throwable {
+        startServer(protocol, synchronous);
         sendMessageToServer(protocol, protocol + "_payload");
         stopServer();
     }
 
     public void x_test_profile() throws Throwable {
-        startServer("http");
+        startServer("http", false);
         for(int i = 0; i < 10000; i++) {
             sendMessageToServer("http", "xxx_payload");
             MockCourierFactory.resetCouriers();
@@ -147,10 +161,29 @@
         stopServer();
     }
 
-    private void startServer(String protocol) throws SAXException, ConfigurationException, ManagedLifecycleException {
+    private void startServer(String protocol, boolean synchronous) throws SAXException, ConfigurationException, ManagedLifecycleException {
         ConfigTree config = getConfig("cat", "servicex", protocol, "8888");
 
-        listener = new JBossRemotingGatewayListener(config);
+        if(synchronous) {
+            listener = new JBossRemotingGatewayListener(config) {
+                protected UncomposedMessageDeliveryAdapter createDeliveryAdapter() throws ConfigurationException {
+                    try {
+                        return new UncomposedMessageDeliveryAdapter("cat", "servicex", new JBossRemotingMessageComposer()) {
+                            protected EPR getReplyToAddress(EPR toEpr) throws ConfigurationException {
+                                return epr3;
+                            }
+                        };
+                    } catch (RegistryException e) {
+                        e.printStackTrace();
+                        fail(e.getMessage());
+                        return null;
+                    }
+                }
+            };
+        } else {
+            config.setAttribute("synchronous", "false");
+            listener = new JBossRemotingGatewayListener(config);
+        }
 
         listener.doInitialise();
         listener.doStart();

Modified: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/message/MessageDeliveryAdapterUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/message/MessageDeliveryAdapterUnitTest.java	2007-04-16 14:17:59 UTC (rev 11009)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/message/MessageDeliveryAdapterUnitTest.java	2007-04-16 14:30:30 UTC (rev 11010)
@@ -49,7 +49,7 @@
     private MockCourier courier3;
     private MockCourier courier4;
     private MockCourier courier5;
-    private UncomposedMessageDeliveryAdapter mediator;
+    private UncomposedMessageDeliveryAdapter deliveryAdapter;
     private String payload = "*XX*";
 
     protected void setUp() throws Exception {
@@ -73,7 +73,7 @@
         MockRegistry.register("cat", "service", epr4, courier4);
         MockRegistry.register("cat", "service", epr5, courier5);
 
-        mediator = new UncomposedMessageDeliveryAdapter("cat", "service", new MockMessageComposer());
+        deliveryAdapter = new UncomposedMessageDeliveryAdapter("cat", "service", new MockMessageComposer());
     }
 
     protected void tearDown() throws Exception {
@@ -84,40 +84,55 @@
     public void test_getCourier_CourierException() throws MessageDeliverException {
         // Get the courier factory to throw a CourierException
         MockCourierFactory.courierException = new CourierException("");
-        mediator.deliver(payload);
+        try {
+            deliveryAdapter.deliverAsync(payload);
+            fail("Expected MessageDeliverException");
+        } catch(MessageDeliverException e) {
+            // Expected.
+        }
         assertNoDeliveryAttempted();
     }
 
     public void test_getCourier_MalformedEPRException() throws MessageDeliverException {
         // Get the courier factory to throw a MalformedEPRException
         MockCourierFactory.malformedEPRException = new MalformedEPRException("");
-        mediator.deliver(payload);
+        try {
+            deliveryAdapter.deliverAsync(payload);
+            fail("Expected MessageDeliverException");
+        } catch(MessageDeliverException e) {
+            // Expected.
+        }
         assertNoDeliveryAttempted();
     }
 
     public void test_No_EPRs() throws RegistryException, MessageDeliverException {
         // Make sure there's no attempt to make a delivery when there's no
         // EPRs for the service.
-        mediator = new UncomposedMessageDeliveryAdapter("x", "y", new MockMessageComposer());
-        mediator.deliver(payload);
+        deliveryAdapter = new UncomposedMessageDeliveryAdapter("x", "y", new MockMessageComposer());
+        try {
+            deliveryAdapter.deliverAsync(payload);
+            fail("Expected MessageDeliverException");
+        } catch(MessageDeliverException e) {
+            // Expected.
+        }
         assertNoDeliveryAttempted();
     }
 
     public void test_deliver() throws MessageDeliverException {
         // Make sure the delivery happens as expected...
 
-        mediator.deliver(payload);
+        deliveryAdapter.deliverAsync(payload);
         assertEquals(null, courier1.message);
         assertEquals(null, courier2.message);
         assertEquals(null, courier3.message);
         assertEquals(payload, ActionUtils.getTaskObject(courier4.message));
         assertEquals(null, courier5.message);
 
-        assertEquals(epr4, mediator.getLastSuccessfulEPR());
+        assertEquals(epr4, deliveryAdapter.getLastSuccessfulEPR());
         String payload2 = "*YYY*";
-        mediator.deliver(payload2);
+        deliveryAdapter.deliverAsync(payload2);
         assertEquals(payload2, ActionUtils.getTaskObject(courier4.message));
-        assertEquals(epr4, mediator.getLastSuccessfulEPR());
+        assertEquals(epr4, deliveryAdapter.getLastSuccessfulEPR());
     }
 
     private void assertNoDeliveryAttempted() {
@@ -126,7 +141,7 @@
            courier3.deliveryAttempted ||
            courier4.deliveryAttempted ||
            courier5.deliveryAttempted) {
-            fail("A deliver attempt was made on one of the couriers.");
+            fail("A deliverAsync attempt was made on one of the couriers.");
         }
     }
 

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java	2007-04-16 14:17:59 UTC (rev 11009)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java	2007-04-16 14:30:30 UTC (rev 11010)
@@ -130,7 +130,7 @@
 				File file = new File(_url.getFile());
 				if ((!_receiverOnly) && (!file.isDirectory()))
 					throw new CourierException(
-							"File for deliver EPR must be a directory (file name will be MessageID)");
+							"File for deliverAsync EPR must be a directory (file name will be MessageID)");
 
 				File directory = (file.isDirectory()) ? file : file
 						.getParentFile();
@@ -162,7 +162,7 @@
 	 * package the ESB message in a File
 	 * 
 	 * @param message
-	 *            Message - the message to deliver
+	 *            Message - the message to deliverAsync
 	 * @return boolean - the result of the delivery
 	 * @throws CourierException -
 	 *             if problems were encountered

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	2007-04-16 14:17:59 UTC (rev 11009)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java	2007-04-16 14:30:30 UTC (rev 11010)
@@ -127,7 +127,7 @@
 	 * package the ESB message in a javax.jms.ObjectMessage, and send it
 	 * 
 	 * @param message
-	 *            Message - the message to deliver
+	 *            Message - the message to deliverAsync
 	 * @return boolean - the result of the delivery
 	 * @throws CourierException -
 	 *             if problems were encountered

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java	2007-04-16 14:17:59 UTC (rev 11009)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java	2007-04-16 14:30:30 UTC (rev 11010)
@@ -106,7 +106,7 @@
 	 * package the ESB message in a java.io.Serializable, and write it
 	 * 
 	 * @param message
-	 *            Message - the message to deliver
+	 *            Message - the message to deliverAsync
 	 * @return boolean - the result of the delivery
 	 * @throws CourierException -
 	 *             if problems were encountered

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourierImpl.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourierImpl.java	2007-04-16 14:17:59 UTC (rev 11009)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/TwoWayCourierImpl.java	2007-04-16 14:30:30 UTC (rev 11010)
@@ -154,7 +154,7 @@
 			MalformedEPRException
 	{
 		if (null == _deliverCourier)
-			throw new CourierException("No deliver courier");
+			throw new CourierException("No deliverAsync courier");
 		return _deliverCourier.deliver(message);
 	}
 

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/Courier.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/Courier.java	2007-04-16 14:17:59 UTC (rev 11009)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/Courier.java	2007-04-16 14:30:30 UTC (rev 11010)
@@ -35,9 +35,9 @@
 public interface Courier extends DeliverOnlyCourier
 {
 	/**
-	 * Try to deliver an ESB message. This is a one shot delivery.
+	 * Try to deliverAsync an ESB message. This is a one shot delivery.
 	 * 
-	 * @param message Message - the message to deliver 
+	 * @param message Message - the message to deliverAsync
 	 * @return boolean - the result of the delivery
 	 * @throws CourierException - if problems were encountered
 	 */

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierCollection.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierCollection.java	2007-04-16 14:17:59 UTC (rev 11009)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierCollection.java	2007-04-16 14:30:30 UTC (rev 11010)
@@ -83,7 +83,7 @@
     
     /**
      * Deliver the message to the list of couriers.
-     * @param message The message to deliver.
+     * @param message The message to deliverAsync.
      * @throws CourierException For processing errors.
      * @throws MalformedEPRException For configuration errors.
      */

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierFactory.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierFactory.java	2007-04-16 14:17:59 UTC (rev 11009)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierFactory.java	2007-04-16 14:30:30 UTC (rev 11010)
@@ -84,18 +84,18 @@
     /**
 	 * Obtain a courier which can perform deliveries only and prime it with the "to address" (toEPR).
 	 *
-	 * @param toEPR - the 'to address', the address on where to deliver a Message.
-	 * @return
+	 * @param toEPR - the 'to address', the address on where to deliverAsync a Message.
+	 * @return The courier.
 	 * @throws CourierException if the specific courier implementation cannot be created.
 	 */
-	public Courier getMessageCourier(EPR toEPR) throws CourierException, MalformedEPRException {
-        return getCourier(toEPR);
+	public TwoWayCourier getMessageCourier(EPR toEPR) throws CourierException, MalformedEPRException {
+        return getCourier(toEPR, null);
     }
 
     /**
 	 * Obtain a courier which can perform deliveries only and prime it with the "to address" (toEPR).
 	 * 
-	 * @param toEPR - the 'to address', the address on where to deliver a Message.
+	 * @param toEPR - the 'to address', the address on where to deliverAsync a Message.
 	 * @return
 	 * @throws CourierException if the specific courier implementation cannot be created.
 	 */
@@ -107,7 +107,7 @@
 	 * Obtain a courier which can perform pickups only and prime it with the "to address" (toEPR) 
 	 * and the "replyTo address" (replyToEPR). 
 	 * 
-	 * @parem replyToEPR - the 'replyTo address', the address where to deliver the Message we pickup.
+	 * @parem replyToEPR - the 'replyTo address', the address where to deliverAsync the Message we pickup.
 	 * @return
 	 * @throws CourierException if the specific courier implementation cannot be created.
 	 */
@@ -119,8 +119,8 @@
 	 * Obtain a courier which can perform both deliveries and pickups and prime it with 
 	 * the "to address" (toEPR) and the "replyTo address" (replyToEPR). 
 	 * 
-	 * @param toEPR      - the 'to address', the address on where to deliver a Message.
-	 * @parem replyToEPR - the 'replyTo address', the address where to deliver the Message we pickup.
+	 * @param toEPR      - the 'to address', the address on where to deliverAsync a Message.
+	 * @parem replyToEPR - the 'replyTo address', the address where to deliverAsync the Message we pickup.
 	 * @return
 	 * @throws CourierException if the specific courier implementation cannot be created.
 	 */

Modified: 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	2007-04-16 14:17:59 UTC (rev 11009)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/couriers/CourierUtil.java	2007-04-16 14:30:30 UTC (rev 11010)
@@ -74,7 +74,8 @@
 	public static EPR getDefaultReplyToEpr(EPR toEpr)
 			throws CourierException, MalformedEPRException
 	{
-		try
+        // TODO: Is this really a "Courier" utility?  Looks more like an EPR/EPRFactory utility?
+        try
 		{
 			if (null==toEpr)				
 				throw new IllegalArgumentException("toEpr must not be null");

Modified: labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/MockCourier.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/MockCourier.java	2007-04-16 14:17:59 UTC (rev 11009)
+++ labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/MockCourier.java	2007-04-16 14:30:30 UTC (rev 11010)
@@ -21,17 +21,21 @@
 
 import org.jboss.soa.esb.couriers.Courier;
 import org.jboss.soa.esb.couriers.CourierException;
+import org.jboss.soa.esb.couriers.TwoWayCourier;
+import org.jboss.soa.esb.couriers.CourierTimeoutException;
 import org.jboss.soa.esb.message.Message;
 import org.jboss.soa.esb.addressing.MalformedEPRException;
+import org.jboss.soa.esb.addressing.EPR;
 
 /**
  * Mock Courier impl.
  * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
  */
-public class MockCourier  implements Courier {
+public class MockCourier implements TwoWayCourier {
 
     public boolean deliveryResult = true;
     public Message message;
+    public Message pickupMessage;
     public boolean deliveryAttempted = false;
     public CourierException courierException;
     public MalformedEPRException malformedEPRException;
@@ -72,4 +76,18 @@
         message = null;
         deliveryAttempted = false;
     }
+
+    public Message pickup(long waitTime) throws CourierException, CourierTimeoutException {
+        return pickupMessage;
+    }
+
+    public Message pickup(long waitTime, EPR epr) throws CourierException, CourierTimeoutException, MalformedEPRException {
+        return pickupMessage;
+    }
+
+    public void setToEpr(EPR toEPR) throws CourierException, MalformedEPRException {
+    }
+
+    public void setReplyToEpr(EPR replyToEPR) throws CourierException, MalformedEPRException {
+    }
 }

Modified: labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/MockCourierFactory.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/MockCourierFactory.java	2007-04-16 14:17:59 UTC (rev 11009)
+++ labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/MockCourierFactory.java	2007-04-16 14:30:30 UTC (rev 11010)
@@ -22,6 +22,7 @@
 import org.jboss.soa.esb.couriers.CourierFactory;
 import org.jboss.soa.esb.couriers.Courier;
 import org.jboss.soa.esb.couriers.CourierException;
+import org.jboss.soa.esb.couriers.TwoWayCourier;
 import org.jboss.soa.esb.addressing.EPR;
 import org.jboss.soa.esb.addressing.MalformedEPRException;
 
@@ -36,10 +37,10 @@
 
     public static CourierException courierException;
     public static MalformedEPRException malformedEPRException;
-    public static Hashtable<EPR, Courier> couriers = new Hashtable<EPR, Courier>();
+    public static Hashtable<EPR, TwoWayCourier> couriers = new Hashtable<EPR, TwoWayCourier>();
     private static CourierFactory originalInstance;
     
-    public Courier getMessageCourier(EPR toEPR) throws CourierException, MalformedEPRException {
+    public TwoWayCourier getMessageCourier(EPR toEPR) throws CourierException, MalformedEPRException {
         if(courierException != null) {
             throw courierException;
         } else if(malformedEPRException != null) {
@@ -66,7 +67,7 @@
     }
 
     public static void resetCouriers() {
-        for (Map.Entry<EPR, Courier> entry : couriers.entrySet()) {
+        for (Map.Entry<EPR, TwoWayCourier> entry : couriers.entrySet()) {
             ((MockCourier)entry.getValue()).reset();
         }
     }

Modified: labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/RegistryFactory.java
===================================================================
--- labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/RegistryFactory.java	2007-04-16 14:17:59 UTC (rev 11009)
+++ labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/RegistryFactory.java	2007-04-16 14:30:30 UTC (rev 11010)
@@ -60,7 +60,7 @@
 
       try
 		{
-			// instruct class loader to load the Registry Implementation
+            // instruct class loader to load the Registry Implementation
          Class registryClass = ClassUtil.forName(className, RegistryFactory.class);
          // Try to instance the Registry
          registry = (Registry) registryClass.newInstance();

Modified: labs/jbossesb/trunk/product/install/build.xml
===================================================================
--- labs/jbossesb/trunk/product/install/build.xml	2007-04-16 14:17:59 UTC (rev 11009)
+++ labs/jbossesb/trunk/product/install/build.xml	2007-04-16 14:30:30 UTC (rev 11010)
@@ -7,7 +7,7 @@
 	<!-- Load Build Properties File -->
 	<property file="${org.jboss.esb.deployment.properties}"/>
 	
-	<target name="deploy"   depends="sar.deploy"   description="Wrapper for jboss.sar.deploy"/>
+	<target name="deploy"   depends="sar.deploy,jboss-esb.war.deploy"   description="Wrapper for jboss.sar.deploy"/>
 	<target name="tomcat"   depends="tomcat.war.all.deploy"  description="Wrapper for tomcat.war.all.deploy"/>
 	
 	<target name="sar.deploy" description="Deploys JBossESB to the server">
@@ -15,6 +15,11 @@
          <fileset dir="${org.jboss.esb.dist.lib}" includes="jbossesb.sar/**"/></copy>
 	</target>
 	
+	<target name="jboss-esb.war.deploy" description="Deploys JBossESB Endpoint Deployment Listing App to the server">
+      <copy  todir="${org.jboss.esb.server.home}/server/${org.jboss.esb.server.config}/deploy">
+         <fileset dir="${org.jboss.esb.dist.lib}" includes="jboss-esb.war"/></copy>
+	</target>
+	
 	<!-- Tomcat war deployment -->
 	<path id="classpath">
 		<fileset dir="${org.jboss.esb.dist.lib}" includes="**/*jar"/>

Modified: labs/jbossesb/trunk/product/samples/quickstarts/quickstarts.properties
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/quickstarts.properties	2007-04-16 14:17:59 UTC (rev 11009)
+++ labs/jbossesb/trunk/product/samples/quickstarts/quickstarts.properties	2007-04-16 14:30:30 UTC (rev 11010)
@@ -8,13 +8,13 @@
 # "../../../build/jbossesb/lib" and "jbosshome.dir" to point to "../../../build/jbossesb-server-4.2.MR1/".
 # DO NOT CHECK THIS IN!
 ##############################################################################################
-#esb.product.lib.dir=../../../build/jbossesb/lib
-esb.product.lib.dir=../../../lib
+esb.product.lib.dir=../../../build/jbossesb/lib
+#esb.product.lib.dir=../../../lib
 
 # Location of your JBoss Application Server installation.
 # NB: Avoid using back slashes '\' in the path - '/' works on all platforms.
 #jbosshome.dir=../../../build/jbossesb-server-4.2.MR1/
-jbosshome.dir=/jbossesb-server-4.2.MR1
+jbosshome.dir=/jboss-4.0.5.GA
 
 # If you are running the ftp tests then you must complete the following
 jbossesb.ftp.hostname=

Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_jbossws_adapter_01/jbmq-service.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_jbossws_adapter_01/jbmq-service.xml	2007-04-16 14:17:59 UTC (rev 11009)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_jbossws_adapter_01/jbmq-service.xml	2007-04-16 14:30:30 UTC (rev 11010)
@@ -12,4 +12,10 @@
             jboss.mq:service=DestinationManager
         </depends>
     </mbean>
+    <mbean code="org.jboss.mq.server.jmx.Queue"
+           name="jboss.mq.destination:service=Queue,name=quickstart_webservice_jbossws_adapter_01_esb_reply">
+        <depends optional-attribute-name="DestinationManager">
+            jboss.mq:service=DestinationManager
+        </depends>
+    </mbean>
 </server>
\ No newline at end of file

Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_war1/src/quickstart/webservice_war1/MyAction.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_war1/src/quickstart/webservice_war1/MyAction.java	2007-04-16 14:17:59 UTC (rev 11009)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_war1/src/quickstart/webservice_war1/MyAction.java	2007-04-16 14:30:30 UTC (rev 11010)
@@ -31,59 +31,52 @@
 import org.jboss.soa.esb.couriers.CourierFactory;
 import org.jboss.soa.esb.couriers.CourierUtil;
 
-public class MyAction extends AbstractActionLifecycle
-{
-    
-  protected ConfigTree	_config;
-	  
-  public MyAction(ConfigTree config) { _config = config; } 
-  
-  public Message noOperation(Message message) { return message; } 
+public class MyAction extends AbstractActionLifecycle {
 
-  public Message displayMessage(Message message) throws Exception{		
-		  logHeader();
-		  System.out.println("Body: " + new String(message.getBody().getContents()));
-		  logFooter();
-		  return message;         	
-	}
-  
-   public Message playWithMessage(Message message) throws Exception {
-	   Body msgBody = message.getBody();
-     String results = new String();
-	   String contents = new String(msgBody.getContents());
-     results = "Hello From ESB MyAction: " + contents;
-	   // msgBody.setContents(results.getBytes());
-	   Message replyMessage = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);				
-		 replyMessage.getBody().setContents(results.getBytes());
-		 EPR replyEPR = message.getHeader().getCall().getReplyTo();
-		 final Courier courier = CourierFactory.getCourier(replyEPR) ;
-                 try
-                 {
-                     courier.deliver(replyMessage); 
-                 }
-                 finally
-                 {
-                     CourierUtil.cleanCourier(courier) ;
-                 }
-	   return replyMessage;
-   }
-   
-   public void exceptionHandler(Message message, Throwable exception) {
-	   logHeader();
-	   System.out.println("!ERROR!");
-	   System.out.println(exception.getMessage());
-	   System.out.println("For Message: ");
-	   System.out.println(message.getBody().getContents());
-	   logFooter();
-   }
-	
-   // This makes it easier to read on the console
-   private void logHeader() {
-	   System.out.println("\n&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");
-   }
-   private void logFooter() {
-	   System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&\n");
-   }
-    
-	
+    protected ConfigTree _config;
+
+    public MyAction(ConfigTree config) {
+        _config = config;
+    }
+
+    public Message noOperation(Message message) {
+        return message;
+    }
+
+    public Message displayMessage(Message message) throws Exception {
+        logHeader();
+        System.out.println("Body: " + new String(message.getBody().getContents()));
+        logFooter();
+        return message;
+    }
+
+    public Message playWithMessage(Message message) throws Exception {
+        Body msgBody = message.getBody();
+        String contents = new String(msgBody.getContents());
+
+        // Reset the message body contents with the response...
+        msgBody.setContents(("Hello From ESB MyAction: " + contents).getBytes());
+
+        return message;
+    }
+
+    public void exceptionHandler(Message message, Throwable exception) {
+        logHeader();
+        System.out.println("!ERROR!");
+        System.out.println(exception.getMessage());
+        System.out.println("For Message: ");
+        System.out.println(message.getBody().getContents());
+        logFooter();
+    }
+
+    // This makes it easier to read on the console
+    private void logHeader() {
+        System.out.println("\n&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");
+    }
+
+    private void logFooter() {
+        System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&\n");
+    }
+
+
 }
\ No newline at end of file

Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_war1/war/src/quickstart/webservice_war1/webservice/HelloWorldWS.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_war1/war/src/quickstart/webservice_war1/webservice/HelloWorldWS.java	2007-04-16 14:17:59 UTC (rev 11009)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_war1/war/src/quickstart/webservice_war1/webservice/HelloWorldWS.java	2007-04-16 14:30:30 UTC (rev 11010)
@@ -21,11 +21,11 @@
 package quickstart.webservice_war1.webservice;
 
 // For setting up the basic WS
+
 import javax.jws.WebMethod;
 import javax.jws.WebService;
-import javax.jws.soap.SOAPBinding; 
+import javax.jws.soap.SOAPBinding;
 
-
 // For ESB Interaction
 import org.jboss.soa.esb.services.registry.Registry; // jbossesb-services.jar
 import org.jboss.soa.esb.services.registry.RegistryFactory; // jbossesb-services.jar
@@ -36,62 +36,40 @@
 import org.jboss.soa.esb.couriers.TwoWayCourier; // jbossesb-rosetta.jar
 import org.jboss.soa.esb.couriers.CourierFactory; // jbossesb-rosetta.jar
 import org.jboss.soa.esb.couriers.CourierUtil; // jbossesb-rosetta.jar
-import org.jboss.soa.esb.addressing.Call; // jbossesb-rosetta.jar
+import org.jboss.soa.esb.addressing.Call;
+import org.jboss.soa.esb.listeners.message.MessageDeliveryAdapter; // jbossesb-rosetta.jar
 
- at WebService(name = "HelloWorld", targetNamespace="http://webservice_war1/helloworld")
+ at WebService(name = "HelloWorld", targetNamespace = "http://webservice_war1/helloworld")
 @SOAPBinding(style = SOAPBinding.Style.RPC)
-public class HelloWorldWS
-{
-   @WebMethod
-   public String sayHello(String toWhom)
-   {
-   	  System.out.println("I'm Hit! " + toWhom);
-   	  String results = "";
-   	  try {		
-	   	  
-	   	  Registry registry = RegistryFactory.getRegistry();
-	   	  
-	   	  Message requestMessage = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
-	   	  requestMessage.getBody().setContents(toWhom.getBytes()); // inject the value from the WS client
-	   	  
-	   	  Message replyMessage=null;
+public class HelloWorldWS {
+    @WebMethod
+    public String sayHello(String toWhom) {
+        System.out.println("HelloWorld Hit! " + toWhom);
+        String results = "";
+        try {
+            MessageDeliveryAdapter deliveryAdapter;
+            Message requestMessage;
+            Message replyMessage = null;
 
-	   	  EPR requestEPR = (EPR)registry.findEPR("MyServiceCategory", "MyService"); // from HelloWorld quickstart
-	   	  
-	   	  EPR replyEPR = CourierUtil.getDefaultReplyToEpr(requestEPR);
-	   	  TwoWayCourier courier = CourierFactory.getCourier(requestEPR, null);	 
-	   	  
-                  try
-                  {
-                          if (requestMessage.getHeader().getCall()==null) {
-                                        Call call = new Call();
-                                        requestMessage.getHeader().setCall(call);
-                                }
-                  requestMessage.getHeader().getCall().setReplyTo(replyEPR);
-                  if (courier.deliver(requestMessage))
-                                {
-                                                        courier.setReplyToEpr(replyEPR); // why?
-                                
-                                                        replyMessage = courier.pickup(5000); // attempt for 5 secs
-                                                        
-                                }
-                  }
-                  finally
-                  {
-                      CourierUtil.cleanCourier(courier) ;
-                  }
-	
-			  if (replyMessage != null) {
-	     	  results = new String(replyMessage.getBody().getContents());
-	     	} else {
-	     		results = "Hello World: " + toWhom + " on " + new java.util.Date();
-	      }
-      } catch (Exception e) {      	
-      	System.out.println(e + "\n");
-      	e.printStackTrace(System.out);
-      }
-      return results;
-   }
+            // Create the delivery adapter for the target service (you'd normally cache this!!)...
+            deliveryAdapter = new MessageDeliveryAdapter("MyServiceCategory", "MyService");
+            // Create and populate the request message...
+            requestMessage = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+            requestMessage.getBody().setContents(toWhom.getBytes()); // inject the value from the WS client
+            // Deliver the request message synchronously - timeout after 20 seconds... 
+            replyMessage = deliveryAdapter.deliverSync(requestMessage, 20000);
+
+            if (replyMessage != null) {
+                results = new String(replyMessage.getBody().getContents());
+            } else {
+                results = "Hello World: " + toWhom + " on " + new java.util.Date();
+            }
+        } catch (Exception e) {
+            System.out.println(e + "\n");
+            e.printStackTrace(System.out);
+        }
+        return results;
+    }
 }
 
 




More information about the jboss-svn-commits mailing list