[jboss-svn-commits] JBL Code SVN: r8693 - in labs/jbossesb/trunk: product/core/listeners/src/org/jboss/soa/esb/listeners/message product/docs/services qa/junit/src/org/jboss/soa/esb/actions qa/junit/src/org/jboss/soa/esb/listeners/message
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Jan 4 16:15:48 EST 2007
Author: kurt.stam at jboss.com
Date: 2007-01-04 16:15:44 -0500 (Thu, 04 Jan 2007)
New Revision: 8693
Removed:
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/CbrJmsQueueListener.java
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/message/CbrJmsQueueListenerTest.java
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/message/CbrJmsQueueListenerTest.xml
Modified:
labs/jbossesb/trunk/product/docs/services/ContentBasedRouting.odt
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/actions/CbrProxyActionUnitTest.java
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/actions/CbrProxyActionUnitTest.xml
Log:
Updating the CbrProxyAction to use the CbrListener, amd removing the old CbrJmsListener references.
Deleted: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/CbrJmsQueueListener.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/CbrJmsQueueListener.java 2007-01-04 20:53:26 UTC (rev 8692)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/CbrJmsQueueListener.java 2007-01-04 21:15:44 UTC (rev 8693)
@@ -1,137 +0,0 @@
-/*
- * 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.listeners.message;
-
-import java.net.URISyntaxException;
-import java.util.Collection;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.Priority;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.addressing.eprs.JMSEpr;
-import org.jboss.soa.esb.couriers.CourierException;
-import org.jboss.soa.esb.couriers.CourierFactory;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.listeners.ListenerInitializationException;
-import org.jboss.soa.esb.listeners.ListenerTagNames;
-import org.jboss.soa.esb.listeners.State;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.services.registry.RegistryException;
-import org.jboss.soa.esb.services.routing.MessageRouter;
-import org.jboss.soa.esb.services.routing.MessageRouterException;
-import org.jboss.soa.esb.services.routing.cbr.ContentBasedRouter;
-import org.jboss.soa.esb.services.routing.cbr.ContentBasedRouterFactory;
-
-/**
- * Esb Message aware Content Based Router JMS queue listener.
- * <p/> Expects an Object message whose getObject() method returns an org.jboss.soa.esb.message.Message
- * <br/>Clones the 'static' ConfigTree with which this listener was created, and stores the cloned tree
- * inside the Message (to enable all actions in the chain to use the configuration)
- * <br/>Instantiates and runs a new ActionProcessingPipeline on the received esb Message (augmented with
- * ConfigTree) that will in turn instantiate and run all action classes in the chain
- *
- * @author <a href="mailto:kurt.stam at redhat.com">Kurt Stam</a>
- * @since Version 4.0
- */
-
-public class CbrJmsQueueListener extends JmsQueueListener
-{
- private static transient Logger _logger = Logger.getLogger(CbrJmsQueueListener.class);
-
- public CbrJmsQueueListener(EsbListenerController controller, ConfigTree config) throws ConfigurationException {
- super(controller, config);
- }
-
- /**
- * Loops until controlling process determines
- * <br/>Waits for JMS Object messages containing ESB messages
- * <br/>When one is received, instantiates an action processing pipeline to process it
- * <br/>Pipeline is started in new Thread
- */
- public void listen()
- {
- try {
- setState(State.Loading_parameters);
- ContentBasedRouter cbr =ContentBasedRouterFactory.getRouter();
- String ruleSet=null;
- String ruleLanguage=null;
- if (_config.getFirstChild(ListenerTagNames.CBR_TAG)==null) {
- _logger.error("Required child element " + ListenerTagNames.CBR_TAG + " not found in " + _config.getName() + ".");
- throw new ListenerInitializationException("Required child element " + ListenerTagNames.CBR_TAG + " not found.");
- } else {
- ruleSet =_config.getFirstChild(ListenerTagNames.CBR_TAG).getAttribute(ListenerTagNames.RULE_SET_TAG);
- if (ruleSet==null) {
- throw new ListenerInitializationException("Required attribute " + ListenerTagNames.RULE_SET_TAG + " not found.");
- }
- ruleLanguage =_config.getFirstChild(ListenerTagNames.CBR_TAG).getAttribute(ListenerTagNames.RULE_LANGUAGE_TAG);
- }
- try { _controller.register(_config,_epr); }
- catch (RegistryException re)
- {
- _logger.log("Unable to Register service",Priority.FATAL, re.getLocalizedMessage(), re);
- return;
- }
-
- // We're now ready to process messages...
- setState(State.Ready);
- while (_controller.continueLooping()) {
- long lwait = _controller.millisToWait();
- Message message = (lwait > 0 ) ? receiveEsbMessage(100) : null;
- if (null!=message) {
- _logger.log(Priority.DEBUG, "Sending message to the Content Based Router.");
- Collection<String> destinationServices = cbr.route(ruleSet, ruleLanguage, message);
- if (Boolean.FALSE.equals(message.getProperties().getProperty(MessageRouter.DELIVER_MESSAGES))) {
- message.getProperties().setProperty(MessageRouter.ROUTING_DESTINATION_SERVICE_LIST, destinationServices);
- try {
- _logger.debug("Replying to caller");
- //TODO For now it's ok to assume it's JMS. But going forward this needs to be fixed
- if (message.getHeader().getCall()!=null && message.getHeader().getCall().getReplyTo()!=null) {
- JMSEpr replyTo = new JMSEpr(message.getHeader().getCall().getReplyTo());
- CourierFactory.getCourier(replyTo).deliver(message);
- } else {
- _logger.log(Priority.ERROR, "Unable to reply to caller. Could not optain replyTo EPR.");
- }
- } catch (URISyntaxException use) {
- _logger.log(Priority.ERROR, "Unable to reply to caller. "+ use.getLocalizedMessage(), use);
- } catch (CourierException ce) {
- _logger.log(Priority.ERROR, "Unable to reply to caller. "+ ce.getLocalizedMessage(), ce);
- }
- }
- }
- }
- try { _controller.unRegister(_eprCategoryName, _eprName, _epr); }
- catch (RegistryException re)
- {
- _logger.log( Priority.WARN,"Unable to Un-register service "+ re.getLocalizedMessage());
- //TODO Gotta find the cause of this
- }
-
- } catch (ListenerInitializationException lie) {
- _logger.log(Priority.FATAL, lie.getLocalizedMessage(), lie);
- } catch (MessageRouterException mre) {
- _logger.log(Priority.FATAL, mre.getLocalizedMessage(), mre);
- } finally {
- cleanup();
- }
- }
-}
Modified: labs/jbossesb/trunk/product/docs/services/ContentBasedRouting.odt
===================================================================
(Binary files differ)
Modified: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/actions/CbrProxyActionUnitTest.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/actions/CbrProxyActionUnitTest.java 2007-01-04 20:53:26 UTC (rev 8692)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/actions/CbrProxyActionUnitTest.java 2007-01-04 21:15:44 UTC (rev 8693)
@@ -27,6 +27,7 @@
import static org.junit.Assert.fail;
import java.io.File;
+import java.io.FileInputStream;
import java.io.InputStream;
import java.sql.DriverManager;
import java.sql.Statement;
@@ -39,10 +40,10 @@
import org.apache.log4j.xml.DOMConfigurator;
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.ListenerManager;
+import org.jboss.soa.esb.listeners.ListenerUtil;
import org.jboss.soa.esb.listeners.State;
import org.jboss.soa.esb.listeners.message.ActionProcessingPipeline;
-import org.jboss.soa.esb.listeners.message.EsbListenerController;
-import org.jboss.soa.esb.listeners.message.EsbListenerControllerFactory;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.message.format.MessageFactory;
import org.jboss.soa.esb.services.routing.MessageRouter;
@@ -63,7 +64,7 @@
public class CbrProxyActionUnitTest
{
private static Logger logger = Logger.getLogger(CbrProxyActionUnitTest.class);
- private static EsbListenerController _proc = null;
+ private static ListenerManager _proc = null;
private static String mDbDriver;
private static String mDbUrl;
private static String mDbUsername;
@@ -182,7 +183,9 @@
logger.info("Testing to see if we can instantiate one");
String deploymentConfigFile = TestEnvironmentUtil.getUserDir("qa")
+ "junit/src/org/jboss/soa/esb/actions/CbrProxyActionUnitTest.xml";
- _proc = EsbListenerControllerFactory.getInstance(deploymentConfigFile);
+ ConfigTree tree = ConfigTree.fromInputStream(new FileInputStream(deploymentConfigFile));
+ _proc = ListenerUtil.launchManager(tree, true);
+ _proc.waitUntilReady();
} catch (Throwable e) {
e.printStackTrace();
Modified: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/actions/CbrProxyActionUnitTest.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/actions/CbrProxyActionUnitTest.xml 2007-01-04 20:53:26 UTC (rev 8692)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/actions/CbrProxyActionUnitTest.xml 2007-01-04 21:15:44 UTC (rev 8693)
@@ -39,15 +39,20 @@
service-category="MessageRouting"
service-name="ContentBasedRoutingService"
service-description="This CBR routs messages to different service destination based whether the messageType is XML or Serializable"
- listenerClass="org.jboss.soa.esb.listeners.message.CbrJmsQueueListener"
- connection-factory="ConnectionFactory"
- destination-type="queue"
- destination-name="queue/A"
- jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
- jndi-URL="localhost"
- message-selector="service='ContentBasedRouting-SerializableOrXml'"
- >
- <cbr ruleSet="JBossESBRules.drl" />
+ listenerClass="org.jboss.soa.esb.listeners.message.CbrListener"
+ >
+ <EPR
+ protocol="jms"
+ connection-factory="ConnectionFactory"
+ destination-type="queue"
+ destination-name="queue/A"
+ jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
+ jndi-URL="localhost"
+ message-selector="service='ContentBasedRouting-SerializableOrXml'"
+ />
+
+ <cbr ruleSet="JBossESBRules.drl" />
+
</ContentBasedRouter>
</ContentBasedRouterTest>
Deleted: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/message/CbrJmsQueueListenerTest.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/message/CbrJmsQueueListenerTest.java 2007-01-04 20:53:26 UTC (rev 8692)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/message/CbrJmsQueueListenerTest.java 2007-01-04 21:15:44 UTC (rev 8693)
@@ -1,201 +0,0 @@
-/*
-* 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.listeners.message;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.InputStream;
-import java.sql.DriverManager;
-import java.sql.Statement;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Properties;
-
-import junit.framework.JUnit4TestAdapter;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.xml.DOMConfigurator;
-import org.jboss.soa.esb.addressing.EPR;
-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.listeners.State;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.format.MessageFactory;
-import org.jboss.soa.esb.services.registry.Registry;
-import org.jboss.soa.esb.services.registry.RegistryException;
-import org.jboss.soa.esb.services.registry.RegistryFactory;
-import org.jboss.soa.esb.services.routing.MessageRouter;
-import org.jboss.soa.esb.testutils.FileUtil;
-import org.jboss.soa.esb.testutils.HsqldbUtil;
-import org.jboss.soa.esb.testutils.TestEnvironmentUtil;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-/**
- * Testing the Content Based Router.
- *
- * @author kurt.stam at redhat.com
- *
- */
-public class CbrJmsQueueListenerTest
-{
- private static Logger logger = Logger.getLogger(CbrJmsQueueListenerTest.class);
- private static EsbListenerController _proc = null;
-
-
- private static String mDbDriver;
- private static String mDbUrl;
- private static String mDbUsername;
- private static String mDbPassword;
-
- private static final String SERVICE_CATEGORY_NAME = "MessageRouting";
- private static final String SERVICE_NAME = "ContentBasedRouterService";
-
- /**
- * Testing the Content Based Router.
- */
- @Test
- public void sendMessages()
- {
- try {
- sendMessage("First Message");
- //The second time the rulesEngine should be primed.
- sendMessage("Second Message");
- } catch (RegistryException re) {
- re.printStackTrace();
- assertTrue(false);
- } catch (CourierException ce) {
- ce.printStackTrace();
- assertTrue(false);
- }
- }
- /**
- * Sends a message to the CbrJmsQueueListener.
- *
- * @param body - a String containing the body of the message.
- * @throws Exception
- */
- private static void sendMessage(String body) throws RegistryException, CourierException{
- Message msg = MessageFactory.getInstance().getMessage();
- msg.getBody().setContents(body.getBytes());
- msg.getProperties().setProperty(MessageRouter.DELIVER_MESSAGES, Boolean.FALSE);
- Registry registry = RegistryFactory.getRegistry();
- Collection<EPR> eprs = registry.findEPRs(SERVICE_CATEGORY_NAME, SERVICE_NAME);
- for (Iterator<EPR> eprIterator=eprs.iterator();eprIterator.hasNext();){
- //Just use the first EPR in the list.
- EPR epr = eprIterator.next();
- Courier courier = CourierFactory.getCourier(epr);
- courier.deliver(msg);
- break;
- }
- }
-
- public static junit.framework.Test suite() {
- return new JUnit4TestAdapter(CbrJmsQueueListenerTest.class);
- }
-
- @BeforeClass
- public static void runBeforeAllTests()
- {
- try {
- DOMConfigurator.configure(TestEnvironmentUtil.getUserDir("product","../product") + "etc/test/resources/log4j.xml");
- TestEnvironmentUtil.setESBPropertiesFileToUse("product","../product");
- //Set the juddi properties file in System so juddi will pick it up later and use the test values.
- String juddiPropertiesFile = "/org/jboss/soa/esb/services/registry/juddi-qatest.properties";
- System.setProperty("juddi.propertiesFile", juddiPropertiesFile);
- //Read this properties file to get the db connection string
- Properties props = new Properties();
- InputStream inStream = Class.class.getResourceAsStream(juddiPropertiesFile);
- props.load(inStream);
- mDbDriver = props.getProperty("juddi.jdbcDriver");
- mDbUrl = props.getProperty("juddi.jdbcUrl");
- mDbUsername = props.getProperty("juddi.jdbcUsername");
- mDbPassword = props.getProperty("juddi.jdbcPassword");
-
- String database="not tested yet";
- if ("org.hsqldb.jdbcDriver".equals(mDbDriver)) {
- database = "hsqldb";
- //Bring up hsql on default port 9001
- HsqldbUtil.startHsqldb(TestEnvironmentUtil.getUserDir("product","../product") + "build/hsqltestdb", "juddi");
- } else if ("com.mysql.jdbc.Driver".equals(mDbDriver)) {
- database = "mysql";
- } //add and test your own database..
-
- //Get the registry-schema create scripts
- String sqlDir = TestEnvironmentUtil.getUserDir("product","../product") + "install/jUDDI-registry/sql/" + database + "/";
- //Drop what is there now, if exists. We want to start fresh.
- String sqlDropCmd = FileUtil.readTextFile(new File(sqlDir + "drop_database.sql"));
- String sqlCreateCmd = FileUtil.readTextFile(new File(sqlDir + "create_database.sql"));
- String sqlInsertPubCmd = FileUtil.readTextFile(new File(sqlDir + "insert_publishers.sql"));
-
- try {
- Class.forName(mDbDriver);
- } catch (Exception e) {
- System.out.println("ERROR: failed to load " + database + " JDBC driver.");
- e.printStackTrace();
- return;
- }
- java.sql.Connection con = DriverManager.getConnection(mDbUrl, mDbUsername, mDbPassword);
- Statement stmnt = con.createStatement();
- System.out.println("Dropping the schema if exist");
- stmnt.execute(sqlDropCmd);
- System.out.println("Creating the juddi-schema");
- stmnt.execute(sqlCreateCmd);
- System.out.println("Adding the jbossesb publisher");
- stmnt.execute(sqlInsertPubCmd);
-
- //Now we can bring up the ContentBasedRouter
- logger.info("Testing to see if we can instantiate one");
- String deploymentConfigFile = TestEnvironmentUtil.getUserDir("qa")
- + "junit/src/org/jboss/soa/esb/listeners/message/CbrJmsQueueListenerTest.xml";
- _proc = EsbListenerControllerFactory.getInstance(deploymentConfigFile);
- } catch (Throwable e) {
- e.printStackTrace();
- System.out.println("We should stop testing, since we don't have a db.");
- assertTrue(false);
- }
-
-
- }
-
- /**
- * Shutdown the database
- * @throws Exception
- */
- @AfterClass
- public static void runAfterAllTests() throws Exception {
- //Increase Sleep for debugging
- Thread.sleep(200);
- _proc.requestEnd();
- //Give the controller time to finish
- Thread.sleep(2000);
- State oS = _proc.getState();
- System.out.println("Exit state = "+oS.toString());
-
- if ("org.hsqldb.jdbcDriver".equals(mDbDriver)) {
- HsqldbUtil.stopHsqldb(mDbUrl, mDbUsername, mDbPassword);
- }
- }
-
-}
Deleted: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/message/CbrJmsQueueListenerTest.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/message/CbrJmsQueueListenerTest.xml 2007-01-04 20:53:26 UTC (rev 8692)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/message/CbrJmsQueueListenerTest.xml 2007-01-04 21:15:44 UTC (rev 8693)
@@ -1,41 +0,0 @@
-<!--
-/*
- * 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.
- */
- -->
-
-<ContentBasedRouterTest parameterReloadSecs="180">
- <ContentBasedRouter
- service-category="MessageRouting"
- service-name="ContentBasedRoutingService"
- service-description="This CBR routs messages to different service destination based whether the messageType is XML or Serializable"
- listenerClass="org.jboss.soa.esb.listeners.message.CbrJmsQueueListener"
- connection-factory="ConnectionFactory"
- destination-type="queue"
- destination-name="queue/A"
- jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
- jndi-URL="localhost"
- message-selector="service='ContentBasedRouting-SerializableOrXml'"
- >
- <cbr ruleSet="JBossESBRules.drl" />
- </ContentBasedRouter>
-
-</ContentBasedRouterTest>
More information about the jboss-svn-commits
mailing list