[jboss-svn-commits] JBL Code SVN: r6944 - in labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss: . internal internal/soa internal/soa/esb internal/soa/esb/couriers soa/esb soa/esb/actions/templates soa/esb/listeners soa/esb/message/listeners
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Oct 20 06:53:46 EDT 2006
Author: estebanschifman
Date: 2006-10-20 06:53:36 -0400 (Fri, 20 Oct 2006)
New Revision: 6944
Added:
labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/internal/
labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/internal/soa/
labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/internal/soa/esb/
labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/internal/soa/esb/couriers/
labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/MockComposer.java
labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gatewayExample.xml
Removed:
labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/couriers/
Modified:
labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/internal/soa/esb/couriers/Courier.java
labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/internal/soa/esb/couriers/CourierException.java
labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/internal/soa/esb/couriers/CourierFactory.java
labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java
labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/MockAction.java
labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/MockFileAction.java
labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/MockSqlRowAction.java
labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/GatewayListenerController.java
labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/JmsGatewayListener.java
labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/message/listeners/ActionProcessingPipeline.java
labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/message/listeners/JmsQueueListener.java
labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/message/listeners/ListenerTagNames.java
labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/message/listeners/example.xml
Log:
couriers package to internal.couriers
listener tag name changes
new MockComposer class
example xml configuration for gateway
Copied: labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/internal/soa/esb/couriers (from rev 6912, labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/couriers)
Modified: labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/internal/soa/esb/couriers/Courier.java
===================================================================
--- labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/couriers/Courier.java 2006-10-19 14:37:28 UTC (rev 6912)
+++ labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/internal/soa/esb/couriers/Courier.java 2006-10-20 10:53:36 UTC (rev 6944)
@@ -20,25 +20,36 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.soa.esb.couriers;
+package org.jboss.internal.soa.esb.couriers;
import org.jboss.soa.esb.addressing.EPR;
import org.jboss.soa.esb.message.Message;
public abstract class Courier
{
-
+/**
+ * try to deliver an ESB message
+ * @param message Message - the message to deliver
+ * @return boolean - the result of the delivery
+ * @throws CourierException - if problems were encountered
+ */
public abstract boolean deliver(Message message) throws CourierException;
// no default constructor
private Courier() {}
+ /**
+ * protected constructor
+ * @param epr
+ */
// protected constructor
protected Courier (EPR epr)
{
_epr = epr;
}
-
+ /**
+ * target EPR where to deliver ESB messages
+ */
EPR _epr;
}
Modified: labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/internal/soa/esb/couriers/CourierException.java
===================================================================
--- labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/couriers/CourierException.java 2006-10-19 14:37:28 UTC (rev 6912)
+++ labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/internal/soa/esb/couriers/CourierException.java 2006-10-20 10:53:36 UTC (rev 6944)
@@ -20,7 +20,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.soa.esb.couriers;
+package org.jboss.internal.soa.esb.couriers;
import org.jboss.soa.esb.BaseException;
Modified: labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/internal/soa/esb/couriers/CourierFactory.java
===================================================================
--- labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/couriers/CourierFactory.java 2006-10-19 14:37:28 UTC (rev 6912)
+++ labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/internal/soa/esb/couriers/CourierFactory.java 2006-10-20 10:53:36 UTC (rev 6944)
@@ -20,7 +20,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.soa.esb.couriers;
+package org.jboss.internal.soa.esb.couriers;
import java.net.URISyntaxException;
@@ -37,7 +37,7 @@
return _instance;
}
- public static Courier getDispatcher(EPR epr) throws CourierException
+ public static Courier getCourier(EPR epr) throws CourierException
{
try
{
Modified: labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java
===================================================================
--- labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/couriers/JmsCourier.java 2006-10-19 14:37:28 UTC (rev 6912)
+++ labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java 2006-10-20 10:53:36 UTC (rev 6944)
@@ -20,38 +20,162 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.soa.esb.couriers;
+package org.jboss.internal.soa.esb.couriers;
-import javax.jms.MessageConsumer;
+import java.util.*;
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.jms.TopicPublisher;
+import javax.naming.Context;
+import org.apache.log4j.Logger;
import org.jboss.soa.esb.addressing.EPR;
import org.jboss.soa.esb.addressing.helpers.JMSEpr;
+import org.jboss.soa.esb.helpers.AppServerContext;
import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.util.Util;
+import org.jboss.soa.esb.helpers.*;
public class JmsCourier extends Courier
{
- JmsCourier(EPR epr)
+ /**
+ * disable default constructor
+ */
+ private JmsCourier() { super(null); }
+ /**
+ * package protected constructor - Objects of Courier should only be instantiated by the Factory
+ * @param epr
+ */
+ JmsCourier(EPR epr) throws CourierException
{
super(new JMSEpr(epr));
- _sleepForRetries = 3;
+ _sleepForRetries = 3000;
+
+ try
+ {
+ _messageProperties = Util.propertiesFromSelector(getEpr().getMessageSelector());
+ createMessageProducer();
+ }
+ catch (Exception e) { throw new CourierException(e); }
- }
+ } //________________________________
+
+ /**
+ * Cast _epr to JMSEpr
+ * @return JMSEpr
+ */
protected JMSEpr getEpr() { return (JMSEpr)_epr; }
@Override
+ /**
+ * package the ESB message in a javax.jms.ObjectMessage, and send it
+ * @param message Message - the message to deliver
+ * @return boolean - the result of the delivery
+ * @throws CourierException - if problems were encountered
+ */
+
public boolean deliver(Message message) throws CourierException
{
- // TODO Auto-generated method stub
+ if (null==message)
+ return false;
+ while (null!=_messageProducer)
+ {
+ try
+ {
+ // obtain Serializable version of arg0 and package it in a jms ObjectMessage
+ sendMessage(_jmsSession.createObjectMessage(Util.serialize(message)));
+ return true;
+ }
+ catch (JMSException e) { jmsRetry(e); }
+ catch (Exception e) { throw new CourierException(e);}
+ }
return false;
- }
- protected String _queueName;
- protected QueueConnection _queueConnection;
- protected QueueSession _queueSession;
- protected Queue _queue;
- protected MessageConsumer _messageReceiver;
+ } //________________________________
+
+ /**
+ * send/publish a javax.jms.ObjectMessage (that will contain the serialized ESB Message)
+ * @param jmsMessage
+ */
+ protected void sendMessage(javax.jms.Message jmsMessage) throws JMSException
+ {
+ if (_messageProducer instanceof TopicPublisher)
+ ((TopicPublisher)_messageProducer).publish(jmsMessage);
+ else
+ _messageProducer.send(jmsMessage);
+ } //________________________________
+
+ private void jmsRetry(Exception exc)
+ {
+ _logger.error("JMS error. Attempting JMS reconnect.", exc);
+ _jmsConnection = null;
+ _jmsSession = null;
+ _messageProducer= null;
+
+ for (int i1 = 0; i1 < 5; i1++)
+ {
+ // try to reconnect to the queue
+ try { createMessageProducer(); }
+ catch (Exception e)
+ {
+ _logger.error("Reconnecting to JMS", e);
+ try { Thread.sleep(_sleepForRetries); }
+ catch (InterruptedException e1)
+ { // Just return after logging
+ _logger.error("Unexpected thread interupt exception.", e);
+ break;
+ }
+ }
+ }
+ }
+
+ protected void createMessageProducer() throws Exception
+ {
+
+ String sJndiType = getEpr().getJndiType();
+ if (Util.isNullString(sJndiType))
+ sJndiType = "jboss";
+ String sJndiURL = getEpr().getJndiURL();
+ if (Util.isNullString(sJndiURL))
+ sJndiURL = "localhost";
+ Context oJndiCtx = AppServerContext.getServerContext(sJndiType,sJndiURL);
+
+ String sFactoryClass = getEpr().getConnectionFactory();
+ if (Util.isNullString(sFactoryClass))
+ sFactoryClass = "ConnectionFactory";
+
+ Object tmp = oJndiCtx.lookup(sFactoryClass);
+
+ String sType = getEpr().getDestinationType();
+ if (JMSEpr.QUEUE_TYPE.equals(sType))
+ {
+ Queue queue = (Queue) oJndiCtx.lookup(getEpr().getDestinationName());
+ QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
+ QueueConnection qConn = qcf.createQueueConnection();
+ QueueSession qSess = qConn.createQueueSession(false,QueueSession.AUTO_ACKNOWLEDGE);
+ _jmsConnection = qConn;
+ _jmsSession = qSess;
+ _messageProducer = qSess.createProducer(queue);
+ }
+ else if(JMSEpr.TOPIC_TYPE.equals(sType))
+ {
+
+ }
+ else
+ throw new CourierException("Unknown destination type");
+
+ } //________________________________
+
+ protected Logger _logger = Logger.getLogger(JmsCourier.class);
protected String _messageSelector;
- protected final long _sleepForRetries; // milliseconds
+ protected Connection _jmsConnection;
+ protected Session _jmsSession;
+ protected MessageProducer _messageProducer;
+ protected long _sleepForRetries = 3000; // milliseconds
+ protected List<KeyValuePair> _messageProperties;
}
Modified: labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/MockAction.java
===================================================================
--- labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/MockAction.java 2006-10-20 10:51:37 UTC (rev 6943)
+++ labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/MockAction.java 2006-10-20 10:53:36 UTC (rev 6944)
@@ -1,3 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
package org.jboss.soa.esb.actions.templates;
import java.io.Serializable;
Added: labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/MockComposer.java
===================================================================
--- labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/MockComposer.java 2006-10-20 10:51:37 UTC (rev 6943)
+++ labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/MockComposer.java 2006-10-20 10:53:36 UTC (rev 6944)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.actions.templates;
+
+import java.text.SimpleDateFormat;
+
+import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.message.format.serialized.MessageImpl;
+import org.jboss.soa.esb.message.Message;
+
+
+/**
+ * Use this class to tune your XML configurations <p/>Once your config works
+ * with this dummy class, you can switch to your own action class
+ *
+ * @author Esteban
+ *
+ */
+public class MockComposer
+{
+ private static Logger _logger = Logger.getLogger(MockComposer.class);
+
+ public Message composeEmptyMessage(Object obj)
+ {
+ _logger.info(getLogMessage("process was called with <<" + obj.toString() + ">>"));
+ MessageImpl message = new MessageImpl();
+ return message;
+ } // ________________________________
+
+ private SimpleDateFormat s_oTS = new SimpleDateFormat(
+ "yyyy/MM/dd hh:mm:ss.SSS");
+
+ private String getLogMessage(String text)
+ {
+ return new StringBuilder()
+ .append(s_oTS.format(new java.util.Date(System.currentTimeMillis())))
+ .append(" ").append(text)
+ .toString()
+ ;
+ }
+
+} // ____________________________________________________________________________
Modified: labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/MockFileAction.java
===================================================================
--- labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/MockFileAction.java 2006-10-20 10:51:37 UTC (rev 6943)
+++ labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/MockFileAction.java 2006-10-20 10:53:36 UTC (rev 6944)
@@ -1,3 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
package org.jboss.soa.esb.actions.templates;
import java.io.File;
Modified: labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/MockSqlRowAction.java
===================================================================
--- labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/MockSqlRowAction.java 2006-10-20 10:51:37 UTC (rev 6943)
+++ labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/actions/templates/MockSqlRowAction.java 2006-10-20 10:53:36 UTC (rev 6944)
@@ -1,3 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
package org.jboss.soa.esb.actions.templates;
import java.io.Serializable;
Modified: labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/GatewayListenerController.java
===================================================================
--- labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/GatewayListenerController.java 2006-10-20 10:51:37 UTC (rev 6943)
+++ labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/GatewayListenerController.java 2006-10-20 10:53:36 UTC (rev 6944)
@@ -503,23 +503,23 @@
return EPRManager.getInstance(sDir);
}
- public EPR getEprByName (String name) throws IOException
+ public EPR getEprByName (String serviceName) throws IOException
{
- return getEprManager().loadEPR(name);
+ return getEprManager().loadEPR(serviceName);
} // ________________________________
- public void register (String name, EPR address)
+ public void register (String serviceName, EPR address)
{
- try { getEprManager().saveEPR(name,address); }
+ try { getEprManager().saveEPR(serviceName,address); }
catch (IOException e)
{
_logger.fatal("Cannot register service",e);
}
} // ________________________________
- public void unRegister (String name)
+ public void unRegister (String serviceName, EPR address)
{
- try { getEprManager().removeEPR(name); }
+ try { getEprManager().removeEPR(serviceName); }
catch (IOException e)
{
_logger.fatal("Cannot un-register service",e);
Modified: labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/JmsGatewayListener.java
===================================================================
--- labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/JmsGatewayListener.java 2006-10-20 10:51:37 UTC (rev 6943)
+++ labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/JmsGatewayListener.java 2006-10-20 10:53:36 UTC (rev 6944)
@@ -37,12 +37,13 @@
import org.apache.log4j.*;
+import org.jboss.internal.soa.esb.couriers.*;
import org.jboss.soa.esb.addressing.EPR;
import org.jboss.soa.esb.addressing.helpers.JMSEpr;
import org.jboss.soa.esb.helpers.AppServerContext;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.listeners.ListenerTagNames;;
+import org.jboss.soa.esb.message.listeners.ListenerTagNames;
public class JmsGatewayListener implements Runnable
{
@@ -58,8 +59,8 @@
public void run()
{
- if (null!=_eprInName)
- _controller.register(_eprInName,_eprIn);
+ if (null!=_serviceName)
+ _controller.register(_serviceName,_myEpr);
while (_controller.continueLooping())
{
@@ -73,14 +74,22 @@
_logger.warn("Action class method <"+_processMethod.getName()+"> returned a null object");
continue;
}
- Message message = null;
- try { message = (org.jboss.soa.esb.message.Message)obj; }
+ // try to deliver the composed message, using the appropriate courier
+ // to the target service
+ try
+ {
+ _courier.deliver((org.jboss.soa.esb.message.Message)obj);
+ }
catch (ClassCastException e)
{
_logger.error("Action class method <"+_processMethod.getName()+"> returned a non Message object");
continue;
}
- dispatch(message);
+ catch (CourierException e)
+ {
+ _logger.error("Courier <"+_courier.getClass().getName()+".deliver(Message) FAILED");
+ continue;
+ }
continue;
}
catch (InvocationTargetException e)
@@ -97,8 +106,8 @@
}
}
- if (null!=_eprInName)
- _controller.unRegister(_eprInName);
+ if (null!=_serviceName)
+ _controller.unRegister(_serviceName,_myEpr);
if (null != _queueSession)
try { _queueSession.close(); }
@@ -108,11 +117,6 @@
catch (Exception e2) {/* Tried my best - Just continue */ }
} // ________________________________
- protected void dispatch(Message message)
- {
-
- } // ________________________________
-
/**
* Check for mandatory and optional attributes in parameter tree
*
@@ -123,33 +127,35 @@
protected void checkMyParms() throws Exception
{
// Third arg is null - Exception will be thrown if attribute is not found
- _eprOutName = _controller.obtainAtt(_config, ListenerTagNames.EPR_OUT_NAME, null);
- _eprOut = _controller.getEprByName(_eprOutName);
- if (null==_eprOut)
- throw new ConfigurationException("EPR <"+_eprOutName+"> not found in registry");
+ _targetServiceName = _controller.obtainAtt(_config, ListenerTagNames.TARGET_SERVICE_NAME_TAG, null);
+ _targetEpr = _controller.getEprByName(_targetServiceName);
+ if (null==_targetEpr)
+ throw new ConfigurationException("EPR <"+_targetServiceName+"> not found in registry");
_queueName = _controller.obtainAtt(_config, JMSEpr.DESTINATION_NAME_TAG, null);
// Look for first "action" element - only first one will be used
- String tagName = ListenerTagNames.ACTION_ELEMENT;
+ String tagName = ListenerTagNames.ACTION_ELEMENT_TAG;
ConfigTree actionElement = _config.getFirstChild(tagName);
if (null==actionElement)
throw new ConfigurationException("Missing <"+tagName+"> element");
// class attribute
- _composerName = _controller.obtainAtt(actionElement,ListenerTagNames.ACTION_CLASS_ATTRIBUTE,null);
+ _composerName = _controller.obtainAtt(actionElement,ListenerTagNames.ACTION_CLASS_TAG,null);
_composerClass = Class.forName(_composerName);
Constructor oConst = _composerClass.getConstructor(new Class[] {ConfigTree.class});
_composer= oConst.newInstance(_config);
// From here onwards, all attributes have a default value
// process attribute
- tagName = ListenerTagNames.ACTION_PROCESS_METHOD;
+ tagName = ListenerTagNames.PROCESS_METHOD_TAG;
String sProcessMethod = _controller.obtainAtt(_config,tagName,tagName);
_processMethod = _composerClass.getMethod(sProcessMethod,new Class[] {Message.class});
// No problem if selector is null - everything in queue will be returned
_messageSelector = _config.getAttribute(JMSEpr.MESSAGE_SELECTOR_TAG);
+ _courier = CourierFactory.getCourier(_targetEpr);
+
prepareMessageReceiver();
} // ________________________________
@@ -164,8 +170,8 @@
Context oJndiCtx = AppServerContext.getServerContext(sJndiType,sJndiURL);
String sFactClass = _controller.obtainAtt(_config,JMSEpr.CONNECTION_FACTORY_TAG, "ConnectionFactory");
- _eprInName = _config.getAttribute(ListenerTagNames.EPR_IN_NAME);
- _eprIn = (null==_eprInName) ? null
+ _serviceName = _config.getAttribute(ListenerTagNames.SERVICE_NAME_TAG);
+ _myEpr = (null==_serviceName) ? null
: new JMSEpr(JMSEpr.QUEUE_TYPE,_queueName,sFactClass,sJndiType,sJndiURL,_messageSelector);
Object tmp = oJndiCtx.lookup(sFactClass);
@@ -222,11 +228,13 @@
protected GatewayListenerController _controller;
protected final long _sleepForRetries; // milliseconds
- protected String _eprInName ,_eprOutName;
- protected EPR _eprIn ,_eprOut;
+ protected String _serviceName,_targetServiceName;
+ protected EPR _myEpr ,_targetEpr;
protected String _composerName;
protected Class _composerClass;
protected Object _composer;
protected Method _processMethod;
+
+ protected Courier _courier;
}
Added: labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gatewayExample.xml
===================================================================
--- labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gatewayExample.xml 2006-10-20 10:51:37 UTC (rev 6943)
+++ labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gatewayExample.xml 2006-10-20 10:53:36 UTC (rev 6944)
@@ -0,0 +1,17 @@
+<GatewayListenerControllerExample
+ parameterReloadSecs="180"
+>
+ <JmsGatewayExample
+ service-name="JmsGatewayService"
+ listenerClass="org.jboss.soa.esb.listeners.JmsGatewayListener"
+ connection-factory="ConnectionFactory"
+ destination-type="queue"
+ destination-name="queue/A"
+ jndi-type="jboss"
+ jndi-URL="localhost"
+ message-selector="service='composeExampleService'"
+ >
+ <action class="org.jboss.soa.esb.message.listeners.MockComposer" process="composeEmptyMessage" />
+ </JmsGatewayExample>
+
+</GatewayListenerControllerExample>
Modified: labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/message/listeners/ActionProcessingPipeline.java
===================================================================
--- labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/message/listeners/ActionProcessingPipeline.java 2006-10-20 10:51:37 UTC (rev 6943)
+++ labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/message/listeners/ActionProcessingPipeline.java 2006-10-20 10:53:36 UTC (rev 6944)
@@ -35,7 +35,7 @@
_config = ActionUtils.getConfigTree(_message);
if (null==_config)
throw new IllegalArgumentException("Configuration needed for action classes");
- _actionList = _config.getChildren(ListenerTagNames.ACTION_ELEMENT);
+ _actionList = _config.getChildren(ListenerTagNames.ACTION_ELEMENT_TAG);
if (null==_actionList || _actionList.length<1)
throw new ConfigurationException("No actions in list");
}
@@ -67,10 +67,10 @@
for(ConfigTree oCurr : _actionList)
{
_currentIndex++;
- String attrName = ListenerTagNames.ACTION_CLASS_ATTRIBUTE;
+ String attrName = ListenerTagNames.ACTION_CLASS_TAG;
_currentAction = oCurr.getAttribute(attrName);
- attrName = ListenerTagNames.ACTION_PROCESS_METHOD;
+ attrName = ListenerTagNames.PROCESS_METHOD_TAG;
String sProcessMethod = obtainAttribute(oCurr,attrName,attrName);
_currentClass = Class.forName(_currentAction);
@@ -141,7 +141,7 @@
protected void actionClassException(ConfigTree tree, Exception thr)
{
thr.printStackTrace();
- String sMethod = obtainAttribute(tree,ListenerTagNames.ACTION_EXCEPTION_CALLBACK,null);
+ String sMethod = obtainAttribute(tree,ListenerTagNames.EXCEPTION_METHOD_TAG,null);
if (null!=sMethod)
try
{
@@ -160,7 +160,7 @@
*/
protected void actionClassFinishedOk(ConfigTree tree)
{
- String sMethod = obtainAttribute(tree,ListenerTagNames.ACTION_NORMAL_COMPLETION_CALLBACK,null);
+ String sMethod = obtainAttribute(tree,ListenerTagNames.NORMAL_COMPLETION_METHOD_TAG,null);
if (null!=sMethod)
try
{
@@ -177,7 +177,7 @@
String[] sa = new String[_actionList.length];
int i1=0;
for (ConfigTree oCurr : _actionList)
- sa[i1++]=obtainAttribute(oCurr,ListenerTagNames.ACTION_CLASS_ATTRIBUTE,"NO_CLASSNAME");
+ sa[i1++]=obtainAttribute(oCurr,ListenerTagNames.ACTION_CLASS_TAG,"NO_CLASSNAME");
return sa;
}
Modified: labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/message/listeners/JmsQueueListener.java
===================================================================
--- labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/message/listeners/JmsQueueListener.java 2006-10-20 10:51:37 UTC (rev 6943)
+++ labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/message/listeners/JmsQueueListener.java 2006-10-20 10:53:36 UTC (rev 6944)
@@ -114,7 +114,7 @@
// Default value of obtainAttribute is null - Exception will be thrown
String sQueue = obtainAttribute(JMSEpr.DESTINATION_NAME_TAG, null);
- _eprName = obtainAttribute(ListenerTagNames.EPR_IN_NAME,null);
+ _eprName = obtainAttribute(ListenerTagNames.SERVICE_NAME_TAG,null);
// No problem if selector is null - everything in queue will be returned
_sSelector = _config.getAttribute(JMSEpr.MESSAGE_SELECTOR_TAG);
Modified: labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/message/listeners/ListenerTagNames.java
===================================================================
--- labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/message/listeners/ListenerTagNames.java 2006-10-20 10:51:37 UTC (rev 6943)
+++ labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/message/listeners/ListenerTagNames.java 2006-10-20 10:53:36 UTC (rev 6944)
@@ -2,12 +2,12 @@
public class ListenerTagNames
{
- public static final String EPR_IN_NAME = "epr-in-name";
- public static final String EPR_OUT_NAME = "epr-out-name";
+ public static final String SERVICE_NAME_TAG = "service-name";
+ public static final String TARGET_SERVICE_NAME_TAG = "target-service-name";
- public static final String ACTION_ELEMENT = "action";
- public static final String ACTION_CLASS_ATTRIBUTE = "class";
- public static final String ACTION_PROCESS_METHOD = "process";
- public static final String ACTION_NORMAL_COMPLETION_CALLBACK = "okMethod";
- public static final String ACTION_EXCEPTION_CALLBACK= "exceptionMethod";
+ public static final String ACTION_ELEMENT_TAG = "action";
+ public static final String ACTION_CLASS_TAG = "class";
+ public static final String PROCESS_METHOD_TAG = "process";
+ public static final String NORMAL_COMPLETION_METHOD_TAG = "okMethod";
+ public static final String EXCEPTION_METHOD_TAG = "exceptionMethod";
}
Modified: labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/message/listeners/example.xml
===================================================================
--- labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/message/listeners/example.xml 2006-10-20 10:51:37 UTC (rev 6943)
+++ labs/jbossesb/workspace/eschifman/trunk/product/core/listeners/src/org/jboss/soa/esb/message/listeners/example.xml 2006-10-20 10:53:36 UTC (rev 6944)
@@ -2,7 +2,7 @@
parameterReloadSecs="180"
>
<ListenJmsQueueExample
- epr-name="myEprMnemonicName"
+ service-name="myServiceName"
listenerClass="org.jboss.soa.esb.message.listeners.JmsQueueListener"
connection-factory="ConnectionFactory"
destination-type="queue"
More information about the jboss-svn-commits
mailing list