[jboss-svn-commits] JBL Code SVN: r13993 - in labs/jbossesb/trunk/product: rosetta/src/org/jboss/soa/esb/actions and 10 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Aug 3 08:40:39 EDT 2007
Author: tfennelly
Date: 2007-08-03 08:40:38 -0400 (Fri, 03 Aug 2007)
New Revision: 13993
Added:
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/MessageMulticaster.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java
Removed:
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/MessageMulticaster.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/ServiceInvoker.java
Modified:
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedWiretap.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/StaticWiretap.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/ListenerUtil.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/InflowGateway.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaInflowGateway.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JmsEndpoint.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/Invoker.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/UncomposedMessageDeliveryAdapter.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/routing/MessageRouter.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/ServiceInvokerUnitTest.java
labs/jbossesb/trunk/product/samples/quickstarts/native_client/war/src/org/jboss/soa/esb/samples/quickstart/nativeclient/webservice/HelloWorldWS.java
labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer1/src/org/jboss/soa/esb/samples/quickstart/webservice_consumer1/test/SendEsbMessage.java
labs/jbossesb/trunk/product/samples/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/LoanBroker.java
labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbActionHandler.java
Log:
http://jira.jboss.com/jira/browse/JBESB-767
Moved ServiecInvoker and MessageMulticaster to a new "org.jboss.soa.esb.client" package.
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedWiretap.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedWiretap.java 2007-08-03 12:13:26 UTC (rev 13992)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedWiretap.java 2007-08-03 12:40:38 UTC (rev 13993)
@@ -31,8 +31,8 @@
import org.jboss.soa.esb.Service;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.listeners.ListenerTagNames;
-import org.jboss.soa.esb.listeners.ServiceInvoker;
-import org.jboss.soa.esb.listeners.MessageMulticaster;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.client.MessageMulticaster;
import org.jboss.soa.esb.listeners.message.MessageDeliverException;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.message.mapping.ObjectMapper;
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/StaticWiretap.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/StaticWiretap.java 2007-08-03 12:13:26 UTC (rev 13992)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/StaticWiretap.java 2007-08-03 12:40:38 UTC (rev 13993)
@@ -33,7 +33,6 @@
import org.jboss.soa.esb.Service;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.listeners.ListenerTagNames;
-import org.jboss.soa.esb.listeners.MessageMulticaster;
import org.jboss.soa.esb.listeners.message.MessageDeliverException;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.services.registry.RegistryException;
@@ -93,7 +92,7 @@
protected ConfigTree _config;
- protected MessageMulticaster messageMulticaster = new MessageMulticaster();
+ protected org.jboss.soa.esb.client.MessageMulticaster messageMulticaster = new org.jboss.soa.esb.client.MessageMulticaster();
protected static Logger _logger = Logger.getLogger(StaticRouter.class);
}
Copied: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/MessageMulticaster.java (from rev 13985, labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/MessageMulticaster.java)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/MessageMulticaster.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/MessageMulticaster.java 2007-08-03 12:40:38 UTC (rev 13993)
@@ -0,0 +1,151 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.client;
+
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.Service;
+import org.jboss.soa.esb.actions.Aggregator;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import org.jboss.soa.esb.services.registry.RegistryException;
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.apache.log4j.Logger;
+
+import java.util.*;
+
+/**
+ * Message Multicaster.
+ * <p/>
+ * Used to send a message to a recipient list, or a subset of that recipient list.
+ * <p/>
+ * Caches a {@link ServiceInvoker} instance for each recipient.
+ * <p/>
+ * <b>Note</b>: This doesn't "multicast" message delivery in the true IP sense of the
+ * word "multicast". It sends the message to all recipients in its recipient list,
+ * one at a time, in the order the recipients were added via the
+ * {@link #addRecipient(org.jboss.soa.esb.Service)} method.
+ *
+ * @author <a href="mailto:tom.fennely at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class MessageMulticaster {
+
+ private static Logger logger = Logger.getLogger(MessageMulticaster.class);
+
+ private Map<Service, ServiceInvoker> invokers = new LinkedHashMap<Service, ServiceInvoker>();
+
+ /**
+ * Add a message recipient Service.
+ * @param service Recipient service for receipt of messages from this miltcaster instance.
+ * @throws RegistryException Failed to lookup Service endpoint.
+ * @throws MessageDeliverException Failed to deliver message to endpoint.
+ */
+ public void addRecipient(Service service) throws RegistryException, MessageDeliverException {
+ AssertArgument.isNotNull(service, "service");
+ // The ServiceInvoker will be lazilly created in the getInvoker method.
+ // This is effectively a registration of the service as being a potential recipient.
+ invokers.put(service, null);
+ }
+
+ /**
+ * Is the specified service a recipient of this multicaster instance.
+ * @param service The service to check for.
+ * @return True if the supplied service is one of the recipients, otherwise false.
+ */
+ public boolean isRecipient(Service service) {
+ return invokers.containsKey(service);
+ }
+
+ /**
+ * Get the number ot recipients associated with this multicaster instance.
+ * @return The number of recipients.
+ */
+ public int getRecipientCount() {
+ return invokers.size();
+ }
+
+ /**
+ * Send the message to all the recipients associated with this multicaster.
+ * @param message The message.
+ * @throws RegistryException Failed to lookup Service endpoint.
+ * @throws MessageDeliverException Failed to deliver message to endpoint.
+ */
+ public void sendToAll(Message message) throws RegistryException, MessageDeliverException {
+ sendToSubset(message, new ArrayList<Service>(invokers.keySet()));
+ }
+
+ /**
+ * Send the message to all the recipients associated with this multicaster and
+ * also listed in the supplied recipient list.
+ * <p/>
+ * The recipients supplied in the list must have been added through the {@link #addRecipient(org.jboss.soa.esb.Service)}
+ * method, otherwise the message will be delivered to the Dead Letter Channel.
+ *
+ * @param message The message.
+ * @param recipients The recipient subset to which the supplied message is to be sent.
+ * @throws RegistryException Failed to lookup Service endpoint.
+ * @throws MessageDeliverException Failed to deliver message to endpoint.
+ */
+ public void sendToSubset(Message message, List<Service> recipients) throws RegistryException, MessageDeliverException {
+ String uuId = UUID.randomUUID().toString();
+ ArrayList<String> aggregatorTags = new ArrayList<String>();
+ int recipientCount = recipients.size();
+ long timestamp = System.currentTimeMillis();
+
+ for(int i = 0; i < recipientCount; i++) {
+ Service recipient = recipients.get(i);
+ ServiceInvoker invoker = getInvoker(recipient);
+ String tag = uuId + ":" + (i + 1) + ":" + recipientCount + ":" + timestamp;
+
+ aggregatorTags.add(tag);
+ message.getProperties().setProperty(Aggregator.AGGEGRATOR_TAG, aggregatorTags);
+ if (logger.isDebugEnabled()) {
+ logger.debug(Aggregator. AGGEGRATOR_TAG + "=" + tag);
+ }
+
+ if(invoker == null) {
+ logger.error("Service '" + recipient + "' is not in recipient list. Delivering message to Dead Letter Channel.");
+ org.jboss.soa.esb.client.ServiceInvoker.deliverToDeadLetterChannel(message);
+ } else {
+ try {
+ invoker.deliverAsync(message);
+ } catch(MessageDeliverException e) {
+ logger.error("Failed to deliver message to Service '" + recipient + "'. Delivering message to Dead Letter Channel.");
+ ServiceInvoker.deliverToDeadLetterChannel(message);
+ }
+ }
+ }
+ }
+
+ private org.jboss.soa.esb.client.ServiceInvoker getInvoker(Service recipient) throws RegistryException, MessageDeliverException {
+ ServiceInvoker invoker = invokers.get(recipient);
+
+ // We lazilly create the invokers...
+ if(invoker == null) {
+ if(!invokers.containsKey(recipient)) {
+ // We don't create an invoker for the Service if it wasn't
+ // already "registered" via the addRecipient method.
+ return null;
+ }
+ invoker = new ServiceInvoker(recipient);
+ invokers.put(recipient, invoker);
+ }
+
+ return invoker;
+ }
+}
\ No newline at end of file
Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/MessageMulticaster.java
___________________________________________________________________
Name: svn:eol-style
+ native
Copied: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java (from rev 13981, labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/ServiceInvoker.java)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java 2007-08-03 12:40:38 UTC (rev 13993)
@@ -0,0 +1,392 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.client;
+
+import java.util.Date;
+import java.util.List;
+
+import javax.jms.JMSException;
+
+import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.jboss.internal.soa.esb.rosetta.pooling.JmsConnectionPoolContainer;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.Service;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.MalformedEPRException;
+import org.jboss.soa.esb.addressing.util.DefaultReplyTo;
+import org.jboss.soa.esb.common.Configuration;
+import org.jboss.soa.esb.couriers.Courier;
+import org.jboss.soa.esb.couriers.CourierException;
+import org.jboss.soa.esb.couriers.CourierFactory;
+import org.jboss.soa.esb.couriers.CourierUtil;
+import org.jboss.soa.esb.couriers.FaultMessageException;
+import org.jboss.soa.esb.couriers.TwoWayCourier;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import org.jboss.soa.esb.listeners.ha.LoadBalancePolicy;
+import org.jboss.soa.esb.listeners.ha.ServiceClusterInfo;
+import org.jboss.soa.esb.listeners.ha.ServiceClusterInfoImpl;
+import org.jboss.soa.esb.listeners.RegistryUtil;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.registry.RegistryException;
+import org.jboss.soa.esb.util.ClassUtil;
+
+/**
+ * Invoker class for managing {@link Message} delivery to a specified Service.
+ * <p/>
+ * Manages loading of {@link EPR EPRs}, {@link Courier} selection and
+ * message delivery. Provides a unified/simplified interface for message
+ * delivery.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class ServiceInvoker {
+
+ public static final String INTERNAL_SERVICE_CATEGORY = "JBossESB-Internal";
+
+ public static final String DEAD_LETTER_SERVICE_NAME = "DeadLetterService";
+
+ /**
+ * Class logger.
+ */
+ private static Logger logger = Logger.getLogger(ServiceInvoker.class);
+ /**
+ * The target service.
+ */
+ private Service service;
+ /**
+ * Load balancer.
+ */
+ private LoadBalancePolicy loadBalancer;
+ /**
+ * Cluster info.
+ */
+ private ServiceClusterInfo serviceClusterInfo;
+ /**
+ * Synchronous courier "pickup" deliver timeout.
+ */
+ private ThreadLocal<Long> syncPickupDeliveryTimeout = new ThreadLocal<Long>();
+ /**
+ *
+ */
+ private Date expirationDate;
+ /**
+ * Dead letter channel Service invoker.
+ */
+ private static ServiceInvoker dlQueueInvoker;
+
+ /**
+ * Public constructor.
+ *
+ * @param service The Service to which this instance will deliver messages.
+ * @throws RegistryException Failed to lookup Service endpoint.
+ * @throws MessageDeliverException Failed to deliver message to endpoint.
+ */
+ public ServiceInvoker(Service service) throws RegistryException, MessageDeliverException {
+ AssertArgument.isNotNull(service, "service");
+ this.service = service;
+ String lbClass = Configuration.getLoadBalancerPolicy();
+ try {
+ Class c = ClassUtil.forName(lbClass, this.getClass());
+ loadBalancer = (LoadBalancePolicy) c.newInstance();
+ loadServiceClusterInfo();
+ } catch (ClassNotFoundException clf) {
+ logger.error("No such LoadBalancePolicy class = " + lbClass);
+ throw new MessageDeliverException(clf.getMessage(), clf);
+ } catch (InstantiationException ie) {
+ logger.error("Could not instatiate LoadBalancePolicy class = " + lbClass);
+ throw new MessageDeliverException(ie.getMessage(), ie.getCause());
+ } catch (IllegalAccessException iae) {
+ logger.error("Illegal access while instantiating LoadBalancePolicy class = " + lbClass);
+ throw new MessageDeliverException(iae.getMessage(), iae);
+ }
+ }
+
+ /**
+ * Public constructor.
+ *
+ * @param serviceCategory The <b>category name</b> of the Service to which this instance will
+ * deliver messages.
+ * @param serviceName The <b>name</b> of the Service to which this instance will
+ * deliver messages.
+ * @throws RegistryException Failed to lookup Service endpoint.
+ * @throws MessageDeliverException Failed to deliver message to endpoint.
+ */
+ public ServiceInvoker(String serviceCategory, String serviceName) throws RegistryException, MessageDeliverException {
+ this(new Service(serviceCategory, serviceName));
+ }
+
+ /**
+ * Method to deliver *one* message, which allocates resources before sending the message and
+ * deallocates resources after the invocation.
+ *
+ * @param message Message to be send
+ * @return message (if the invo
+ * @throws RegistryException Failed to lookup Service endpoint.
+ * @throws MessageDeliverException Failed to deliver message to endpoint.
+ * @deprecated Please do not use this method. This was added as a short term workaround
+ * and will be going away ASAP.
+ */
+ public Message deliverOne(Message message) throws MessageDeliverException, RegistryException, FaultMessageException {
+ try {
+ deliverAsync(message);
+ } finally {
+ //cleanup allocated resources.
+ close();
+ }
+ return message;
+ }
+
+ /**
+ * Release allocated resources, such as connection pools. This is only of interest when you run
+ * in standalone mode, in other cases the container will call it for you.
+ */
+ public void close() {
+ try {
+ JmsConnectionPoolContainer.removeAllPools();
+ } catch (JMSException e) {
+ logger.error("Could not release resources " + e.getMessage(), e);
+ }
+ }
+
+ /**
+ * Synchronously deliver the supplied message to the target service associated with this invoker 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 RegistryException Failed to lookup Service endpoint.
+ * @throws MessageDeliverException Failed to deliver message to endpoint.
+ */
+ public Message deliverSync(Message message, long timeoutMillis) throws MessageDeliverException, RegistryException, FaultMessageException {
+ AssertArgument.isNotNull(message, "message");
+ syncPickupDeliveryTimeout.set(timeoutMillis);
+ return post(message, true);
+ }
+
+ /**
+ * Asynchronously deliver the supplied message to the target service associated with this invoker instance.
+ *
+ * @param message The message to be delivered.
+ * @throws MessageDeliverException Failed to deliver message, after trying all available EPRs.
+ */
+ public void deliverAsync(Message message) throws MessageDeliverException {
+ AssertArgument.isNotNull(message, "message");
+ // Not interested in a reply
+
+ try {
+ post(message, false);
+ } catch (FaultMessageException ex) {
+ throw new MessageDeliverException("Unexpected FaultMessageException during message delivery.", ex);
+ }
+ }
+
+ /**
+ * Deliver a message to the Dead Letter Channel Service.
+ *
+ * @param message The message to be delivered to the dead letter chennel.
+ * @throws RegistryException Service endpoint lookup failure.
+ * @throws MessageDeliverException Message delivery failure.
+ */
+ public static synchronized void deliverToDeadLetterChannel(Message message) throws RegistryException, MessageDeliverException {
+ if (dlQueueInvoker == null) {
+ dlQueueInvoker = new ServiceInvoker(INTERNAL_SERVICE_CATEGORY, DEAD_LETTER_SERVICE_NAME);
+ }
+ dlQueueInvoker.deliverAsync(message);
+ }
+
+ /**
+ * Deliver the supplied message to the target service associated with this invoker 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 deliver message, after trying all available EPRs.
+ */
+ private Message post(Message message, boolean synchronous) throws MessageDeliverException, FaultMessageException {
+ int numberOfAttemps = 0;
+ while (numberOfAttemps++ < 2) {
+ if ((serviceClusterInfo.getEPRs().size() == 0) || (new Date().after(expirationDate))) {
+ loadServiceClusterInfo();
+ }
+ Message replyMessage;
+ EPR epr;
+ // Iterate over all the EPRs in the list until delivered
+ while ((epr = loadBalancer.chooseEPR(serviceClusterInfo)) != null) {
+ replyMessage = attemptDelivery(message, epr, synchronous);
+ if (replyMessage != null) {
+ // We've delivered it, we're done!
+ return replyMessage;
+ } else {
+ logger.info("Unresponsive EPR: " + epr);
+ serviceClusterInfo.removeDeadEPR(epr);
+ }
+ }
+ }
+
+ // Throw exception if delivery failed...
+ throw new MessageDeliverException("Failed to deliver message to Service [" + service + "]. Check for errors.");
+ }
+
+ /**
+ * Get the details of Service to which this invoker instance is delivering messages.
+ *
+ * @return The Service details.
+ */
+ public Service getService() {
+ return service;
+ }
+
+ /**
+ * Get the Service category name for the Service for which this instance is delivering messages.
+ *
+ * @return Service Category.
+ */
+ public String getServiceCategory() {
+ return service.getCategory();
+ }
+
+ /**
+ * Get the Service name for the Service for which this instance is delivering messages.
+ *
+ * @return Service name.
+ */
+ public String getServiceName() {
+ return service.getName();
+ }
+
+ /**
+ * Attempt to deliver 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.
+ * @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 Message attemptDelivery(Message message, EPR epr, boolean synchronous) throws FaultMessageException {
+ TwoWayCourier courier = null;
+
+ // Get a courier for the EPR...
+ try {
+ courier = getCourier(epr);
+ } catch (CourierException e) {
+ logger.debug("Courier lookup failed for EPR [" + epr + "] for Service [" + service + "].", e);
+ } catch (MalformedEPRException e) {
+ logger.warn("Badly formed EPR [" + epr + "] for Service [" + service + "]. " + e.getMessage());
+ } catch (Throwable t) {
+ logger.warn("Unexpected exception during Courier lookup for EPR [" + epr + "] for Service [" + service + "].", t);
+ }
+
+ // Try delivering the message using the courier we just looked up....
+ if (courier != null) {
+ try {
+ EPR replyToEPR = message.getHeader().getCall().getReplyTo();
+
+ if (synchronous) {
+ if (replyToEPR == null)
+ replyToEPR = getReplyToAddress(epr);
+
+ if (replyToEPR == null) {
+ logger.debug("Not using epr [" + epr + "] for Service [" + service + "]. No reply-to address available for synchronous response.");
+ return null;
+ }
+ message.getHeader().getCall().setReplyTo(replyToEPR);
+ }
+ if (courier.deliver(message)) {
+ if (replyToEPR != null) {
+ // do we need to do this for synchronous calls? Vagueries of Couriers?
+
+ courier.setReplyToEpr(replyToEPR);
+ return courier.pickup(syncPickupDeliveryTimeout.get());
+ } else {
+ return message;
+ }
+ }
+ } catch (FaultMessageException e) {
+ throw e;
+ } catch (CourierException e) {
+ logger.debug("Badly formed EPR [" + epr + "] for Service [" + service + "]. " + e.getMessage());
+ } catch (MalformedEPRException e) {
+ // Hmmmm???... Can this really happen? The Courier has already been created. Haven't we already validated the EPR during the Courier lookup (above)??
+ logger.warn("Unexpected error. Badly formed EPR [" + epr + "] for Service [" + service + "]. But the EPR has already been validated!!");
+ } catch (Throwable t) {
+ logger.warn("Unexpected exception during attempted message delivery over Courier for EPR [" + epr + "] for Service [" + service + "].", t);
+ } finally {
+ // TODO: So does this mean that Couriers are stateful? If so, do we need to synchronize on using them??
+ CourierUtil.cleanCourier(courier);
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Get the reply to address for synchronous delivery.
+ *
+ * @param toEpr The to address.
+ * @return The replyTo address.
+ * @throws ConfigurationException Unable to support synchronous reply on 'to' address.
+ */
+ protected EPR getReplyToAddress(EPR toEpr) throws ConfigurationException {
+ // This method just allows us to override Courier lookup during unit testing.
+ try {
+ return DefaultReplyTo.getReplyTo(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}
+ * is being sought.
+ * @return The courier for the EPR.
+ * @throws CourierException A courier implementation cannot be created.
+ * @throws MalformedEPRException Bad EPR.
+ */
+ 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);
+ }
+
+ /**
+ * Loads the EPRs fresh from the Registry. Right now we will do this every minute
+ * until we can expect to get updates from the registry. For now this should work
+ * just fine.
+ *
+ * @throws MessageDeliverException Registry lookup failure.
+ */
+ public void loadServiceClusterInfo() throws MessageDeliverException {
+ try {
+ List<EPR> serviceEprs = RegistryUtil.getEprs(service.getCategory(), service.getName());
+ serviceClusterInfo = new ServiceClusterInfoImpl(service.getName(), serviceEprs);
+ expirationDate = new Date(java.lang.System.currentTimeMillis() + 60000);
+ } catch (RegistryException e) {
+ throw new MessageDeliverException(e.getMessage(), e);
+ }
+ }
+
+}
Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/ListenerUtil.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/ListenerUtil.java 2007-08-03 12:13:26 UTC (rev 13992)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/ListenerUtil.java 2007-08-03 12:40:38 UTC (rev 13993)
@@ -42,7 +42,6 @@
import org.jboss.soa.esb.addressing.eprs.JMSEpr;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.listeners.message.MessageDeliverException;
-import org.jboss.soa.esb.listeners.ServiceInvoker;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.services.registry.RegistryException;
import org.jboss.soa.esb.util.Util;
@@ -68,7 +67,7 @@
public static void tryToDeliver(Message message, String category, String name)
throws MessageDeliverException, JMSException, RegistryException
{
- ServiceInvoker adapter = new ServiceInvoker(category, name);
+ org.jboss.soa.esb.client.ServiceInvoker adapter = new org.jboss.soa.esb.client.ServiceInvoker(category, name);
adapter.deliverAsync(message);
JmsConnectionPoolContainer.removeAllPools();
}
Deleted: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/MessageMulticaster.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/MessageMulticaster.java 2007-08-03 12:13:26 UTC (rev 13992)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/MessageMulticaster.java 2007-08-03 12:40:38 UTC (rev 13993)
@@ -1,149 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * 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,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.soa.esb.listeners;
-
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.Service;
-import org.jboss.soa.esb.actions.Aggregator;
-import org.jboss.soa.esb.listeners.message.MessageDeliverException;
-import org.jboss.soa.esb.services.registry.RegistryException;
-import org.jboss.internal.soa.esb.assertion.AssertArgument;
-import org.apache.log4j.Logger;
-
-import java.util.*;
-
-/**
- * Message Multicaster.
- * <p/>
- * Used to send a message to a recipient list, or a subset of that recipient list.
- * <p/>
- * Caches a {@link ServiceInvoker} instance for each recipient.
- * <p/>
- * <b>Note</b>: This doesn't "multicast" message delivery in the true IP sense of the
- * word "multicast". It sends the message to all recipients in its recipient list,
- * one at a time, in the order the recipients were added via the
- * {@link #addRecipient(org.jboss.soa.esb.Service)} method.
- *
- * @author <a href="mailto:tom.fennely at jboss.com">tom.fennelly at jboss.com</a>
- */
-public class MessageMulticaster {
-
- private static Logger logger = Logger.getLogger(MessageMulticaster.class);
-
- private Map<Service, ServiceInvoker> invokers = new LinkedHashMap<Service, ServiceInvoker>();
-
- /**
- * Add a message recipient Service.
- * @param service Recipient service for receipt of messages from this miltcaster instance.
- * @throws RegistryException Failed to lookup Service endpoint.
- * @throws MessageDeliverException Failed to deliver message to endpoint.
- */
- public void addRecipient(Service service) throws RegistryException, MessageDeliverException {
- AssertArgument.isNotNull(service, "service");
- // The ServiceInvoker will be lazilly created in the getInvoker method.
- // This is effectively a registration of the service as being a potential recipient.
- invokers.put(service, null);
- }
-
- /**
- * Is the specified service a recipient of this multicaster instance.
- * @param service The service to check for.
- * @return True if the supplied service is one of the recipients, otherwise false.
- */
- public boolean isRecipient(Service service) {
- return invokers.containsKey(service);
- }
-
- /**
- * Get the number ot recipients associated with this multicaster instance.
- * @return The number of recipients.
- */
- public int getRecipientCount() {
- return invokers.size();
- }
-
- /**
- * Send the message to all the recipients associated with this multicaster.
- * @param message The message.
- * @throws RegistryException Failed to lookup Service endpoint.
- * @throws MessageDeliverException Failed to deliver message to endpoint.
- */
- public void sendToAll(Message message) throws RegistryException, MessageDeliverException {
- sendToSubset(message, new ArrayList<Service>(invokers.keySet()));
- }
-
- /**
- * Send the message to all the recipients associated with this multicaster and
- * also listed in the supplied recipient list.
- * <p/>
- * The recipients supplied in the list must have been added through the {@link #addRecipient(org.jboss.soa.esb.Service)}
- * method, otherwise the message will be delivered to the Dead Letter Channel.
- *
- * @param message The message.
- * @param recipients The recipient subset to which the supplied message is to be sent.
- * @throws RegistryException Failed to lookup Service endpoint.
- * @throws MessageDeliverException Failed to deliver message to endpoint.
- */
- public void sendToSubset(Message message, List<Service> recipients) throws RegistryException, MessageDeliverException {
- String uuId = UUID.randomUUID().toString();
- ArrayList<String> aggregatorTags = new ArrayList<String>();
- int recipientCount = recipients.size();
- long timestamp = System.currentTimeMillis();
-
- for(int i = 0; i < recipientCount; i++) {
- Service recipient = recipients.get(i);
- ServiceInvoker invoker = getInvoker(recipient);
- String tag = uuId + ":" + (i + 1) + ":" + recipientCount + ":" + timestamp;
-
- aggregatorTags.add(tag);
- message.getProperties().setProperty(Aggregator.AGGEGRATOR_TAG, aggregatorTags);
- if (logger.isDebugEnabled()) {
- logger.debug(Aggregator. AGGEGRATOR_TAG + "=" + tag);
- }
-
- if(invoker == null) {
- logger.error("Service '" + recipient + "' is not in recipient list. Delivering message to Dead Letter Channel.");
- ServiceInvoker.deliverToDeadLetterChannel(message);
- } else {
- try {
- invoker.deliverAsync(message);
- } catch(MessageDeliverException e) {
- logger.error("Failed to deliver message to Service '" + recipient + "'. Delivering message to Dead Letter Channel.");
- ServiceInvoker.deliverToDeadLetterChannel(message);
- }
- }
- }
- }
-
- private ServiceInvoker getInvoker(Service recipient) throws RegistryException, MessageDeliverException {
- ServiceInvoker invoker = invokers.get(recipient);
-
- // We lazilly create the invokers...
- if(invoker == null) {
- if(!invokers.containsKey(recipient)) {
- return null;
- }
- invoker = new ServiceInvoker(recipient);
- invokers.put(recipient, invoker);
- }
-
- return invoker;
- }
-}
Deleted: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/ServiceInvoker.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/ServiceInvoker.java 2007-08-03 12:13:26 UTC (rev 13992)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/ServiceInvoker.java 2007-08-03 12:40:38 UTC (rev 13993)
@@ -1,391 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * 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,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.soa.esb.listeners;
-
-import java.util.Date;
-import java.util.List;
-
-import javax.jms.JMSException;
-
-import org.apache.log4j.Logger;
-import org.jboss.internal.soa.esb.assertion.AssertArgument;
-import org.jboss.internal.soa.esb.rosetta.pooling.JmsConnectionPoolContainer;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.Service;
-import org.jboss.soa.esb.addressing.EPR;
-import org.jboss.soa.esb.addressing.MalformedEPRException;
-import org.jboss.soa.esb.addressing.util.DefaultReplyTo;
-import org.jboss.soa.esb.common.Configuration;
-import org.jboss.soa.esb.couriers.Courier;
-import org.jboss.soa.esb.couriers.CourierException;
-import org.jboss.soa.esb.couriers.CourierFactory;
-import org.jboss.soa.esb.couriers.CourierUtil;
-import org.jboss.soa.esb.couriers.FaultMessageException;
-import org.jboss.soa.esb.couriers.TwoWayCourier;
-import org.jboss.soa.esb.listeners.message.MessageDeliverException;
-import org.jboss.soa.esb.listeners.ha.LoadBalancePolicy;
-import org.jboss.soa.esb.listeners.ha.ServiceClusterInfo;
-import org.jboss.soa.esb.listeners.ha.ServiceClusterInfoImpl;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.services.registry.RegistryException;
-import org.jboss.soa.esb.util.ClassUtil;
-
-/**
- * Invoker class for managing {@link Message} delivery to a specified Service.
- * <p/>
- * Manages loading of {@link EPR EPRs}, {@link Courier} selection and
- * message delivery. Provides a unified/simplified interface for message
- * delivery.
- *
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- */
-public class ServiceInvoker {
-
- public static final String INTERNAL_SERVICE_CATEGORY = "JBossESB-Internal";
-
- public static final String DEAD_LETTER_SERVICE_NAME = "DeadLetterService";
-
- /**
- * Class logger.
- */
- private static Logger logger = Logger.getLogger(ServiceInvoker.class);
- /**
- * The target service.
- */
- private Service service;
- /**
- * Load balancer.
- */
- private LoadBalancePolicy loadBalancer;
- /**
- * Cluster info.
- */
- private ServiceClusterInfo serviceClusterInfo;
- /**
- * Synchronous courier "pickup" deliver timeout.
- */
- private ThreadLocal<Long> syncPickupDeliveryTimeout = new ThreadLocal<Long>();
- /**
- *
- */
- private Date expirationDate;
- /**
- * Dead letter channel Service invoker.
- */
- private static ServiceInvoker dlQueueInvoker;
-
- /**
- * Public constructor.
- *
- * @param service The Service to which this instance will deliver messages.
- * @throws RegistryException Failed to lookup Service endpoint.
- * @throws MessageDeliverException Failed to deliver message to endpoint.
- */
- public ServiceInvoker(Service service) throws RegistryException, MessageDeliverException {
- AssertArgument.isNotNull(service, "service");
- this.service = service;
- String lbClass = Configuration.getLoadBalancerPolicy();
- try {
- Class c = ClassUtil.forName(lbClass, this.getClass());
- loadBalancer = (LoadBalancePolicy) c.newInstance();
- loadServiceClusterInfo();
- } catch (ClassNotFoundException clf) {
- logger.error("No such LoadBalancePolicy class = " + lbClass);
- throw new MessageDeliverException( clf.getMessage(), clf);
- } catch (InstantiationException ie) {
- logger.error("Could not instatiate LoadBalancePolicy class = " + lbClass);
- throw new MessageDeliverException( ie.getMessage(), ie.getCause());
- } catch (IllegalAccessException iae) {
- logger.error("Illegal access while instantiating LoadBalancePolicy class = " + lbClass);
- throw new MessageDeliverException( iae.getMessage(), iae);
- }
- }
-
- /**
- * Public constructor.
- *
- * @param serviceCategory The <b>category name</b> of the Service to which this instance will
- * deliver messages.
- * @param serviceName The <b>name</b> of the Service to which this instance will
- * deliver messages.
- * @throws RegistryException Failed to lookup Service endpoint.
- * @throws MessageDeliverException Failed to deliver message to endpoint.
- */
- public ServiceInvoker(String serviceCategory, String serviceName) throws RegistryException, MessageDeliverException {
- this(new Service(serviceCategory, serviceName));
- }
-
- /**
- * Method to deliver *one* message, which allocates resources before sending the message and
- * deallocates resources after the invocation.
- *
- * @param message Message to be send
- * @return message (if the invo
- * @throws RegistryException Failed to lookup Service endpoint.
- * @throws MessageDeliverException Failed to deliver message to endpoint.
- */
- public Message deliverOne (Message message) throws MessageDeliverException, RegistryException, FaultMessageException
- {
- try {
- deliverAsync(message);
- } finally {
- //cleanup allocated resources.
- close();
- }
- return message;
- }
-
- /**
- * Release allocated resources, such as connection pools. This is only of interest when you run
- * in standalone mode, in other cases the container will call it for you.
- */
- public void close(){
- try {
- JmsConnectionPoolContainer.removeAllPools();
- } catch (JMSException e) {
- logger.error("Could not release resources " + e.getMessage(), e);
- }
- }
-
- /**
- * Synchronously deliver the supplied message to the target service associated with this invoker 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 RegistryException Failed to lookup Service endpoint.
- * @throws MessageDeliverException Failed to deliver message to endpoint.
- */
- public Message deliverSync(Message message, long timeoutMillis) throws MessageDeliverException, RegistryException, FaultMessageException {
- AssertArgument.isNotNull(message, "message");
- syncPickupDeliveryTimeout.set(timeoutMillis);
- return post(message, true);
- }
-
- /**
- * Asynchronously deliver the supplied message to the target service associated with this invoker instance.
- *
- * @param message The message to be delivered.
- * @throws MessageDeliverException Failed to deliver message, after trying all available EPRs.
- */
- public void deliverAsync(Message message) throws MessageDeliverException {
- AssertArgument.isNotNull(message, "message");
- // Not interested in a reply
-
- try
- {
- post(message, false);
- }
- catch (FaultMessageException ex)
- {
- throw new MessageDeliverException("Unexpected FaultMessageException");
- }
- }
-
- /**
- * Deliver a message to the Dead Letter Channel Service.
- * @param message The message to be delivered to the dead letter chennel.
- * @throws RegistryException Service endpoint lookup failure.
- * @throws MessageDeliverException Message delivery failure.
- */
- public static synchronized void deliverToDeadLetterChannel(Message message) throws RegistryException, MessageDeliverException {
- if(dlQueueInvoker == null) {
- dlQueueInvoker = new ServiceInvoker(INTERNAL_SERVICE_CATEGORY, DEAD_LETTER_SERVICE_NAME);
- }
- dlQueueInvoker.deliverAsync(message);
- }
-
- /**
- * Deliver the supplied message to the target service associated with this invoker 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 deliver message, after trying all available EPRs.
- */
- private Message post(Message message, boolean synchronous) throws MessageDeliverException, FaultMessageException
- {
- int numberOfAttemps=0;
- while (numberOfAttemps++ < 2) {
- if ((serviceClusterInfo.getEPRs().size()==0) || (new Date().after(expirationDate)) ) {
- loadServiceClusterInfo();
- }
- Message replyMessage;
- EPR epr;
- // Iterate over all the EPRs in the list until delivered
- while ((epr = loadBalancer.chooseEPR(serviceClusterInfo))!=null) {
- replyMessage = attemptDelivery(message, epr, synchronous);
- if (replyMessage != null) {
- // We've delivered it, we're done!
- return replyMessage;
- } else {
- logger.info("Unresponsive EPR: " + epr);
- serviceClusterInfo.removeDeadEPR(epr);
- }
- }
- }
-
- // Throw exception if delivery failed...
- throw new MessageDeliverException("Failed to deliver message to Service [" + service + "]. Check for errors.");
- }
-
- /**
- * Get the details of Service to which this invoker instance is delivering messages.
- * @return The Service details.
- */
- public Service getService() {
- return service;
- }
-
- /**
- * Get the Service category name for the Service for which this instance is delivering messages.
- *
- * @return Service Category.
- */
- public String getServiceCategory() {
- return service.getCategory();
- }
-
- /**
- * Get the Service name for the Service for which this instance is delivering messages.
- *
- * @return Service name.
- */
- public String getServiceName() {
- return service.getName();
- }
-
- /**
- * Attempt to deliver 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.
- * @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 Message attemptDelivery(Message message, EPR epr, boolean synchronous) throws FaultMessageException {
- TwoWayCourier courier = null;
-
- // Get a courier for the EPR...
- try {
- courier = getCourier(epr);
- } catch (CourierException e) {
- logger.debug("Courier lookup failed for EPR [" + epr + "] for Service [" + service + "].", e);
- } catch (MalformedEPRException e) {
- logger.warn("Badly formed EPR [" + epr + "] for Service [" + service + "]. " + e.getMessage());
- } catch (Throwable t) {
- logger.warn("Unexpected exception during Courier lookup for EPR [" + epr + "] for Service [" + service + "].", t);
- }
-
- // Try delivering the message using the courier we just looked up....
- if (courier != null) {
- try {
- EPR replyToEPR = message.getHeader().getCall().getReplyTo();
-
- if (synchronous) {
- if (replyToEPR == null)
- replyToEPR = getReplyToAddress(epr);
-
- if(replyToEPR == null) {
- logger.debug("Not using epr [" + epr + "] for Service [" + service + "]. No reply-to address available for synchronous response.");
- return null;
- }
- message.getHeader().getCall().setReplyTo(replyToEPR);
- }
- if (courier.deliver(message)) {
- if (replyToEPR != null) {
- // do we need to do this for synchronous calls? Vagueries of Couriers?
-
- courier.setReplyToEpr(replyToEPR);
- return courier.pickup(syncPickupDeliveryTimeout.get());
- } else {
- return message;
- }
- }
- } catch (FaultMessageException e) {
- throw e;
- } catch (CourierException e) {
- logger.debug("Badly formed EPR [" + epr + "] for Service [" + service + "]. " + e.getMessage());
- } catch (MalformedEPRException e) {
- // Hmmmm???... Can this really happen? The Courier has already been created. Haven't we already validated the EPR during the Courier lookup (above)??
- logger.warn("Unexpected error. Badly formed EPR [" + epr + "] for Service [" + service + "]. But the EPR has already been validated!!");
- } catch (Throwable t) {
- logger.warn("Unexpected exception during attempted message delivery over Courier for EPR [" + epr + "] for Service [" + service + "].", t);
- } finally {
- // TODO: So does this mean that Couriers are stateful? If so, do we need to synchronize on using them??
- CourierUtil.cleanCourier(courier);
- }
- }
-
- return null;
- }
-
- /**
- * Get the reply to address for synchronous delivery.
- *
- * @param toEpr The to address.
- * @return The replyTo address.
- * @throws ConfigurationException Unable to support synchronous reply on 'to' address.
- */
- protected EPR getReplyToAddress(EPR toEpr) throws ConfigurationException {
- // This method just allows us to override Courier lookup during unit testing.
- try {
- return DefaultReplyTo.getReplyTo(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}
- * is being sought.
- * @return The courier for the EPR.
- * @throws CourierException A courier implementation cannot be created.
- * @throws MalformedEPRException Bad EPR.
- */
- 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);
- }
- /**
- * Loads the EPRs fresh from the Registry. Right now we will do this every minute
- * until we can expect to get updates from the registry. For now this should work
- * just fine.
- * @throws MessageDeliverException Registry lookup failure.
- */
- public void loadServiceClusterInfo() throws MessageDeliverException
- {
- try {
- List<EPR> serviceEprs = RegistryUtil.getEprs(service.getCategory(), service.getName());
- serviceClusterInfo = new ServiceClusterInfoImpl(service.getName(), serviceEprs);
- expirationDate = new Date(java.lang.System.currentTimeMillis() + 60000);
- } catch (RegistryException e) {
- throw new MessageDeliverException(e.getMessage(), e);
- }
- }
-
-}
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/InflowGateway.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/InflowGateway.java 2007-08-03 12:13:26 UTC (rev 13992)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/InflowGateway.java 2007-08-03 12:40:38 UTC (rev 13993)
@@ -21,8 +21,6 @@
*/
package org.jboss.soa.esb.listeners.jca;
-import org.jboss.soa.esb.listeners.ServiceInvoker;
-
/**
* Required interface for JCA ESB Gateways
* <p/>
@@ -34,5 +32,5 @@
*/
public interface InflowGateway
{
- public void setServiceInvoker(ServiceInvoker invoker);
+ public void setServiceInvoker(org.jboss.soa.esb.client.ServiceInvoker invoker);
}
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaInflowGateway.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaInflowGateway.java 2007-08-03 12:13:26 UTC (rev 13992)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaInflowGateway.java 2007-08-03 12:40:38 UTC (rev 13993)
@@ -31,7 +31,7 @@
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.listeners.ListenerTagNames;
import org.jboss.soa.esb.listeners.ListenerUtil;
-import org.jboss.soa.esb.listeners.ServiceInvoker;
+import org.jboss.soa.esb.client.ServiceInvoker;
import org.jboss.soa.esb.listeners.message.MessageDeliverException;
import org.jboss.soa.esb.listeners.lifecycle.AbstractThreadedManagedLifecycle;
import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JmsEndpoint.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JmsEndpoint.java 2007-08-03 12:13:26 UTC (rev 13992)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JmsEndpoint.java 2007-08-03 12:40:38 UTC (rev 13993)
@@ -25,7 +25,7 @@
import javax.jms.MessageListener;
import org.jboss.soa.esb.listeners.gateway.PackageJmsMessageContents;
-import org.jboss.soa.esb.listeners.ServiceInvoker;
+import org.jboss.soa.esb.client.ServiceInvoker;
/**
* comment
@@ -35,7 +35,7 @@
*/
public class JmsEndpoint implements InflowGateway, MessageListener
{
- private ServiceInvoker service;
+ private org.jboss.soa.esb.client.ServiceInvoker service;
private PackageJmsMessageContents transformer = new PackageJmsMessageContents();
public void setServiceInvoker(ServiceInvoker invoker)
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/Invoker.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/Invoker.java 2007-08-03 12:13:26 UTC (rev 13992)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/Invoker.java 2007-08-03 12:40:38 UTC (rev 13993)
@@ -47,7 +47,7 @@
* Utility class to hide implementation details for sending Command messages and optionally awaiting for a response.
*
* @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- * @deprecated Use {@link org.jboss.soa.esb.listeners.ServiceInvoker}.
+ * @deprecated Use {@link org.jboss.soa.esb.client.ServiceInvoker}.
*/
public class Invoker {
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/UncomposedMessageDeliveryAdapter.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/UncomposedMessageDeliveryAdapter.java 2007-08-03 12:13:26 UTC (rev 13992)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/UncomposedMessageDeliveryAdapter.java 2007-08-03 12:40:38 UTC (rev 13993)
@@ -30,11 +30,11 @@
/**
* Adapter class for delivering uncomposed (ESB unaware) message payloads to a target service.
* <p/>
- * Basically wires a {@link ServiceInvoker} instance with a {@link MessageComposer}
+ * Basically wires a {@link org.jboss.soa.esb.client.ServiceInvoker} instance with a {@link MessageComposer}
* instance.
*
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- * @see org.jboss.soa.esb.listeners.ServiceInvoker
+ * @see org.jboss.soa.esb.client.ServiceInvoker
*/
public class UncomposedMessageDeliveryAdapter {
@@ -42,7 +42,7 @@
* Composed message delivery adapter. Performs the delivery after this class
* composes the message.
*/
- private ServiceInvoker serviceInvoker;
+ private org.jboss.soa.esb.client.ServiceInvoker serviceInvoker;
/**
* Message composer.
*/
@@ -63,7 +63,7 @@
AssertArgument.isNotNull(serviceCategory, "serviceCategory");
AssertArgument.isNotNull(serviceName, "serviceName");
AssertArgument.isNotNull(composer, "composer");
- serviceInvoker = new org.jboss.soa.esb.listeners.ServiceInvoker(serviceCategory, serviceName);
+ serviceInvoker = new org.jboss.soa.esb.client.ServiceInvoker(serviceCategory, serviceName);
this.composer = composer;
}
@@ -127,7 +127,7 @@
*
* @return Message Delivery Adapter.
*/
- public ServiceInvoker getDeliveryAdapter() {
+ public org.jboss.soa.esb.client.ServiceInvoker getDeliveryAdapter() {
return serviceInvoker;
}
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/routing/MessageRouter.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/routing/MessageRouter.java 2007-08-03 12:13:26 UTC (rev 13992)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/routing/MessageRouter.java 2007-08-03 12:40:38 UTC (rev 13993)
@@ -30,14 +30,13 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.services.registry.RegistryException;
-import org.jboss.soa.esb.listeners.ServiceInvoker;
import org.jboss.soa.esb.listeners.message.MessageDeliverException;
/**
* Generic Message Router Interface.
*
* @author kurt.stam at redhat.com
- * @deprecated Use {@link org.jboss.soa.esb.listeners.ServiceInvoker}.
+ * @deprecated Use {@link org.jboss.soa.esb.client.ServiceInvoker}.
*/
public abstract class MessageRouter {
private static Logger logger = Logger.getLogger(MessageRouter.class);
@@ -66,12 +65,12 @@
* the service name
* @param message -
* the message that needs routing and delivery
- * @deprecated Use the {@link org.jboss.soa.esb.listeners.ServiceInvoker}
+ * @deprecated Use the {@link org.jboss.soa.esb.client.ServiceInvoker}
*/
@SuppressWarnings("unchecked")
public synchronized static void deliverMessage(String serviceCategory, String serviceName, Message message) throws MessageRouterException {
try {
- ServiceInvoker serviceInvoker = new ServiceInvoker(serviceCategory, serviceName);
+ org.jboss.soa.esb.client.ServiceInvoker serviceInvoker = new org.jboss.soa.esb.client.ServiceInvoker(serviceCategory, serviceName);
serviceInvoker.deliverAsync(message);
} catch (RegistryException e) {
throw new MessageRouterException(e);
@@ -88,7 +87,7 @@
* Collection with the name of the destination services.
* @param message -
* the message that needs routing and delivery
- * @deprecated Use the {@link org.jboss.soa.esb.listeners.MessageMulticaster}.
+ * @deprecated Use the {@link org.jboss.soa.esb.client.MessageMulticaster}.
*/
@SuppressWarnings("unchecked")
public synchronized static void deliverMessages(Collection<String[]> destinations, Message message) throws MessageRouterException {
Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/ServiceInvokerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/ServiceInvokerUnitTest.java 2007-08-03 12:13:26 UTC (rev 13992)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/ServiceInvokerUnitTest.java 2007-08-03 12:40:38 UTC (rev 13993)
@@ -36,7 +36,7 @@
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.listeners.ListenerTagNames;
import org.jboss.soa.esb.listeners.RegistryUtil;
-import org.jboss.soa.esb.listeners.ServiceInvoker;
+import org.jboss.soa.esb.client.ServiceInvoker;
import org.jboss.soa.esb.listeners.message.MessageDeliverException;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.message.format.MessageFactory;
@@ -145,7 +145,7 @@
try
{
- ServiceInvoker invoker = new ServiceInvoker("foo", "bar");
+ org.jboss.soa.esb.client.ServiceInvoker invoker = new org.jboss.soa.esb.client.ServiceInvoker("foo", "bar");
invoker.deliverAsync(message);
fail();
}
@@ -171,7 +171,7 @@
try
{
- ServiceInvoker invoker = new ServiceInvoker("eprmanager", "qwerty");
+ ServiceInvoker invoker = new org.jboss.soa.esb.client.ServiceInvoker("eprmanager", "qwerty");
invoker.deliverAsync(message);
}
catch (Exception ex)
@@ -183,7 +183,7 @@
try
{
- ServiceInvoker invoker = new ServiceInvoker("eprmanager", "qwerty");
+ ServiceInvoker invoker = new org.jboss.soa.esb.client.ServiceInvoker("eprmanager", "qwerty");
invoker.deliverAsync(message);
}
catch (Exception ex)
Modified: labs/jbossesb/trunk/product/samples/quickstarts/native_client/war/src/org/jboss/soa/esb/samples/quickstart/nativeclient/webservice/HelloWorldWS.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/native_client/war/src/org/jboss/soa/esb/samples/quickstart/nativeclient/webservice/HelloWorldWS.java 2007-08-03 12:13:26 UTC (rev 13992)
+++ labs/jbossesb/trunk/product/samples/quickstarts/native_client/war/src/org/jboss/soa/esb/samples/quickstart/nativeclient/webservice/HelloWorldWS.java 2007-08-03 12:40:38 UTC (rev 13993)
@@ -30,7 +30,7 @@
import org.jboss.soa.esb.message.Message; // jbossesb-rosetta.jar
import org.jboss.soa.esb.message.format.MessageFactory; // jbossesb-rosetta.jar
import org.jboss.soa.esb.message.format.MessageType; // jbossesb-rosetta.jar
-import org.jboss.soa.esb.listeners.ServiceInvoker; // jbossesb-rosetta.jar
+import org.jboss.soa.esb.client.ServiceInvoker; // jbossesb-rosetta.jar
@WebService(name = "HelloWorld", targetNamespace = "http://nativeclient/helloworld")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@@ -45,7 +45,7 @@
Message replyMessage = null;
// Create the delivery adapter for the target service (you'd normally cache this!!)...
- deliveryAdapter = new org.jboss.soa.esb.listeners.ServiceInvoker("MyServiceCategory", "MyNativeClientService");
+ deliveryAdapter = new org.jboss.soa.esb.client.ServiceInvoker("MyServiceCategory", "MyNativeClientService");
// Create and populate the request message...
requestMessage = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
requestMessage.getBody().setByteArray(toWhom.getBytes()); // inject the value from the WS client
Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer1/src/org/jboss/soa/esb/samples/quickstart/webservice_consumer1/test/SendEsbMessage.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer1/src/org/jboss/soa/esb/samples/quickstart/webservice_consumer1/test/SendEsbMessage.java 2007-08-03 12:13:26 UTC (rev 13992)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer1/src/org/jboss/soa/esb/samples/quickstart/webservice_consumer1/test/SendEsbMessage.java 2007-08-03 12:40:38 UTC (rev 13993)
@@ -20,7 +20,7 @@
*/
package org.jboss.soa.esb.samples.quickstart.webservice_consumer1.test;
-import org.jboss.soa.esb.listeners.ServiceInvoker;
+import org.jboss.soa.esb.client.ServiceInvoker;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.message.format.MessageFactory;
import org.jboss.soa.esb.message.format.MessageType;
Modified: labs/jbossesb/trunk/product/samples/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/LoanBroker.java
===================================================================
--- labs/jbossesb/trunk/product/samples/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/LoanBroker.java 2007-08-03 12:13:26 UTC (rev 13992)
+++ labs/jbossesb/trunk/product/samples/trailblazer/client/src/org/jboss/soa/esb/samples/trailblazer/loanbroker/LoanBroker.java 2007-08-03 12:40:38 UTC (rev 13993)
@@ -30,7 +30,7 @@
import org.jboss.soa.esb.message.format.MessageType;
import org.jboss.soa.esb.samples.trailblazer.util.TrailblazerProperties;
import org.jboss.soa.esb.samples.trailblazer.web.WebCustomer;
-import org.jboss.soa.esb.listeners.ServiceInvoker;
+import org.jboss.soa.esb.client.ServiceInvoker;
/*
* LoanBroker is responsible for getting customer requests for loans onto the JBoss ESB
Modified: labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbActionHandler.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbActionHandler.java 2007-08-03 12:13:26 UTC (rev 13992)
+++ labs/jbossesb/trunk/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actionhandlers/EsbActionHandler.java 2007-08-03 12:40:38 UTC (rev 13993)
@@ -33,7 +33,7 @@
import org.dom4j.tree.DefaultElement;
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.addressing.Call;
-import org.jboss.soa.esb.listeners.ServiceInvoker;
+import org.jboss.soa.esb.client.ServiceInvoker;
import org.jboss.soa.esb.message.Body;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.message.format.MessageFactory;
More information about the jboss-svn-commits
mailing list