[jboss-svn-commits] JBL Code SVN: r14192 - in labs/jbossesb/trunk/product: rosetta and 20 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Aug 14 00:07:22 EDT 2007
Author: kurt.stam at jboss.com
Date: 2007-08-14 00:07:21 -0400 (Tue, 14 Aug 2007)
New Revision: 14192
Added:
labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/soa/esb/actions/MessageRedeliverer.java
labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/soa/esb/schedule/
labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/soa/esb/schedule/RedeliverEventMessageComposer.java
labs/jbossesb/trunk/product/services/jbossesb/src/main/resources/message-store-sql/mysql/drop_database.sql
labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/esb/persistence/tests/RedeliverClient.java
labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/esb/persistence/tests/RedeliverUnitTest.java
labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/esb/persistence/tests/ScheduledRedeliveryUnitTest.java
labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/esb/persistence/tests/config-01.xml
Removed:
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/AggregatorIntegrationTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/AggregatorTest.xml
Modified:
labs/jbossesb/trunk/product/lib/ext/
labs/jbossesb/trunk/product/rosetta/build.xml
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/Service.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedWiretap.java
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
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/common/Configuration.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/common/Environment.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/persistence/MessageStore.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/message/MessageDeliveryAdapterUnitTest.java
labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/internal/soa/esb/persistence/format/MessageStoreFactory.java
labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/internal/soa/esb/persistence/format/db/DBMessageStoreImpl.java
labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/internal/soa/esb/persistence/format/jcr/JCRMessageStoreImpl.java
labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/soa/esb/actions/MessagePersister.java
labs/jbossesb/trunk/product/services/jbossesb/src/main/resources/META-INF/jboss-esb.xml
labs/jbossesb/trunk/product/services/jbossesb/src/main/resources/message-store-sql/mysql/create_database.sql
labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/internal/soa/esb/persistence/format/jcr/JCRConnectionManagerUnitTest.java
labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/esb/persistence/tests/MessageStoreUnitTest.java
labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/messagestore/MessageStoreClient.java
labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/messagestore/MessageStoreTest.java
labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPClient.java
Log:
JBESB-581 redeliver service as part of failover
Property changes on: labs/jbossesb/trunk/product/lib/ext
___________________________________________________________________
Name: svn:ignore
- mysql-connector-java-5.0.5-bin.jar
+ mysql-connector-java-5.0.5-bin.jar
mysql-connector-java-3.1.12-bin.jar
Modified: labs/jbossesb/trunk/product/rosetta/build.xml
===================================================================
--- labs/jbossesb/trunk/product/rosetta/build.xml 2007-08-14 03:25:57 UTC (rev 14191)
+++ labs/jbossesb/trunk/product/rosetta/build.xml 2007-08-14 04:07:21 UTC (rev 14192)
@@ -68,6 +68,8 @@
includes="org/jboss/soa/esb/testutils/**/*.class"/>
<fileset dir="${org.jboss.esb.internal.dest}/tests/"
includes="org/jboss/soa/esb/common/tests/*.class"/>
+ <fileset dir="${org.jboss.esb.internal.dest}/tests/"
+ includes="org/jboss/**/Mock*.class" />
</jar>
</target>
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/Service.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/Service.java 2007-08-14 03:25:57 UTC (rev 14191)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/Service.java 2007-08-14 04:07:21 UTC (rev 14192)
@@ -19,6 +19,8 @@
*/
package org.jboss.soa.esb;
+import java.io.Serializable;
+
import org.jboss.internal.soa.esb.assertion.AssertArgument;
/**
@@ -29,8 +31,12 @@
*
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
*/
-public class Service {
+public class Service implements Serializable{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
private String category;
private String name;
@@ -40,6 +46,14 @@
this.category = category.trim();
this.name = name.trim();
}
+
+ public boolean equals(Service service) {
+ if (category.equals(service.getCategory()) && name.equals(service.getName())) {
+ return true;
+ } else {
+ return false;
+ }
+ }
public String getCategory() {
return category;
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-14 03:25:57 UTC (rev 14191)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedWiretap.java 2007-08-14 04:07:21 UTC (rev 14192)
@@ -108,11 +108,9 @@
+ ". Please fix your configuration.");
try {
- ServiceInvoker.deliverToDeadLetterChannel(message);
+ ServiceInvoker.deliverToDeadLetterService(message);
} catch (MessageDeliverException e) {
throw new MessageRouterException("Failed to deliver message to Dead Letter Channel.", e);
- } catch (RegistryException e) {
- throw new MessageRouterException("Failed to lookup Dead Letter Channel.", e);
}
}
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/MessageMulticaster.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/MessageMulticaster.java 2007-08-14 03:25:57 UTC (rev 14191)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/MessageMulticaster.java 2007-08-14 04:07:21 UTC (rev 14192)
@@ -120,13 +120,13 @@
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);
+ org.jboss.soa.esb.client.ServiceInvoker.deliverToDeadLetterService(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);
+ ServiceInvoker.deliverToDeadLetterService(message);
}
}
}
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java 2007-08-14 03:25:57 UTC (rev 14191)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java 2007-08-14 04:07:21 UTC (rev 14192)
@@ -45,6 +45,7 @@
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.persistence.MessageStore;
import org.jboss.soa.esb.services.registry.RegistryException;
import org.jboss.soa.esb.util.ClassUtil;
@@ -60,9 +61,10 @@
public class ServiceInvoker {
public static final String INTERNAL_SERVICE_CATEGORY = "JBossESB-Internal";
-
public static final String DEAD_LETTER_SERVICE_NAME = "DeadLetterService";
-
+ public static final String DELIVER_TO = "org.jboss.soa.esb.deliver.to";
+ public static final String IS_REDELIVERY = "org.jboss.soa.esb.deliver.is";
+
/**
* Class logger.
*/
@@ -91,15 +93,18 @@
* Dead letter channel Service invoker.
*/
private static ServiceInvoker dlQueueInvoker;
-
/**
+ * Dead letter Service
+ */
+ private static final Service dlqService = new Service(INTERNAL_SERVICE_CATEGORY, DEAD_LETTER_SERVICE_NAME);
+ /**
* 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 {
+ public ServiceInvoker(Service service) throws MessageDeliverException {
AssertArgument.isNotNull(service, "service");
this.service = service;
String lbClass = Configuration.getLoadBalancerPolicy();
@@ -192,12 +197,22 @@
* @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 {
+ public void deliverAsync(Message message) throws MessageDeliverException
+ {
AssertArgument.isNotNull(message, "message");
// Not interested in a reply
-
try {
post(message, false);
+ } catch (MessageDeliverException mde) {
+ if (message.getProperties().getProperty(IS_REDELIVERY)!=null
+ && "true".equalsIgnoreCase(Configuration.getRedeliveryDlsOn())
+ && !service.equals(dlqService)) {
+ message.getProperties().setProperty(MessageStore.CLASSIFICATION, MessageStore.CLASSIFICATION_RDLVR);
+ message.getProperties().setProperty(DELIVER_TO, service);
+ deliverToDeadLetterService(message);
+ } else {
+ throw mde;
+ }
} catch (FaultMessageException ex) {
throw new MessageDeliverException("Unexpected FaultMessageException during message delivery.", ex);
}
@@ -210,11 +225,15 @@
* @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);
+ public static synchronized void deliverToDeadLetterService(Message message) throws MessageDeliverException {
+ if (!"true".equalsIgnoreCase(Configuration.getRedeliveryDlsOn())) {
+ logger.debug("org.jboss.soa.esb.dls.redeliver is turned off");
+ } else {
+ if (dlQueueInvoker == null) {
+ dlQueueInvoker = new ServiceInvoker(dlqService);
+ }
+ dlQueueInvoker.deliverAsync(message);
}
- dlQueueInvoker.deliverAsync(message);
}
/**
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/common/Configuration.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/common/Configuration.java 2007-08-14 03:25:57 UTC (rev 14191)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/common/Configuration.java 2007-08-14 04:07:21 UTC (rev 14192)
@@ -58,6 +58,8 @@
new KeyValuePair(Environment.PARAMS_REPOS_IMPL_CLASS, getParamRepositoryImplClass()),
new KeyValuePair(Environment.OBJECT_STORE_CONFIG_FILE, getObjStoreConfigFile()),
new KeyValuePair(Environment.ENCRYPT_FACTORY_CLASS, getEncryptionFactoryClass()),
+ new KeyValuePair(Environment.LOAD_BALANCER_POLICY, getLoadBalancerPolicy()),
+ new KeyValuePair(Environment.REDELIVER_DLS_SERVICE_ON, getRedeliveryDlsOn()),
new KeyValuePair(Environment.MSG_STORE_DB_CONNECTION_URL, getStoreUrl()),
new KeyValuePair(Environment.MSG_STORE_DB_JDBC_DRIVER, getStoreDriver()),
new KeyValuePair(Environment.MSG_STORE_DB_CONNECTION_USER, getStoreUser()),
@@ -137,6 +139,12 @@
return ModulePropertyManager.getPropertyManager(ModulePropertyManager.CORE_MODULE).getProperty(Environment.LOAD_BALANCER_POLICY,
Environment.DEFAULT_LOAD_BALANCER_POLICY);
}
+
+ public static String getRedeliveryDlsOn()
+ {
+ return ModulePropertyManager.getPropertyManager(ModulePropertyManager.CORE_MODULE).getProperty(Environment.REDELIVER_DLS_SERVICE_ON,
+ Environment.DEFAULT_REDELIVER_DLS_ON);
+ }
/**
* The Registry Query Manager URI can be used to obtain information about services and their endPoints.
* @return Registry Query Manager URI String
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/common/Environment.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/common/Environment.java 2007-08-14 03:25:57 UTC (rev 14191)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/common/Environment.java 2007-08-14 04:07:21 UTC (rev 14192)
@@ -58,6 +58,7 @@
public static final String OBJECT_STORE_CONFIG_FILE = "org.jboss.soa.esb.objStore.configFile";
public static final String ENCRYPT_FACTORY_CLASS = "org.jboss.soa.esb.encryption.factory.class";
public static final String LOAD_BALANCER_POLICY = "org.jboss.soa.esb.loadbalancer.policy";
+ public static final String REDELIVER_DLS_SERVICE_ON = "org.jboss.soa.esb.dls.redeliver";
/**
* The Registry Query Manager URI defines the endPoint where registry queries can be made.
*/
@@ -103,7 +104,7 @@
public static final String DEFAULT_JNDI_CONTEXT_FACTORY = "org.jnp.interfaces.NamingContextFactory";
public static final String DEFAULT_JNDI_PKG_PREFIX = "org.jnp.interfaces";
public static final String DEFAULT_LOAD_BALANCER_POLICY = "org.jboss.soa.esb.listeners.ha.FirstAvailable";
-
+ public static final String DEFAULT_REDELIVER_DLS_ON = "true";
/*
* DatabaseMessageStore Persistence Store properties.
*/
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-14 03:25:57 UTC (rev 14191)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/message/UncomposedMessageDeliveryAdapter.java 2007-08-14 04:07:21 UTC (rev 14192)
@@ -114,7 +114,7 @@
* container class for the message payload (e.g. a JMS message).
* @throws MessageDeliverException Failed to deliverAsync message, after trying all available EPRs.
*/
- public void deliverAsync(Object messagePayload) throws MessageDeliverException {
+ public void deliverAsync(Object messagePayload) throws MessageDeliverException, RegistryException {
AssertArgument.isNotNull(messagePayload, "messagePayload");
Message message = composer.compose(messagePayload);
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/persistence/MessageStore.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/persistence/MessageStore.java 2007-08-14 03:25:57 UTC (rev 14191)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/persistence/MessageStore.java 2007-08-14 04:07:21 UTC (rev 14192)
@@ -30,9 +30,14 @@
public interface MessageStore
{
public final static String DEFAULT = "org.jboss.internal.soa.esb.persistence.format.db.DBMessageStoreImpl";
- public final static String DEFAULT_CLASSIFICATION = "STORE";
- public final static String DLQ_CLASSIFICATION = "DLQ";
- public final static String MESSAGE_STORE_URI = "message-store-uri";
+ public final static String CLASSIFICATION = "org.jboss.soa.esb.messagestore.classification";
+ public final static String CLASSIFICATION_DEFAULT = "STORE";
+ public final static String CLASSIFICATION_DLQ = "DLQ";
+ public final static String CLASSIFICATION_RDLVR = "RDLVR";
+ public final static String MESSAGE_STORE_URI = "message-store-uri";
+
+
+ /**
/**
* Get the implementation-specific message URI generator.
* @return the generator
@@ -50,7 +55,7 @@
/**
* Get a message from the store by URI.
* @param uid the unique message id
- * @return the message
+ * @return the message or null if it does not exist
* @throws MessageStoreException
*/
public Message getMessage (URI uid) throws MessageStoreException;
@@ -64,7 +69,7 @@
/**
* Indicate that a message has been delivered.
- * @param uid
+ * @param uid the unique message id
* @throws MessageStoreException
*/
public void setDelivered(URI uid) throws MessageStoreException;
@@ -83,4 +88,13 @@
* @throws MessageStoreException
*/
public Map<URI, Message> getAllMessages(String classification) throws MessageStoreException;
+
+ /**
+ * Get a message from the store by URI.
+ * @param uid the unique message id
+ * @param classification the classification of the message
+ * @return the message or null if it does not exist
+ * @throws MessageStoreException
+ */
+ public Message getMessage (URI uid, String classification) throws MessageStoreException;
}
\ No newline at end of file
Deleted: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/AggregatorIntegrationTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/AggregatorIntegrationTest.java 2007-08-14 03:25:57 UTC (rev 14191)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/AggregatorIntegrationTest.java 2007-08-14 04:07:21 UTC (rev 14192)
@@ -1,270 +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.actions;
-
-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.Properties;
-
-import junit.framework.JUnit4TestAdapter;
-
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.addressing.EPR;
-import org.jboss.soa.esb.addressing.MalformedEPRException;
-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.listeners.StandAloneBootStrapper;
-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.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 <a href="mailto:kurt.stam at redhat.com">Kurt Stam</a>
- * @author <a href="mailto:schifest at heuristica.com.ar">Esteban</a>
- * @since Version 4.0
- *
- */
-public class AggregatorIntegrationTest
-{
- private static Logger logger = Logger.getLogger(AggregatorIntegrationTest.class);
-
- private static StandAloneBootStrapper _boot = 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 = "SplitterService";
-
- /**
- * Testing the Content Based Router.
- */
- @Test
- public void sendMessages()
- {
- try
- {
- sendMessage("<message>First Message</message>");
- // The second time the rulesEngine should be primed.
- sendMessage("<message>Second Message</message>");
- }
- catch (RegistryException re)
- {
- re.printStackTrace();
- assertTrue(false);
- }
- catch (CourierException ce)
- {
- ce.printStackTrace();
- assertTrue(false);
- }
- catch (MalformedEPRException me)
- {
- me.printStackTrace();
- assertTrue(false);
- }
- }
-
- /**
- * Sends a message to the CbrJmsQueueListener.
- *
- * @param body -
- * a String containing the body of the message.
- * @throws RegistryException
- * @throws CourierException
- * @throws MalformedEPRException
- */
-
- private static void sendMessage(String body) throws RegistryException, CourierException, MalformedEPRException
- {
- Message msg = MessageFactory.getInstance().getMessage();
- msg.getBody().setByteArray(body.getBytes());
-
- Registry registry = RegistryFactory.getRegistry();
- EPR epr = registry.findEPR(SERVICE_CATEGORY_NAME,
- SERVICE_NAME);
- Courier courier = CourierFactory.getCourier(epr);
- courier.deliver(msg);
- }
-
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(AggregatorIntegrationTest.class);
- }
-
- @BeforeClass
- public static void runBeforeAllTests()
- {
- System.setProperty("com.arjuna.common.util.propertyservice.verbosePropertyManager", "on");
- try
- {
- TestEnvironmentUtil.setESBPropertiesFileToUse();
-
- logger.info(Configuration.dump());
-
- logger.info(Configuration.getRegistryImplementationClass());
- // 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-unittest.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
- String deploymentConfigFile = TestEnvironmentUtil.getUserDir("product")
- + "rosetta/tests/src/org/jboss/soa/esb/actions/AggregatorTest.xml";
- String validationFileName = TestEnvironmentUtil.getUserDir(
- "product", "../product")
- + "/etc/schemas/xml/jbossesb-1.0.1.xsd";
- // Make sure this file exists
- File validationFile = new File(validationFileName);
- if (!validationFile.exists())
- {
- System.err.println("Validation file "
- + validationFile.getAbsolutePath() + " does not exist");
- assertTrue(false);
- }
- _boot = new StandAloneBootStrapper(deploymentConfigFile,
- validationFileName);
-
- logger
- .info("Testing to see if we can instantiate and start ListenerManager");
- }
- 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
- {
- Thread.sleep(2000);
- // Increase Sleep for debugging
- _boot.requestEnd();
- // Give the esb time to finish
- Thread.sleep(2000);
- // Cleaning up the generated files
- String listenerConfigFile = TestEnvironmentUtil.getUserDir("product")
- + "junit/src/org/jboss/soa/esb/actions/jbossesb-listener.xml";
- File listenerFile = new File(listenerConfigFile);
- if (listenerFile.exists())
- listenerFile.delete();
- String gatewayConfigFile = TestEnvironmentUtil.getUserDir("product")
- + "junit/src/org/jboss/soa/esb/actions/jbossesb-gateway.xml";
- File gatewayFile = new File(gatewayConfigFile);
- if (gatewayFile.exists())
- gatewayFile.delete();
-
- if ("org.hsqldb.jdbcDriver".equals(mDbDriver))
- {
- HsqldbUtil.stopHsqldb(mDbUrl, mDbUsername, mDbPassword);
- }
- }
-
-}
Deleted: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/AggregatorTest.xml
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/AggregatorTest.xml 2007-08-14 03:25:57 UTC (rev 14191)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/AggregatorTest.xml 2007-08-14 04:07:21 UTC (rev 14192)
@@ -1,83 +0,0 @@
-<?xml version = "1.0" encoding = "UTF-8"?>
-<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd"
-parameterReloadSecs="10">
-
- <!-- for activemq use:
- jndi-context-factory="org.apache.activemq.jndi.ActiveMQInitialContextFactory"
- jndi-URL="tcp://localhost:61616" -->
-
- <!-- for mq series use:
- jndi-context-factory="com.ibm.mq.jms.context.WMQInitialContextFactory"
- jndi-URL="dev37:1414/SYSTEM.DEF.SVRCONN" -->
-
- <!-- for jbossmq use:
- jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
- jndi-URL="localhost" -->
-
-
- <providers>
- <jms-provider name="localhost"
- connection-factory="ConnectionFactory"
- jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
- jndi-URL="localhost" >
-
- <jms-bus busid="QueueA">
- <jms-message-filter
- dest-type="QUEUE"
- dest-name="queue/A"
- />
- </jms-bus>
- <jms-bus busid="QueueB">
- <jms-message-filter
- dest-type="QUEUE"
- dest-name="queue/B"
- />
- </jms-bus>
- </jms-provider>
- </providers>
- <services>
- <service
- category="Aggregation"
- name="Aggregrator"
- description="Aggregates messages">
- <listeners>
- <jms-listener name="AggregatorListenQueue" busidref="QueueA"
- maxThreads="1">
- </jms-listener>
- </listeners>
- <actions>
- <action class="org.jboss.soa.esb.actions.Aggregator" name="Aggregator">
- <property name="timeoutInMillies" value="60000"/>
- </action>
- <action name="print-after" class="org.jboss.soa.esb.actions.SystemPrintln">
- <property name="message" value="An aggregated message was created" />
- </action>
- <!-- add transformation action to aggregate the attachments into 1 message -->
- </actions>
- </service>
- <service
- category="MessageRouting"
- name="SplitterService"
- description="Sends messages to 2 destinations">
- <listeners>
- <jms-listener name="SplitterListenQueue"
- busidref="QueueB"
- maxThreads="1">
- </jms-listener>
- </listeners>
- <actions>
- <action name="print-before" class="org.jboss.soa.esb.actions.SystemPrintln">
- <property name="message" value="Hello Static Router" />
- </action>
- <action process="split" class="org.jboss.soa.esb.actions.StaticRouter" name="StaticRouter">
- <property name="destinations">
- <!-- send 2 copies straight to the aggregator, in reality you would route
- them through maybe a transformer and another service first -->
- <route-to service-category="Aggregation" service-name="Aggregrator" />
- <route-to service-category="Aggregation" service-name="Aggregrator" />
- </property>
- </action>
- </actions>
- </service>
- </services>
-</jbossesb>
Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/message/MessageDeliveryAdapterUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/message/MessageDeliveryAdapterUnitTest.java 2007-08-14 03:25:57 UTC (rev 14191)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/message/MessageDeliveryAdapterUnitTest.java 2007-08-14 04:07:21 UTC (rev 14192)
@@ -96,6 +96,8 @@
fail("Expected MessageDeliverException");
} catch(MessageDeliverException e) {
// Expected.
+ } catch(RegistryException re) {
+ fail("RegistryException");
}
assertNoDeliveryAttempted();
}
@@ -109,6 +111,8 @@
fail("Expected MessageDeliverException");
} catch(MessageDeliverException e) {
// Expected.
+ } catch(RegistryException re) {
+ fail("RegistryException");
}
assertNoDeliveryAttempted();
}
@@ -122,22 +126,27 @@
fail("Expected MessageDeliverException");
} catch(MessageDeliverException e) {
// Expected.
+ } catch(RegistryException re) {
+ fail("RegistryException");
}
assertNoDeliveryAttempted();
}
@Test
public void test_deliver() throws MessageDeliverException {
// Make sure the delivery happens as expected...
-
- deliveryAdapter.deliverAsync(payload);
- assertEquals(null, courier1.message);
- assertEquals(null, courier2.message);
- assertEquals(null, courier3.message);
- assertEquals(payload, ActionUtils.getTaskObject(courier4.message));
-
- String payload2 = "*YYY*";
- deliveryAdapter.deliverAsync(payload2);
- assertEquals(payload2, ActionUtils.getTaskObject(courier4.message));
+ try {
+ deliveryAdapter.deliverAsync(payload);
+ assertEquals(null, courier1.message);
+ assertEquals(null, courier2.message);
+ assertEquals(null, courier3.message);
+ assertEquals(payload, ActionUtils.getTaskObject(courier4.message));
+
+ String payload2 = "*YYY*";
+ deliveryAdapter.deliverAsync(payload2);
+ assertEquals(payload2, ActionUtils.getTaskObject(courier4.message));
+ } catch(RegistryException re) {
+ fail("RegistryException");
+ }
}
Modified: labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/internal/soa/esb/persistence/format/MessageStoreFactory.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/internal/soa/esb/persistence/format/MessageStoreFactory.java 2007-08-14 03:25:57 UTC (rev 14191)
+++ labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/internal/soa/esb/persistence/format/MessageStoreFactory.java 2007-08-14 04:07:21 UTC (rev 14192)
@@ -26,6 +26,7 @@
import org.apache.log4j.Logger;
import org.jboss.soa.esb.services.persistence.MessageStore;
+import org.jboss.soa.esb.services.persistence.RedeliverStore;
import org.jboss.soa.esb.util.ClassUtil;
/**
*
@@ -48,6 +49,15 @@
public MessageStore getMessageStore() {
return getMessageStore(MessageStore.DEFAULT);
}
+
+ /**
+ * Returns a the default MessageStore implementation (Database).
+ * @return MessageStore
+ */
+ public RedeliverStore getRedeliverStore() {
+ return (RedeliverStore) getMessageStore(MessageStore.DEFAULT);
+ }
+
/**
* Returns an instance of a MessageStore, of the type 'className'. Multiple instances of the same
* type of MessageStore will be created for different sets of properties.
Modified: labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/internal/soa/esb/persistence/format/db/DBMessageStoreImpl.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/internal/soa/esb/persistence/format/db/DBMessageStoreImpl.java 2007-08-14 03:25:57 UTC (rev 14191)
+++ labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/internal/soa/esb/persistence/format/db/DBMessageStoreImpl.java 2007-08-14 04:07:21 UTC (rev 14192)
@@ -33,7 +33,9 @@
import org.apache.log4j.Logger;
import org.jboss.internal.soa.esb.message.urigen.DefaultMessageURIGenerator;
-import org.jboss.internal.soa.esb.thirdparty.Base64;
+import org.jboss.soa.esb.Service;
+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.urigen.MessageURIGenerator;
import org.jboss.soa.esb.persistence.manager.ConnectionManager;
@@ -41,30 +43,24 @@
import org.jboss.soa.esb.persistence.manager.ConnectionManagerFactory;
import org.jboss.soa.esb.services.persistence.MessageStore;
import org.jboss.soa.esb.services.persistence.MessageStoreException;
+import org.jboss.soa.esb.services.persistence.RedeliverStore;
+import org.jboss.soa.esb.services.registry.RegistryException;
import org.jboss.soa.esb.util.Util;
+import org.jboss.util.Base64;
-public class DBMessageStoreImpl implements MessageStore
+public class DBMessageStoreImpl implements RedeliverStore
{
- private static Logger logger = Logger.getLogger(DBMessageStoreImpl.class);
+ private Logger logger = Logger.getLogger(this.getClass());
protected ConnectionManager mgr = null;
-
- protected Connection conn = null;
-
- //protected ResultSet rs = null;
-
- //protected PreparedStatement ps = null;
+
+ private int maxRedeliverCount = 10;
protected MessageURIGenerator uriGenerator = new DefaultMessageURIGenerator();
- public DBMessageStoreImpl()
+ public DBMessageStoreImpl() throws ConnectionManagerException
{
- try {
mgr = ConnectionManagerFactory.getConnectionManager();
- } catch (ConnectionManagerException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
}
/* (non-Javadoc)
@@ -82,24 +78,11 @@
{
// String messageString = null;
URI uid = null;
+ Connection conn=null;
try{
conn = mgr.getConnection();
-
uid = uriGenerator.generateMessageURI(message);
-
- String messageString = Base64.encodeObject(Util.serialize(message));
-
- // insert into the database
- String sql = "insert into message(uuid, type, message, delivered, classification) values(?,?,?,?,?)";
- PreparedStatement ps = conn.prepareStatement(sql);
- ps.setString(1, uid.toString());
- ps.setString(2, message.getType().toString());
- ps.setString(3, messageString);
- ps.setString(4, "TRUE");
- ps.setString(5, classification);
- ps.execute();
- ps.close();
-
+ insert(uid, message, classification, "TRUE", conn);
}
catch (Exception e)
{
@@ -108,7 +91,7 @@
}
finally
{
- release();
+ release(conn);
}
return uid;
@@ -121,93 +104,74 @@
public synchronized Message getMessage (URI uid)
throws MessageStoreException
{
-
- String sql = "select uuid,type,message from message where uuid=?";
Message message = null;
-
- try
- {
+ Connection conn=null;
+ try {
conn = mgr.getConnection();
- PreparedStatement ps = conn.prepareStatement(sql);
- ps.setString(1, uid.toString());
-
- ResultSet rs = ps.executeQuery();
- if (!rs.next())
- throw new MessageStoreException("Non existing Message for UUID: " + uid);
-
- message = Util.deserialize((Serializable) Base64.decodeToObject(rs
- .getString(3)));
-
- }
- catch (SQLException e)
- {
+ message = select(uid, conn);
+ } catch (Exception e) {
throw new MessageStoreException(e);
+ } finally {
+ release(conn);
}
- catch (Exception e)
- {
- logger.error(e);
- throw new MessageStoreException(e);
- }
- finally
- {
- release();
- }
-
return message;
-
}
+
+ /**
+ * return a @Message based on the passed in key in the form of a JBoss ESB @URI
+ * format for URI: "urn:jboss/esb/message/UID#" + UUID.randomUUID()" - see the method in this class @addMessage
+ */
+ public synchronized Message getMessage (URI uid, String classification)
+ throws MessageStoreException
+ {
+ Message message = null;
+ Connection conn=null;
+ try {
+ conn = mgr.getConnection();
+ message = select(uid, classification, conn);
+ } catch (Exception e) {
+ throw new MessageStoreException(e);
+ } finally {
+ release(conn);
+ }
+ return message;
+ }
/**
*
* @param uid - key for message to set undelivered flag on
* @throws MessageStoreException
*/
- public void setUndelivered(URI uid) throws MessageStoreException{
+ public void setUndelivered(URI uid) throws MessageStoreException
+ {
String sql = "update message set delivered = 'FALSE' where uuid=?";
-
- try
- {
+ Connection conn=null;
+ try {
conn = mgr.getConnection();
-
PreparedStatement ps = conn.prepareStatement(sql);
ps.setString(1, uid.toString());
ps.execute();
-
- }
- catch (Exception e)
- {
- logger.error(e);
+ } catch (Exception e) {
throw new MessageStoreException(e);
- }
- finally
- {
- release();
+ } finally {
+ release(conn);
}
}
public void setDelivered(URI uid) throws MessageStoreException{
String sql = "update message set delivered = 'TRUE' where uuid=?";
-
- try
- {
+ Connection conn=null;
+ try {
conn = mgr.getConnection();
-
PreparedStatement ps = conn.prepareStatement(sql);
ps.setString(1, "FALSE");
ps.execute();
-
- }
- catch (Exception e)
- {
- logger.error(e);
+ } catch (Exception e) {
throw new MessageStoreException(e);
- }
- finally
- {
- release();
+ } finally {
+ release(conn);
}
-
}
/**
@@ -222,7 +186,7 @@
if (classification!=null) {
sql += " and classification='" + classification + "'";
}
-
+ Connection conn=null;
try
{
conn = mgr.getConnection();
@@ -242,12 +206,11 @@
}
catch (Exception e)
{
- logger.error(e);
throw new MessageStoreException(e);
}
finally
{
- release();
+ release(conn);
}
logger.info("retrieved " + messages.size() + " undelivered messages");
return messages;
@@ -262,11 +225,11 @@
*/
public Map<URI, Message> getAllMessages(String classification) throws MessageStoreException {
HashMap<URI, Message> messages = new HashMap<URI, Message>();
- String sql = "select uuid from message";
+ String sql = "select uuid, message from message";
if (classification!=null) {
sql += " where classification='" + classification + "'";
}
-
+ Connection conn=null;
try
{
conn = mgr.getConnection();
@@ -277,7 +240,7 @@
while (rs.next()) {
URI uid = new URI(rs.getString(1));
- Message msg = getMessage(uid);
+ Message msg = Util.deserialize((Serializable) Base64.decodeToObject( rs.getString(2)));
messages.put(uid, msg);
}
rs.close();
@@ -286,19 +249,18 @@
}
catch (Exception e)
{
- logger.error(e);
throw new MessageStoreException(e);
}
finally
{
- release();
+ release(conn);
}
- logger.info("retrieved " + messages.size() + " undelivered messages");
+ logger.debug("retrieved " + messages.size() + " " + classification + " messages");
return messages;
}
- private void release ()
+ private void release (Connection conn)
{
if (conn != null)
@@ -309,8 +271,176 @@
}
catch (Exception e2)
{
+ logger.warn(e2.getMessage(), e2);
}
}
}
+ /**
+ *
+ */
+ public boolean redeliver(URI uuid) throws MessageStoreException
+ {
+ boolean isDelivered=false;
+ boolean error=false;
+ Connection con = null;
+ try
+ {
+ con = mgr.getConnection();
+ con.setAutoCommit(false);
+ con.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
+
+ Message message=select(uuid, con);
+
+ if (message!=null && delete(uuid, con)==1) {
+ //now any good db should have set a read lock on this record, until we commit.
+ //if exception is thrown up the delivery count on the message
+ //if exceeds the maxcount then update the classification to DLQ.
+ Service to = (Service) message.getProperties().getProperty(ServiceInvoker.DELIVER_TO);
+ try {
+ ServiceInvoker si = new ServiceInvoker(to.getCategory(), to.getName());
+ message.getProperties().setProperty(RedeliverStore.IS_REDELIVERY, true);
+ si.deliverAsync(message);
+ isDelivered=true;
+ } catch (MessageDeliverException e) {
+ logger.debug(e.getMessage(), e);
+ } catch (RegistryException e) {
+ logger.error(e.getMessage(), e);
+ }
+
+ if (isDelivered) {
+ //the message is delivered, we're good so remove it from the store
+ delete(uuid, con);
+ } else {
+ //the message was not delivered
+ if (message.getProperties().getProperty(DELIVER_COUNT)==null) {
+ //appearantly it was the first time
+ message.getProperties().setProperty(RedeliverStore.DELIVER_COUNT, Integer.valueOf("1"));
+ insert(uuid, message, MessageStore.CLASSIFICATION_RDLVR, "FALSE", con);
+ } else {
+ Integer redeliverCount = (Integer) message.getProperties().getProperty(DELIVER_COUNT);
+ if (redeliverCount < maxRedeliverCount) {
+ //up the count
+ message.getProperties().setProperty(RedeliverStore.DELIVER_COUNT, ++redeliverCount);
+ insert(uuid, message, MessageStore.CLASSIFICATION_RDLVR, "FALSE", con);
+ } else {
+ //undeliverable, send to the DLQ
+ insert(uuid, message, MessageStore.CLASSIFICATION_DLQ, "FALSE", con);
+ }
+ }
+ }
+ }
+ }
+ catch (SQLException e)
+ {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Deadlocks may occur under normal processing");
+ logger.debug(e.getMessage(), e);
+ }
+ error=true;
+ }
+ finally
+ {
+ if (con!=null) {
+ try {
+ if (!error) {
+ con.commit();
+ } else {
+ con.rollback();
+ }
+ } catch (SQLException e) {
+ logger.error(e);
+ }
+ try {
+ con.close();
+ } catch (Exception e2) {
+ logger.error(e2);
+ }
+ }
+ }
+ return isDelivered;
+ }
+
+
+ private Message select(URI uid, Connection connection)
+ throws SQLException, MessageStoreException
+ {
+ Message message=null;
+ String selectSql = "select * from message where uuid=?";
+ PreparedStatement selectStmt = connection.prepareStatement(selectSql);
+ selectStmt.setObject(1, uid.toString());
+ ResultSet rs = selectStmt.executeQuery();
+ if (rs.next()) {
+ try {
+ message = Util.deserialize((Serializable) Base64.decodeToObject(rs.getString("message")));
+ } catch (Exception e) {
+ throw new MessageStoreException(e);
+ }
+ }
+ rs.close();
+ selectStmt.close();
+ return message;
+ }
+
+ private Message select(URI uid, String classification, Connection connection)
+ throws SQLException, MessageStoreException
+ {
+ Message message=null;
+ String selectSql = "select * from message where uuid=? and classification=?";
+ PreparedStatement selectStmt = connection.prepareStatement(selectSql);
+ selectStmt.setObject(1, uid.toString());
+ selectStmt.setObject(2, classification);
+ ResultSet rs = selectStmt.executeQuery();
+ if (rs.next()) {
+ try {
+ message = Util.deserialize((Serializable) Base64.decodeToObject(rs.getString("message")));
+ } catch (Exception e) {
+ throw new MessageStoreException(e);
+ }
+ }
+ rs.close();
+ selectStmt.close();
+ return message;
+ }
+
+ private int delete(URI uid, Connection connection)
+ throws SQLException
+ {
+ String deleteSql = "delete from message where uuid=?";
+ PreparedStatement stmt = connection.prepareStatement(deleteSql);
+ stmt.setObject(1, uid.toString());
+ int result = stmt.executeUpdate();
+ stmt.close();
+ return result;
+ }
+
+ private void insert(URI uid, Message message, String classification, String delivered, Connection conn)
+ throws SQLException, MessageStoreException
+ {
+ String sql = "insert into message(uuid, type, message, delivered, classification) values(?,?,?,?,?)";
+ PreparedStatement ps = conn.prepareStatement(sql);
+
+ ps.setString(1, uid.toString());
+ ps.setString(2, message.getType().toString());
+ try {
+ String messageString = Base64.encodeObject(Util.serialize(message));
+ ps.setString(3, messageString);
+ } catch (Exception e) {
+ throw new MessageStoreException(e);
+ }
+ ps.setString(4, "TRUE");
+ ps.setString(5, classification);
+ ps.execute();
+ ps.close();
+ }
+
+
+ public int getMaxRedeliverCount() {
+ return maxRedeliverCount;
+ }
+
+ public void setMaxRedeliverCount(int maxRedeliverCount) {
+ this.maxRedeliverCount = maxRedeliverCount;
+ }
+
}
Modified: labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/internal/soa/esb/persistence/format/jcr/JCRMessageStoreImpl.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/internal/soa/esb/persistence/format/jcr/JCRMessageStoreImpl.java 2007-08-14 03:25:57 UTC (rev 14191)
+++ labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/internal/soa/esb/persistence/format/jcr/JCRMessageStoreImpl.java 2007-08-14 04:07:21 UTC (rev 14192)
@@ -53,6 +53,8 @@
/**
* Message store that persists messages to a JSR 170 content repository.
*
+ * //TODO add the handling of classficiations
+ *
* @author Derek Adams
*/
public class JCRMessageStoreImpl implements MessageStore {
@@ -97,6 +99,21 @@
throw new MessageStoreException(e);
}
}
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.soa.esb.services.persistence.MessageStore#getMessage(java.net.URI)
+ */
+ public Message getMessage(URI uri, String classification) throws MessageStoreException {
+ try {
+ Session session = JCRConnectionManager.getInstance().newRepositorySession();
+ Node root = getMessageStoreRootNode(session);
+ return loadMessage(root, uri);
+ } catch (RepositoryException e) {
+ throw new MessageStoreException(e);
+ }
+ }
/**
* Save a message to the content repository.
Modified: labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/soa/esb/actions/MessagePersister.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/soa/esb/actions/MessagePersister.java 2007-08-14 03:25:57 UTC (rev 14191)
+++ labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/soa/esb/actions/MessagePersister.java 2007-08-14 04:07:21 UTC (rev 14192)
@@ -28,6 +28,7 @@
package org.jboss.soa.esb.actions;
import java.net.URI;
+import java.util.Map;
import org.apache.log4j.Logger;
import org.jboss.internal.soa.esb.persistence.format.MessageStoreFactory;
@@ -36,13 +37,9 @@
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.services.persistence.MessageStore;
import org.jboss.soa.esb.services.persistence.MessageStoreException;
-import org.jboss.soa.esb.services.registry.RegistryException;
-import org.jboss.soa.esb.services.routing.MessageRouterException;
public class MessagePersister extends AbstractActionPipelineProcessor
{
- public final static String SERVICE_CATEGORY = "JBossESB-Internal";
- public final static String SERVICE_NAME = "DeadLetterService";
public final static String MESSAGE_STORE_CLASS = "message-store-class";
public final static String CLASSIFICATION_ATTR = "classification";
@@ -52,7 +49,7 @@
private String classification;
private Logger log = Logger.getLogger(this.getClass());
- public MessagePersister(ConfigTree config) throws ConfigurationException, RegistryException, MessageRouterException
+ public MessagePersister(ConfigTree config) throws ConfigurationException
{
this.config = config;
}
@@ -61,13 +58,18 @@
*/
public Message process(Message message) throws ActionProcessingException
{
+ String classification = this.classification;
try {
+ //the message can override the classification
+ if (message.getProperties().getProperty(MessageStore.CLASSIFICATION)!=null) {
+ classification = String.valueOf(message.getProperties().getProperty(MessageStore.CLASSIFICATION));
+ }
URI uri = messageStore.addMessage(message, classification);
message.getProperties().setProperty(MessageStore.MESSAGE_STORE_URI, uri);
} catch (MessageStoreException mse) {
- log.error("Could not store undeliverable message.", mse);
+ log.error("Could not store message.", mse);
}
- return null;
+ return message;
}
/* (non-Javadoc)
* @see org.jboss.soa.esb.actions.ActionLifecycle#initialise()
@@ -92,5 +94,20 @@
classification=null;
}
+ public Message getMessages(Message message) throws ActionProcessingException
+ {
+ String classification = this.classification;
+ try {
+ //the message can override the classification
+ if (message.getProperties().getProperty(MessageStore.CLASSIFICATION)!=null) {
+ classification = String.valueOf(message.getProperties().getProperty(MessageStore.CLASSIFICATION));
+ }
+ Map<URI, Message> messageMap = messageStore.getAllMessages(classification);
+ message.getBody().add(messageMap);
+ } catch (MessageStoreException mse) {
+ log.error("Could obtain messages.", mse);
+ }
+ return message;
+ }
}
Added: labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/soa/esb/actions/MessageRedeliverer.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/soa/esb/actions/MessageRedeliverer.java (rev 0)
+++ labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/soa/esb/actions/MessageRedeliverer.java 2007-08-14 04:07:21 UTC (rev 14192)
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ */
+
+/**
+ * Routes the Message argument to a fixed list of services ([category,name])
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
+ * @since Version 4.0
+ */
+package org.jboss.soa.esb.actions;
+
+import java.net.URI;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.persistence.MessageStore;
+import org.jboss.soa.esb.services.persistence.MessageStoreException;
+import org.jboss.soa.esb.services.persistence.RedeliverStore;
+
+public class MessageRedeliverer extends MessagePersister
+{
+ public final static String MESSAGE_STORE_CLASS = "message-store-class";
+ public final static String CLASSIFICATION_ATTR = "classfication";
+
+
+ protected ConfigTree config;
+ protected RedeliverStore redeliverStore;
+ private String classification;
+ private Logger log = Logger.getLogger(this.getClass());
+
+ public MessageRedeliverer(ConfigTree config) throws ConfigurationException
+ {
+ super(config);
+ }
+
+ public void initialise() throws ActionLifecycleException {
+ super.initialise();
+ redeliverStore = (RedeliverStore) messageStore;
+ }
+
+ public Message process(Message message) throws ActionProcessingException
+ {
+ classification = MessageStore.CLASSIFICATION_RDLVR;
+ try {
+ //the message can override the classification
+ if (message.getProperties().getProperty(MessageStore.CLASSIFICATION)!=null) {
+ classification = String.valueOf(message.getProperties().getProperty(MessageStore.CLASSIFICATION));
+ }
+ Map<URI, Message> messageMap = messageStore.getAllMessages(classification);
+ for (URI uid : messageMap.keySet()) {
+ redeliverStore.redeliver(uid);
+ }
+ } catch (MessageStoreException mse) {
+ log.error("Could obtain messages.", mse);
+ }
+ return message;
+ }
+}
Property changes on: labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/soa/esb/actions/MessageRedeliverer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/soa/esb/schedule/RedeliverEventMessageComposer.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/soa/esb/schedule/RedeliverEventMessageComposer.java (rev 0)
+++ labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/soa/esb/schedule/RedeliverEventMessageComposer.java 2007-08-14 04:07:21 UTC (rev 14192)
@@ -0,0 +1,54 @@
+/**
+ *
+ */
+package org.jboss.soa.esb.schedule;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.ScheduledEventMessageComposer;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.schedule.SchedulingException;
+import org.jboss.soa.esb.services.persistence.MessageStore;
+
+/**
+ * @author kstam
+ *
+ */
+public class RedeliverEventMessageComposer implements ScheduledEventMessageComposer
+{
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.listeners.ScheduledEventMessageComposer#composeMessage()
+ */
+ public Message composeMessage() throws SchedulingException
+ {
+ Message message = org.jboss.soa.esb.message.format.MessageFactory.getInstance().getMessage();
+ message.getProperties().setProperty(MessageStore.CLASSIFICATION, MessageStore.CLASSIFICATION_RDLVR);
+ return message;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.listeners.ScheduledEventMessageComposer#initialize(org.jboss.soa.esb.helpers.ConfigTree)
+ */
+ public void initialize(ConfigTree config) throws ConfigurationException {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.listeners.ScheduledEventMessageComposer#onProcessingComplete(org.jboss.soa.esb.message.Message)
+ */
+ public Message onProcessingComplete(Message message) throws SchedulingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.listeners.ScheduledEventMessageComposer#uninitialize()
+ */
+ public void uninitialize() {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on: labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/soa/esb/schedule/RedeliverEventMessageComposer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: labs/jbossesb/trunk/product/services/jbossesb/src/main/resources/META-INF/jboss-esb.xml
===================================================================
--- labs/jbossesb/trunk/product/services/jbossesb/src/main/resources/META-INF/jboss-esb.xml 2007-08-14 03:25:57 UTC (rev 14191)
+++ labs/jbossesb/trunk/product/services/jbossesb/src/main/resources/META-INF/jboss-esb.xml 2007-08-14 04:07:21 UTC (rev 14192)
@@ -13,6 +13,9 @@
/>
</jms-bus>
</jms-provider>
+ <schedule-provider name="schedule">
+ <simple-schedule scheduleid="5-min-trigger" frequency="300" repeatCount="-1"/>
+ </schedule-provider>
</providers>
<services>
@@ -43,5 +46,13 @@
</action>
</actions>
</service>
+ <service category="JBossESB-Internal" name="RedeliverService" description="Scheduled Service to Redeliver Messages">
+ <listeners>
+ <scheduled-listener name="redeliver-scheduled-listener" scheduleidref="5-min-trigger" composer="org.jboss.soa.esb.schedule.RedeliverEventMessageComposer" />
+ </listeners>
+ <actions>
+ <action name="RedeliverMessagesAction" class="org.jboss.soa.esb.actions.MessageRedeliverer" />
+ </actions>
+ </service>
</services>
</jbossesb>
Modified: labs/jbossesb/trunk/product/services/jbossesb/src/main/resources/message-store-sql/mysql/create_database.sql
===================================================================
--- labs/jbossesb/trunk/product/services/jbossesb/src/main/resources/message-store-sql/mysql/create_database.sql 2007-08-14 03:25:57 UTC (rev 14191)
+++ labs/jbossesb/trunk/product/services/jbossesb/src/main/resources/message-store-sql/mysql/create_database.sql 2007-08-14 04:07:21 UTC (rev 14192)
@@ -1,9 +1,4 @@
-CREATE DATABASE jbossesb;
-GRANT ALL PRIVILEGES ON jbossesb.* TO 'jbossesb' IDENTIFIED BY 'jbossesb';
-
-USE jbossesb;
-
CREATE TABLE message
(
uuid varchar(128) NOT NULL,
Added: labs/jbossesb/trunk/product/services/jbossesb/src/main/resources/message-store-sql/mysql/drop_database.sql
===================================================================
--- labs/jbossesb/trunk/product/services/jbossesb/src/main/resources/message-store-sql/mysql/drop_database.sql (rev 0)
+++ labs/jbossesb/trunk/product/services/jbossesb/src/main/resources/message-store-sql/mysql/drop_database.sql 2007-08-14 04:07:21 UTC (rev 14192)
@@ -0,0 +1 @@
+DROP TABLE IF EXISTS message;
Modified: labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/internal/soa/esb/persistence/format/jcr/JCRConnectionManagerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/internal/soa/esb/persistence/format/jcr/JCRConnectionManagerUnitTest.java 2007-08-14 03:25:57 UTC (rev 14191)
+++ labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/internal/soa/esb/persistence/format/jcr/JCRConnectionManagerUnitTest.java 2007-08-14 04:07:21 UTC (rev 14192)
@@ -31,8 +31,6 @@
import javax.naming.InitialContext;
import javax.naming.NamingException;
-import junit.framework.TestCase;
-
import org.apache.jackrabbit.core.TransientRepository;
import org.apache.log4j.Logger;
import org.jboss.soa.esb.common.Environment;
Modified: labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/esb/persistence/tests/MessageStoreUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/esb/persistence/tests/MessageStoreUnitTest.java 2007-08-14 03:25:57 UTC (rev 14191)
+++ labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/esb/persistence/tests/MessageStoreUnitTest.java 2007-08-14 04:07:21 UTC (rev 14192)
@@ -88,7 +88,7 @@
MessageStore store = MessageStoreFactory.getInstance().getMessageStore();
assertEquals((store != null), true);
- URI uid = store.addMessage(msg, MessageStore.DEFAULT_CLASSIFICATION);
+ URI uid = store.addMessage(msg, MessageStore.CLASSIFICATION_DEFAULT);
store.setUndelivered(uid);
}
@@ -104,7 +104,7 @@
MessageStore store = MessageStoreFactory.getInstance().getMessageStore();
assertEquals((store != null), true);
- URI uid = store.addMessage(msg,MessageStore.DEFAULT_CLASSIFICATION);
+ URI uid = store.addMessage(msg,MessageStore.CLASSIFICATION_DEFAULT);
store.setDelivered(uid);
}
@@ -130,17 +130,17 @@
MessageStore store = MessageStoreFactory.getInstance().getMessageStore();
assertEquals((store != null), true);
- URI uid1 = store.addMessage(msg1,MessageStore.DEFAULT_CLASSIFICATION);
- URI uid2 = store.addMessage(msg2,MessageStore.DEFAULT_CLASSIFICATION);
- URI uid3 = store.addMessage(msg3,MessageStore.DEFAULT_CLASSIFICATION);
- URI uid4 = store.addMessage(msg4,MessageStore.DEFAULT_CLASSIFICATION);
+ URI uid1 = store.addMessage(msg1,MessageStore.CLASSIFICATION_DEFAULT);
+ URI uid2 = store.addMessage(msg2,MessageStore.CLASSIFICATION_DEFAULT);
+ URI uid3 = store.addMessage(msg3,MessageStore.CLASSIFICATION_DEFAULT);
+ URI uid4 = store.addMessage(msg4,MessageStore.CLASSIFICATION_DEFAULT);
store.setUndelivered(uid1);
store.setUndelivered(uid2);
store.setUndelivered(uid3);
store.setUndelivered(uid4);
- Map<URI, Message> messages = store.getUndeliveredMessages(MessageStore.DEFAULT_CLASSIFICATION);
+ Map<URI, Message> messages = store.getUndeliveredMessages(MessageStore.CLASSIFICATION_DEFAULT);
assertEquals((messages != null), true);
}
@@ -177,12 +177,12 @@
// keep track of the UID to use in retrieving the Message
URI uid1 = null;
- uid1 = store.addMessage(msg1, MessageStore.DEFAULT_CLASSIFICATION);
+ uid1 = store.addMessage(msg1, MessageStore.CLASSIFICATION_DEFAULT);
// System.out.println(uid1);
assertEquals((uid1 != null), true);
URI uid2 = null;
- uid2 = store.addMessage(msg2,MessageStore.DEFAULT_CLASSIFICATION);
+ uid2 = store.addMessage(msg2,MessageStore.CLASSIFICATION_DEFAULT);
// System.out.println(uid2);
assertEquals((uid2 != null), true);
Added: labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/esb/persistence/tests/RedeliverClient.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/esb/persistence/tests/RedeliverClient.java (rev 0)
+++ labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/esb/persistence/tests/RedeliverClient.java 2007-08-14 04:07:21 UTC (rev 14192)
@@ -0,0 +1,72 @@
+/*
+ * 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,
+ * @author daniel.brum at jboss.com
+ */
+
+package org.jboss.soa.esb.esb.persistence.tests;
+
+import java.net.URI;
+import java.util.Map;
+
+import org.jboss.internal.soa.esb.persistence.format.MessageStoreFactory;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.persistence.MessageStoreException;
+import org.jboss.soa.esb.services.persistence.RedeliverStore;
+
+/**
+ * @author dbrum
+ *
+ */
+public class RedeliverClient implements Runnable
+{
+ private int count=0;
+ private boolean isDone=false;
+
+ public void run ()
+ {
+ try {
+ RedeliverStore store = MessageStoreFactory.getInstance().getRedeliverStore();
+ Map<URI, Message> messages = store.getAllMessages("RDLVR");
+ for (URI uid : messages.keySet()) {
+ if (store.redeliver(uid)) {
+ count++;
+ }
+ }
+ setDone(true);
+ } catch (MessageStoreException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public int getCount() {
+ return count;
+ }
+
+ public void setCount(int count) {
+ this.count = count;
+ }
+
+ public boolean isDone() {
+ return isDone;
+ }
+
+ public void setDone(boolean isDone) {
+ this.isDone = isDone;
+ }
+}
Property changes on: labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/esb/persistence/tests/RedeliverClient.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/esb/persistence/tests/RedeliverUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/esb/persistence/tests/RedeliverUnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/esb/persistence/tests/RedeliverUnitTest.java 2007-08-14 04:07:21 UTC (rev 14192)
@@ -0,0 +1,316 @@
+/*
+ * 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,
+ * @author daniel.brum at jboss.com
+ */
+
+package org.jboss.soa.esb.esb.persistence.tests;
+
+/**
+ * @author kstam
+ *
+ *
+ */
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.File;
+import java.net.URI;
+import java.sql.Connection;
+import java.sql.Statement;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.xml.DOMConfigurator;
+import org.jboss.internal.soa.esb.couriers.MockCourier;
+import org.jboss.internal.soa.esb.couriers.MockCourierFactory;
+import org.jboss.internal.soa.esb.persistence.format.MessageStoreFactory;
+import org.jboss.internal.soa.esb.services.registry.MockRegistry;
+import org.jboss.soa.esb.Service;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.common.Configuration;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.format.MessageType;
+import org.jboss.soa.esb.persistence.manager.ConnectionManager;
+import org.jboss.soa.esb.persistence.manager.ConnectionManagerFactory;
+import org.jboss.soa.esb.services.persistence.MessageStore;
+import org.jboss.soa.esb.services.persistence.MessageStoreException;
+import org.jboss.soa.esb.services.persistence.RedeliverStore;
+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;
+
+public class RedeliverUnitTest
+{
+
+ private static Logger log = Logger.getLogger(RedeliverUnitTest.class);
+
+ /*
+ * Should succesfully deliver the message, and then remove the message from the store.
+ */
+ @Test
+ public void redeliverOne() throws Exception
+ {
+ log.info("** redeliverOne");
+ RedeliverStore store = MessageStoreFactory.getInstance().getRedeliverStore();
+ assertEquals((store != null), true);
+ //first lets create an undeliverable message
+ Service service = new Service("cat", "service");
+ URI uid = createMessages(1, service, store);
+
+ store.redeliver(uid);
+ Message message = store.getMessage(uid);
+ //the message should no longer be in the store.
+ assertNull(message);
+ }
+ /*
+ * Adding a message to the store then, the selecting ALL and deliver it with one redeliver thread.
+ */
+ @Test
+ public void redeliverOneThread() throws Exception
+ {
+ log.info("** redeliverOneThreads");
+ MessageStore store = MessageStoreFactory.getInstance().getMessageStore();
+ assertEquals((store != null), true);
+ //first lets create an undeliverable message
+ Service service = new Service("cat", "service");
+ URI uid = createMessages(1, service, store);
+ RedeliverClient redeliverClient = new RedeliverClient();
+ Thread t1 = new Thread(redeliverClient, "CLIENT-1");
+ t1.start();
+
+ long deadline=System.currentTimeMillis() + 20000;
+ boolean waiting=true;
+ while(waiting) {
+ if (redeliverClient.isDone()) {
+ waiting=false;
+ } else if (System.currentTimeMillis() > deadline){
+ //We're timing out for some reason. This is bad.
+ assertTrue(false);
+ }
+ }
+ assertEquals(redeliverClient.getCount(),1);
+ Message message = store.getMessage(uid);
+ assertNull(message);
+ }
+ /*
+ * Adding a message to the store then, the selecting ALL and deliver it with two redeliver threads.
+ */
+ @Test
+ public void redeliverTwoThreads() throws Exception
+ {
+ log.info("** redeliverTwoThreads");
+ //first lets create an undeliverable message
+ MessageStore store = MessageStoreFactory.getInstance().getMessageStore();
+ assertEquals((store != null), true);
+ //first lets create an undeliverable message
+ Service service = new Service("cat", "service");
+ URI uid = createMessages(1, service, store);
+ RedeliverClient client1 = new RedeliverClient();
+ RedeliverClient client2 = new RedeliverClient();
+ Thread t1 = new Thread(client1, "CLIENT-1");
+ Thread t2 = new Thread(client2, "CLIENT-2");
+ t1.start();
+ t2.start();
+
+ long deadline=System.currentTimeMillis() + 20000;
+ boolean waiting=true;
+ while(waiting) {
+
+ if (client1.isDone() && client2.isDone()) {
+ waiting=false;
+ } else if (System.currentTimeMillis() > deadline){
+ //We're timing out for some reason. This is bad.
+ assertTrue(false);
+ }
+ }
+ log.info("Client1 processed " + client1.getCount() + " messages");
+ log.info("Client2 processed " + client2.getCount() + " messages");
+ //only *one* message should be delivered
+ assertEquals(1, client1.getCount() + client2.getCount());
+ //the message is delivered so should no longer be in the store
+ Message message = store.getMessage(uid);
+ assertNull(message);
+ }
+
+ @Test
+ public void redeliverFiftyTwoThreads() throws Exception
+ {
+ int numberOfMessages=50;
+ log.info("** redeliverFiftyTwoThreads");
+ //first lets create an undeliverable message
+ MessageStore store = MessageStoreFactory.getInstance().getMessageStore();
+ assertEquals((store != null), true);
+ //first lets create an undeliverable message
+ Service service = new Service("cat", "service");
+ URI uid = createMessages(numberOfMessages, service, store);
+ RedeliverClient client1 = new RedeliverClient();
+ RedeliverClient client2 = new RedeliverClient();
+ Thread t1 = new Thread(client1, "CLIENT-1");
+ Thread t2 = new Thread(client2, "CLIENT-2");
+ t1.start();
+ t2.start();
+
+ long deadline=System.currentTimeMillis() + 20000;
+ boolean waiting=true;
+
+ while(waiting) {
+
+ if (client1.isDone() && client2.isDone()) {
+ waiting=false;
+ } else if (System.currentTimeMillis() > deadline){
+ //We're timing out for some reason. This is bad.
+ assertTrue(false);
+ }
+ }
+ log.info("Client1 processed " + client1.getCount() + " messages");
+ log.info("Client2 processed " + client2.getCount() + " messages");
+ assertEquals(numberOfMessages, client1.getCount() + client2.getCount());
+ //make sure the last message was send (and removed from the store)
+ Message message = store.getMessage(uid);
+ assertNull(message);
+ }
+ /*
+ * Deliver to undeliverable Service
+ */
+ @Test
+ public void redeliverOneUnreachable() throws Exception
+ {
+ log.info("** redeliverOneUnreachable");
+ RedeliverStore store = MessageStoreFactory.getInstance().getRedeliverStore();
+ assertEquals((store != null), true);
+ //first lets create an undeliverable message
+ Service service = new Service("cat", "unreachable_service");
+ URI uid = createMessages(1, service, store);
+
+ int maxRedeliveryCount = store.getMaxRedeliverCount();
+ for (int i=0; i<maxRedeliveryCount; i++) {
+ store.redeliver(uid);
+ Message message = store.getMessage(uid);
+ //the message should have a redeliveryCount of i+1
+ assertNotNull(message);
+ Integer deliverCount = (Integer) message.getProperties().getProperty(RedeliverStore.DELIVER_COUNT);
+ assertEquals(deliverCount, i+1);
+ }
+ //Now redelivering one more time should put it in the DLQ
+ store.redeliver(uid);
+ Message message = store.getMessage(uid, MessageStore.CLASSIFICATION_DLQ);
+ assertNotNull(message);
+ message = store.getMessage(uid, MessageStore.CLASSIFICATION_RDLVR);
+ assertNull(message);
+ }
+
+
+ private URI createMessages(int numberOfMessages, Service service, MessageStore store) throws MessageStoreException
+ {
+ URI uid=null;
+ for (int i=0; i<numberOfMessages; i++) {
+ Message msg = MessageFactory.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
+ assertEquals((msg != null), true);
+ msg.getProperties().setProperty(ServiceInvoker.DELIVER_TO, service);
+ uid = store.addMessage(msg, MessageStore.CLASSIFICATION_RDLVR);
+ }
+ return uid;
+ }
+
+ @BeforeClass
+ public static void runBeforeAllTests()
+ {
+ MockCourierFactory.install();
+ MockRegistry.install();
+ MockCourier courier1 = new MockCourier(true);
+ MockRegistry.register("cat", "service", courier1);
+ MockCourier courier2 = new MockCourier(false);
+ MockRegistry.register("cat", "unreachable_service", courier2);
+
+ try {
+ File testResourceDir = TestEnvironmentUtil.findResourceDirectory("./product/services/jbossesb/src/test/resources/");
+ System.out.println("Current dir=" + testResourceDir.getCanonicalPath());
+ DOMConfigurator.configure(testResourceDir.getCanonicalPath() + "/log4j.xml");
+ File buildDir = TestEnvironmentUtil.findResourceDirectory("./product/services/jbossesb/build/");
+ File resourceDir = TestEnvironmentUtil.findResourceDirectory("./product/services/jbossesb/src/main/resources/");
+ System.setProperty("org.jboss.soa.esb.propertyFile", "jbossesb-unittest-properties.xml");
+ if ("org.hsqldb.jdbcDriver".equals(Configuration.getStoreDriver())) {
+ HsqldbUtil.startHsqldb(buildDir + "/hsqltestdb", "jbossesb");
+
+ //Drop what is there now, if exists. We want to start fresh.
+ String sqlCreateCmd = TestEnvironmentUtil.readTextFile(new File(resourceDir.getCanonicalPath() + "/message-store-sql/hsqldb/create_database.sql"));
+ String sqlDropCmd = TestEnvironmentUtil.readTextFile(new File(resourceDir.getAbsolutePath() + "/message-store-sql/hsqldb/drop_database.sql"));
+
+ ConnectionManager mgr = ConnectionManagerFactory.getConnectionManager();
+ mgr.init();
+ Connection con = mgr.getConnection();
+ Statement stmnt = con.createStatement();
+ System.out.println("Dropping the schema if exist");
+ stmnt.execute(sqlDropCmd);
+ System.out.println("Creating the message store schema");
+ stmnt.execute(sqlCreateCmd);
+ } else if ("com.mysql.jdbc.Driver".equals(Configuration.getStoreDriver())) {
+
+ String sqlCreateCmd = TestEnvironmentUtil.readTextFile(new File(resourceDir.getCanonicalPath() + "/message-store-sql/mysql/create_database.sql"));
+ String sqlDropCmd = TestEnvironmentUtil.readTextFile(new File(resourceDir.getCanonicalPath() + "/message-store-sql/mysql/drop_database.sql"));
+
+ ConnectionManager mgr = ConnectionManagerFactory.getConnectionManager();
+ mgr.init();
+ Connection con = mgr.getConnection();
+ Statement stmnt = con.createStatement();
+ System.out.println("Dropping the schema if exist");
+ stmnt.execute(sqlDropCmd);
+ System.out.println("Creating the message store schema");
+ stmnt.execute(sqlCreateCmd);
+
+ }
+ } catch (Throwable e) {
+ e.printStackTrace();
+ System.out.println("We should stop testing, since we don't have a db.");
+ assertTrue(false);
+ }
+
+ }
+ @AfterClass
+ public static void runAfterAllTests ()
+ {
+
+ try
+ {
+ if (Configuration.getStoreDriver().equals("org.hsqldb.jdbcDriver"))
+ HsqldbUtil.stopHsqldb(Configuration.getStoreUrl(),
+ Configuration.getStoreUser(), Configuration
+ .getStorePwd());
+ }
+ catch (Exception e)
+ { //
+ log.error( e );
+ }
+
+ MockRegistry.uninstall();
+ MockCourierFactory.uninstall();
+ }
+
+ public static junit.framework.Test suite ()
+ {
+ return new JUnit4TestAdapter(RedeliverUnitTest.class);
+ }
+
+}
Property changes on: labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/esb/persistence/tests/RedeliverUnitTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/esb/persistence/tests/ScheduledRedeliveryUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/esb/persistence/tests/ScheduledRedeliveryUnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/esb/persistence/tests/ScheduledRedeliveryUnitTest.java 2007-08-14 04:07:21 UTC (rev 14192)
@@ -0,0 +1,198 @@
+/*
+ * 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.esb.persistence.tests;
+
+import java.io.File;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.sql.Connection;
+import java.sql.Statement;
+import java.util.Map;
+
+import junit.framework.JUnit4TestAdapter;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.log4j.xml.DOMConfigurator;
+import org.jboss.internal.soa.esb.couriers.MockCourier;
+import org.jboss.internal.soa.esb.couriers.MockCourierFactory;
+import org.jboss.internal.soa.esb.persistence.format.MessageStoreFactory;
+import org.jboss.internal.soa.esb.services.registry.MockRegistry;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.Service;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.common.Configuration;
+import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.message.format.MessageType;
+import org.jboss.soa.esb.parameters.ParamRepositoryException;
+import org.jboss.soa.esb.persistence.manager.ConnectionManager;
+import org.jboss.soa.esb.persistence.manager.ConnectionManagerFactory;
+import org.jboss.soa.esb.services.persistence.MessageStore;
+import org.jboss.soa.esb.services.persistence.MessageStoreException;
+import org.jboss.soa.esb.services.persistence.RedeliverStore;
+import org.jboss.soa.esb.testutils.ESBConfigUtil;
+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;
+import org.xml.sax.SAXException;
+
+/**
+ * Scheduled Redelivery unit test.
+ *
+ * @author <a href="mailto:kurt.stam at jboss.com">kurt.stam at jboss.com</a>
+ */
+public class ScheduledRedeliveryUnitTest{
+
+ @Test
+ public void test_listener_config() throws UnsupportedEncodingException {
+ ESBConfigUtil configUtil = new ESBConfigUtil(getClass().getResourceAsStream("config-01.xml"));
+ String config = configUtil.getListenerConfig("simple-schedule-listener").toString();
+ assertNotNull(config);
+ }
+
+ @Test
+ public void test_simple_schedule_01() {
+
+ try {
+ int numberOfMessages=200;
+ MessageStore store = MessageStoreFactory.getInstance().getMessageStore();
+ assertEquals((store != null), true);
+ //first lets create an undeliverable message
+ Service service = new Service("cat", "service");
+ URI uid = createMessages(numberOfMessages, service, store);
+ Map<URI, Message> messageMap = store.getAllMessages(RedeliverStore.CLASSIFICATION_RDLVR);
+ assertEquals(messageMap.size(), numberOfMessages);
+ runTestConfig("config-01.xml", 5000);
+ Message message2 = store.getMessage(uid);
+ assertNull(message2);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+
+
+ }
+
+ private void runTestConfig(String configName, long upTime) throws ParamRepositoryException, ConfigurationException, ManagedLifecycleException, SAXException, InterruptedException {
+ ESBConfigUtil configUtil = new ESBConfigUtil(getClass().getResourceAsStream(configName));
+
+ configUtil.startController();
+ Thread.sleep(upTime);
+ configUtil.stopController();
+ }
+
+ private URI createMessages(int numberOfMessages, Service service, MessageStore store) throws MessageStoreException
+ {
+ URI uid=null;
+ for (int i=0; i<numberOfMessages; i++) {
+ Message msg = MessageFactory.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
+ assertEquals((msg != null), true);
+ msg.getProperties().setProperty(ServiceInvoker.DELIVER_TO, service);
+ uid = store.addMessage(msg, MessageStore.CLASSIFICATION_RDLVR);
+ }
+ return uid;
+ }
+
+ @BeforeClass
+ public static void runBeforeAllTests()
+ {
+ MockCourierFactory.install();
+ MockRegistry.install();
+ MockCourier courier1 = new MockCourier(true);
+ MockRegistry.register("cat", "service", courier1);
+
+ try {
+ File testResourceDir = TestEnvironmentUtil.findResourceDirectory("./product/services/jbossesb/src/test/resources/");
+ System.out.println("Current dir=" + testResourceDir.getCanonicalPath());
+ DOMConfigurator.configure(testResourceDir.getCanonicalPath() + "/log4j.xml");
+ File buildDir = TestEnvironmentUtil.findResourceDirectory("./product/services/jbossesb/build/");
+ File resourceDir = TestEnvironmentUtil.findResourceDirectory("./product/services/jbossesb/src/main/resources/");
+ System.setProperty("org.jboss.soa.esb.propertyFile", "jbossesb-unittest-properties.xml");
+ if ("org.hsqldb.jdbcDriver".equals(Configuration.getStoreDriver())) {
+ HsqldbUtil.startHsqldb(buildDir + "/hsqltestdb", "jbossesb");
+
+ //Drop what is there now, if exists. We want to start fresh.
+ String sqlCreateCmd = TestEnvironmentUtil.readTextFile(new File(resourceDir.getCanonicalPath() + "/message-store-sql/hsqldb/create_database.sql"));
+ String sqlDropCmd = TestEnvironmentUtil.readTextFile(new File(resourceDir.getAbsolutePath() + "/message-store-sql/hsqldb/drop_database.sql"));
+
+ ConnectionManager mgr = ConnectionManagerFactory.getConnectionManager();
+ mgr.init();
+ Connection con = mgr.getConnection();
+ Statement stmnt = con.createStatement();
+ System.out.println("Dropping the schema if exist");
+ stmnt.execute(sqlDropCmd);
+ System.out.println("Creating the message store schema");
+ stmnt.execute(sqlCreateCmd);
+ } else if ("com.mysql.jdbc.Driver".equals(Configuration.getStoreDriver())) {
+
+ String sqlCreateCmd = TestEnvironmentUtil.readTextFile(new File(resourceDir.getCanonicalPath() + "/message-store-sql/mysql/create_database.sql"));
+ String sqlDropCmd = TestEnvironmentUtil.readTextFile(new File(resourceDir.getCanonicalPath() + "/message-store-sql/mysql/drop_database.sql"));
+
+ ConnectionManager mgr = ConnectionManagerFactory.getConnectionManager();
+ mgr.init();
+ Connection con = mgr.getConnection();
+ Statement stmnt = con.createStatement();
+ System.out.println("Dropping the schema if exist");
+ stmnt.execute(sqlDropCmd);
+ System.out.println("Creating the message store schema");
+ stmnt.execute(sqlCreateCmd);
+
+ }
+ } catch (Throwable e) {
+ e.printStackTrace();
+ System.out.println("We should stop testing, since we don't have a db.");
+ assertTrue(false);
+ }
+
+ }
+
+ @AfterClass
+ public static void runAfterAllTests ()
+ {
+
+ try
+ {
+ if (Configuration.getStoreDriver().equals("org.hsqldb.jdbcDriver"))
+ HsqldbUtil.stopHsqldb(Configuration.getStoreUrl(),
+ Configuration.getStoreUser(), Configuration
+ .getStorePwd());
+ }
+ catch (Exception e)
+ { //
+ e.printStackTrace();
+ }
+
+ MockRegistry.uninstall();
+ MockCourierFactory.uninstall();
+ }
+
+ public static junit.framework.Test suite ()
+ {
+ return new JUnit4TestAdapter(ScheduledRedeliveryUnitTest.class);
+ }
+}
Property changes on: labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/esb/persistence/tests/ScheduledRedeliveryUnitTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/esb/persistence/tests/config-01.xml
===================================================================
--- labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/esb/persistence/tests/config-01.xml (rev 0)
+++ labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/esb/persistence/tests/config-01.xml 2007-08-14 04:07:21 UTC (rev 14192)
@@ -0,0 +1,21 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd">
+
+ <providers>
+ <schedule-provider name="schedule">
+ <simple-schedule scheduleid="1-sec-trigger" frequency="1" repeatCount="2"/>
+ </schedule-provider>
+ </providers>
+
+ <services>
+ <service category="ServiceCat" name="ServiceName" description="Test Service">
+ <listeners>
+ <scheduled-listener name="simple-schedule-listener" scheduleidref="1-sec-trigger" composer="org.jboss.soa.esb.schedule.RedeliverEventMessageComposer" />
+ </listeners>
+ <actions>
+ <action name="RedeliverMessagesAction" class="org.jboss.soa.esb.actions.MessageRedeliverer" />
+ </actions>
+ </service>
+ </services>
+
+</jbossesb>
\ No newline at end of file
Property changes on: labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/esb/persistence/tests/config-01.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Modified: labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/messagestore/MessageStoreClient.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/messagestore/MessageStoreClient.java 2007-08-14 03:25:57 UTC (rev 14191)
+++ labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/messagestore/MessageStoreClient.java 2007-08-14 04:07:21 UTC (rev 14192)
@@ -71,7 +71,7 @@
{
try
{
- URI uid = store.addMessage(msg[rndMsg.nextInt(2)], MessageStore.DEFAULT_CLASSIFICATION);
+ URI uid = store.addMessage(msg[rndMsg.nextInt(2)], MessageStore.CLASSIFICATION_DEFAULT);
if (uid != null) writeList.add(uid);
else
System.err
Modified: labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/messagestore/MessageStoreTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/messagestore/MessageStoreTest.java 2007-08-14 03:25:57 UTC (rev 14191)
+++ labs/jbossesb/trunk/product/services/jbossesb/src/test/java/org/jboss/soa/esb/messagestore/MessageStoreTest.java 2007-08-14 04:07:21 UTC (rev 14192)
@@ -92,7 +92,7 @@
//loop through adding the messages
Random rndMsg = new Random();
for (int x=0; x<=requestors; x++) {
- URI uid = store.addMessage(msg[rndMsg.nextInt(2)], MessageStore.DEFAULT_CLASSIFICATION);
+ URI uid = store.addMessage(msg[rndMsg.nextInt(2)], MessageStore.CLASSIFICATION_DEFAULT);
if (uid == null)
System.out.println("null returned from addMessage() call to uid");
else
Modified: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPClient.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPClient.java 2007-08-14 03:25:57 UTC (rev 14191)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPClient.java 2007-08-14 04:07:21 UTC (rev 14192)
@@ -15,6 +15,7 @@
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.log4j.Logger;
import org.jboss.internal.soa.esb.soap.OGNLUtils;
import org.jboss.internal.soa.esb.util.StreamUtils;
@@ -352,7 +353,7 @@
post.setRequestHeader("Content-Type", "text/xml;charset=UTF-8");
post.setRequestHeader("SOAPAction", soapAction);
- post.setRequestBody(request);
+ post.setRequestEntity(new StringRequestEntity(request));
try {
int result = httpclient.executeMethod(post);
if(result != HttpStatus.SC_OK) {
More information about the jboss-svn-commits
mailing list