[jboss-svn-commits] JBL Code SVN: r14424 - in labs/jbossesb/trunk/product: rosetta/src/org/jboss/soa/esb/client and 5 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Aug 21 15:07:26 EDT 2007


Author: kurt.stam at jboss.com
Date: 2007-08-21 15:07:26 -0400 (Tue, 21 Aug 2007)
New Revision: 14424

Added:
   labs/jbossesb/trunk/product/samples/quickstarts/deadletter/src/org/jboss/soa/esb/samples/quickstart/deadletter/MyFailingAsyncAction.java
   labs/jbossesb/trunk/product/samples/quickstarts/deadletter/src/org/jboss/soa/esb/samples/quickstart/deadletter/MyFailingSyncAction.java
Removed:
   labs/jbossesb/trunk/product/samples/quickstarts/deadletter/src/org/jboss/soa/esb/samples/quickstart/deadletter/CheckMessageStoreAction.java
   labs/jbossesb/trunk/product/samples/quickstarts/deadletter/src/org/jboss/soa/esb/samples/quickstart/deadletter/MyFailingAction.java
Modified:
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/RegistryService.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java
   labs/jbossesb/trunk/product/samples/quickstarts/deadletter/build.xml
   labs/jbossesb/trunk/product/samples/quickstarts/deadletter/jboss-esb.xml
   labs/jbossesb/trunk/product/samples/quickstarts/deadletter/readme.txt
   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/soa/esb/actions/MessagePersister.java
   labs/jbossesb/trunk/product/services/jbossesb/src/main/resources/META-INF/jboss-esb.xml
Log:
JBESB-705, updating to show the use of the DLQ/RDLVR

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/RegistryService.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/RegistryService.java	2007-08-21 16:22:21 UTC (rev 14423)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/RegistryService.java	2007-08-21 19:07:26 UTC (rev 14424)
@@ -29,6 +29,7 @@
 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.registry.ServiceNotFoundException;
 import org.jboss.system.ServiceMBeanSupport;
 
 /**
@@ -42,7 +43,7 @@
 public class RegistryService extends ServiceMBeanSupport implements RegistryServiceMBean
 {
    @Override
-   protected void createService() throws RegistryException
+   protected void createService() throws RegistryException, ServiceNotFoundException
    {
       final Registry registry = RegistryFactory.createRegistry();
       Class[] intfs = {Registry.class};
@@ -59,7 +60,7 @@
               try {
                  return method.invoke(registry, args);
               } catch (InvocationTargetException ite) {
-                     throw new RegistryException(ite.getMessage(), ite.getCause());
+                    throw ite.getCause();
               } catch (Exception e) {
                   throw new RegistryException(e.getMessage(), e);
               } finally {

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-21 16:22:21 UTC (rev 14423)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java	2007-08-21 19:07:26 UTC (rev 14424)
@@ -184,7 +184,7 @@
         try {
             post(message, false);
         } catch (MessageDeliverException mde) {
-            if (message.getProperties().getProperty(IS_REDELIVERY)!=null
+            if (message.getProperties().getProperty(IS_REDELIVERY)==null
                     && "true".equalsIgnoreCase(Configuration.getRedeliveryDlsOn())
                     && !service.equals(dlqService)) {
                 message.getProperties().setProperty(MessageStore.CLASSIFICATION, MessageStore.CLASSIFICATION_RDLVR);

Modified: labs/jbossesb/trunk/product/samples/quickstarts/deadletter/build.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/deadletter/build.xml	2007-08-21 16:22:21 UTC (rev 14423)
+++ labs/jbossesb/trunk/product/samples/quickstarts/deadletter/build.xml	2007-08-21 19:07:26 UTC (rev 14424)
@@ -12,9 +12,10 @@
 		description="sends a JMS message to queue/quickstart_deadletter_Request_gw">
 		<echo>Runs Test JMS Sender</echo>
 		<java fork="yes" classname="org.jboss.soa.esb.samples.quickstart.deadletter.test.SendJMSMessage" failonerror="true">
-			<arg value="Hello Dead Message "/>
+			<arg value="Hello Test Message "/>
 			<classpath refid="exec-classpath"/>
 		</java>
+		<echo>Check output on the ESB console</echo>
 	</target>  
 	
 	<target name="sendesb" depends="compile"
@@ -26,6 +27,7 @@
 			<arg value="Hello Failing Message"/> <!--  Message text -->
 			<classpath refid="exec-classpath"/>
 		</java>
+		<echo>Check output on the ESB console</echo>
 	</target>
 	
 </project>

Modified: labs/jbossesb/trunk/product/samples/quickstarts/deadletter/jboss-esb.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/deadletter/jboss-esb.xml	2007-08-21 16:22:21 UTC (rev 14423)
+++ labs/jbossesb/trunk/product/samples/quickstarts/deadletter/jboss-esb.xml	2007-08-21 19:07:26 UTC (rev 14424)
@@ -49,13 +49,8 @@
 	    		   </property>
    	   			</action>
                 <!-- Send message to My Action -->
-                <action name="MyFailingAction"  class="org.jboss.soa.esb.samples.quickstart.deadletter.MyFailingAction">
-               		<property name="destinations">
-   	 				   <route-to service-category="JBossESB-Internal" service-name="DeadLetterService" />
-	    		   </property>
-   	   			</action>    
-              	<!-- Check that the message is really there -->
-              	<action name="CheckForDeadLettersInMessageStore" class="org.jboss.soa.esb.samples.quickstart.deadletter.CheckMessageStoreAction" />
+                <action name="MyFailingAction"  class="org.jboss.soa.esb.samples.quickstart.deadletter.MyFailingAsyncAction"/>
+                <action name="MyFailingSyncAction"  class="org.jboss.soa.esb.samples.quickstart.deadletter.MyFailingSyncAction"/>
             </actions>
         </service>
       </services>

Modified: labs/jbossesb/trunk/product/samples/quickstarts/deadletter/readme.txt
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/deadletter/readme.txt	2007-08-21 16:22:21 UTC (rev 14423)
+++ labs/jbossesb/trunk/product/samples/quickstarts/deadletter/readme.txt	2007-08-21 19:07:26 UTC (rev 14424)
@@ -1,7 +1,7 @@
 Overview:
 =========
-  The purpose of the messagestore quickstart sample is to show how to send
-  a message in the DeadLetter Service. The interesting piece of configuration
+  The purpose of the messagestore quickstart sample is to show how messages end up in
+  the DeadLetter Service. The interesting piece of configuration
   is:
 
   <!-- Add a copy of the message to the message store under categorization
@@ -23,6 +23,9 @@
 
 To Run standalone mode:
 =======================
+  0. This quickstart can only run if you add the content from the jbossesb.xml from the jbossesb.esb
+     to the current jbossesb.xml, and add the jbossesb.esb jars to the class path. It is recommended
+     to run in '.esb' mode.
   1. In a command terminal window in the quickstart folder type
      'ant deploy-jms-dests'.
   2. In a command terminal window in this folder ("Window1"), type 'ant run'.
@@ -43,10 +46,26 @@
 What to look at in this Quickstart:
 ===================================
 
-  src\quickstart\CheckMessageStoreAction.java:
-    The action class that is identified in the esb-config.xml file and is called
-    whenever a message is received.  
-
+  There are two actions. 
+  
+  src\org\jboss\soa\esb\samples\quickstart\deadletter\MyFailingSyncAction
+    This action attempts a asynchronous call. The attempt should
+    fail and the message should end up getting send to the DeadLetterService. By default
+    this service store a copy of the message in the MessageStore under the classification
+    'RDLVR'. The message would have been redelivered at a later time (according to 
+    the redeliver schedule defined in the jbossesb.esb/META-INF/jboss-esb.xml), but
+    it is removed from the store or else the quickstart would get too confusing.
+    Look for
+    	Message in the RDLVR should be the same message: true
+  
+  src\org\jboss\soa\esb\samples\quickstart\deadletter\MyFailingAsyncAction
+    This action attempts a synchronous call. The attempt should
+    fail and the message should end up getting send to the DeadLetterService. By default
+    this service store a copy of the message in the MessageStore under the classification
+    'DLQ'. An exception is thrown to stop any futher processing of the pipeline.
+    Look for:
+    	Message in the DLQ should be the same message: true
+  
   src\quickstart\helloworld\test\SendJMSMessage.java:
     Shoots in the string passed in via the command line or in this case the arg
     attribute in the ant runtest task.

Deleted: labs/jbossesb/trunk/product/samples/quickstarts/deadletter/src/org/jboss/soa/esb/samples/quickstart/deadletter/CheckMessageStoreAction.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/deadletter/src/org/jboss/soa/esb/samples/quickstart/deadletter/CheckMessageStoreAction.java	2007-08-21 16:22:21 UTC (rev 14423)
+++ labs/jbossesb/trunk/product/samples/quickstarts/deadletter/src/org/jboss/soa/esb/samples/quickstart/deadletter/CheckMessageStoreAction.java	2007-08-21 19:07:26 UTC (rev 14424)
@@ -1,81 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated 
- * by the @authors tag. All rights reserved. 
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors. 
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A 
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
- * MA  02110-1301, USA.
- * 
- * (C) 2005-2006,
- * @author JBoss Inc.
- */
-package org.jboss.soa.esb.samples.quickstart.deadletter;
-
-import java.net.URI;
-import java.util.Map;
-
-import org.jboss.internal.soa.esb.persistence.format.MessageStoreFactory;
-import org.jboss.soa.esb.actions.AbstractActionPipelineProcessor;
-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;
-
-public class CheckMessageStoreAction extends AbstractActionPipelineProcessor {
-
-    protected ConfigTree _config;
-
-    public CheckMessageStoreAction(ConfigTree config) {
-        _config = config;
-    }
-    /**
-     * Check if the message is in the message store. The Unique Identifyer is set on the message property 
-     * with name MessageStore.MESSAGE_STORE_URI. 
-     * 
-     * @param originalMessage
-     * @return
-     * @throws Exception
-     */
-    public Message process(Message message)
-    {
-        return message ;
-    }
-    
-    /**
-     * Process a successful pipeline process. 
-     * Invoked when the pipeline processing completes successfully.
-     * 
-     * @param message The original message.
-     */
-    public void processSuccess(final Message message)
-    {
-        //I can call the messagestore API directory if it is deployed in the same JVM
-        String messageStoreClass = "org.jboss.internal.soa.esb.persistence.format.db.DBMessageStoreImpl";
-        MessageStore messageStore = MessageStoreFactory.getInstance().getMessageStore(messageStoreClass);
-//      Get all the messages in the DLQ
-        System.out.println("Show all messages in the messageStore with category DLQ");
-        try
-        {
-            Map<URI,Message> messageMap = messageStore.getAllMessages("DLQ");
-            for (Message dlqMmessage : messageMap.values()) {
-                System.out.println("***********");
-                System.out.println(new String(dlqMmessage.getBody().getByteArray()));
-            }
-        }
-        catch (final MessageStoreException mse)
-        {
-            System.out.println("***********");
-            System.out.println("Error from message store: " + mse.getMessage()) ;
-        }
-    }
-
-}
\ No newline at end of file

Deleted: labs/jbossesb/trunk/product/samples/quickstarts/deadletter/src/org/jboss/soa/esb/samples/quickstart/deadletter/MyFailingAction.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/deadletter/src/org/jboss/soa/esb/samples/quickstart/deadletter/MyFailingAction.java	2007-08-21 16:22:21 UTC (rev 14423)
+++ labs/jbossesb/trunk/product/samples/quickstarts/deadletter/src/org/jboss/soa/esb/samples/quickstart/deadletter/MyFailingAction.java	2007-08-21 19:07:26 UTC (rev 14424)
@@ -1,61 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated 
- * by the @authors tag. All rights reserved. 
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors. 
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A 
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
- * MA  02110-1301, USA.
- * 
- * (C) 2005-2006,
- * @author JBoss Inc.
- */
-package org.jboss.soa.esb.samples.quickstart.deadletter;
-
-import org.jboss.soa.esb.actions.AbstractActionLifecycle;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.services.routing.MessageRouter;
-
-public class MyFailingAction extends AbstractActionLifecycle {
-
-    protected ConfigTree _config;
-
-    public MyFailingAction(ConfigTree config) {
-        _config = config;
-    }
-    /**
-     * Check if the message is in the message store. The Unique Identifyer is set on the message property 
-     * with name MessageStore.MESSAGE_STORE_URI. 
-     * 
-     * @param originalMessage
-     * @return
-     * @throws Exception
-     */
-    public Message process(Message message) throws Exception 
-    {
-        //Suppose I'm supposed to deliver my message in this action
-        //and the service is not accessable. I can decide to send my
-        //message to the DeadLetter Service. 
-        //
-        //The DeadLetter Service is custom configuble. It is defined in 
-        //the jbossesb.esb an by default it stores the message in the
-        //MessageStore under the DLQ categorization.
-        
-        MessageRouter.deliverMessage(MessageRouter.INTERNAL_SERVICE_CATEGORY
-                , MessageRouter.DEAD_LETTER_SERVICE_NAME
-                , message);
-        
-        return message;
-
-    }
-
-}
\ No newline at end of file

Added: labs/jbossesb/trunk/product/samples/quickstarts/deadletter/src/org/jboss/soa/esb/samples/quickstart/deadletter/MyFailingAsyncAction.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/deadletter/src/org/jboss/soa/esb/samples/quickstart/deadletter/MyFailingAsyncAction.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/deadletter/src/org/jboss/soa/esb/samples/quickstart/deadletter/MyFailingAsyncAction.java	2007-08-21 19:07:26 UTC (rev 14424)
@@ -0,0 +1,108 @@
+/*
+ * 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 JBoss Inc.
+ */
+package org.jboss.soa.esb.samples.quickstart.deadletter;
+
+import java.net.URI;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.persistence.format.MessageStoreFactory;
+import org.jboss.soa.esb.Service;
+import org.jboss.soa.esb.actions.AbstractActionLifecycle;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.persistence.MessageStore;
+import org.jboss.soa.esb.services.persistence.MessageStoreException;
+/**
+ * 
+ * @author kstam
+ *
+ */
+public class MyFailingAsyncAction extends AbstractActionLifecycle {
+
+    protected ConfigTree _config;
+    private Logger logger = Logger.getLogger(this.getClass());
+
+    public MyFailingAsyncAction(ConfigTree config) {
+        _config = config;
+    }
+    /**
+     * Check if the message is in the message store. The Unique Identifyer is set on the message property 
+     * with name MessageStore.MESSAGE_STORE_URI. 
+     * 
+     * @param originalMessage
+     * @return
+     * @throws Exception
+     */
+    public Message process(Message message) throws ActionProcessingException
+    {
+        //The DeadLetterService is custom configurable Service. It is defined in 
+        //the jbossesb.esb an by default it stores the message in the
+        //MessageStore under the DLQ categorization.
+        MessageStore ms = MessageStoreFactory.getInstance().getMessageStore();
+        
+        try {
+            //empty out the DLQ
+            Map<URI, Message> messageMap = ms.getAllMessages(MessageStore.CLASSIFICATION_RDLVR);
+            for (URI key : messageMap.keySet()) {
+                ms.removeMessage(key, MessageStore.CLASSIFICATION_RDLVR);
+            }
+            Service noneExistingService = new Service("none-exising-category", "none-existing-service-name");
+            ServiceInvoker si = new ServiceInvoker(noneExistingService);
+            si.deliverAsync(message);
+           
+            //Adding this control code to show where the message now is.
+            Map<URI, Message> rdlvrMessageMap = ms.getAllMessages(MessageStore.CLASSIFICATION_RDLVR);
+            rdlvrMessageMap = ms.getAllMessages(MessageStore.CLASSIFICATION_RDLVR);
+            while (rdlvrMessageMap.size() == 0) { //we may have to wait for the DLQService to act.
+                rdlvrMessageMap = ms.getAllMessages(MessageStore.CLASSIFICATION_RDLVR);
+                for (URI key : rdlvrMessageMap.keySet()) {
+                    Message rdlvrMessage = rdlvrMessageMap.get(key);
+                    logger.info("*******************************");
+                    logger.info("Message in the RDLVR should be the same message: " + message.getBody().toString().equals(rdlvrMessage.getBody().toString()));
+                    logger.info("Message=" + message.getBody());
+                    logger.info("rdlvrMessage=" + rdlvrMessage.getBody());
+                    logger.info("*******************************");
+                    logger.info("Removing message to avoid future redeliveries");
+                    ms.removeMessage(key, MessageStore.CLASSIFICATION_RDLVR);
+                }
+                if (rdlvrMessageMap.size() == 0) {
+                    logger.info("...Waiting for the DLQ Service to act.");
+                    try {
+                        Thread.sleep(100);
+                    } catch (InterruptedException ie) {
+                        logger.error(ie);
+                    }
+                }
+            }
+        } catch (MessageStoreException mse) {
+            throw new ActionProcessingException(mse.getMessage(), mse);
+        } catch (MessageDeliverException mde) {
+            throw new ActionProcessingException(mde.getMessage(), mde);
+        }
+        return message;
+
+    }
+
+}
\ No newline at end of file


Property changes on: labs/jbossesb/trunk/product/samples/quickstarts/deadletter/src/org/jboss/soa/esb/samples/quickstart/deadletter/MyFailingAsyncAction.java
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: labs/jbossesb/trunk/product/samples/quickstarts/deadletter/src/org/jboss/soa/esb/samples/quickstart/deadletter/MyFailingSyncAction.java (from rev 14349, labs/jbossesb/trunk/product/samples/quickstarts/deadletter/src/org/jboss/soa/esb/samples/quickstart/deadletter/MyFailingAction.java)
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/deadletter/src/org/jboss/soa/esb/samples/quickstart/deadletter/MyFailingSyncAction.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/deadletter/src/org/jboss/soa/esb/samples/quickstart/deadletter/MyFailingSyncAction.java	2007-08-21 19:07:26 UTC (rev 14424)
@@ -0,0 +1,115 @@
+/*
+ * 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 JBoss Inc.
+ */
+package org.jboss.soa.esb.samples.quickstart.deadletter;
+
+import java.net.URI;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.persistence.format.MessageStoreFactory;
+import org.jboss.soa.esb.Service;
+import org.jboss.soa.esb.actions.AbstractActionLifecycle;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.couriers.FaultMessageException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+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;
+/**
+ * 
+ * @author kstam
+ *
+ */
+public class MyFailingSyncAction extends AbstractActionLifecycle {
+
+    protected ConfigTree _config;
+    private Logger logger = Logger.getLogger(this.getClass());
+
+    public MyFailingSyncAction(ConfigTree config) {
+        _config = config;
+    }
+    /**
+     * Check if the message is in the message store. The Unique Identifyer is set on the message property 
+     * with name MessageStore.MESSAGE_STORE_URI. 
+     * 
+     * @param originalMessage
+     * @return
+     * @throws Exception
+     */
+    public Message process(Message message) throws ActionProcessingException
+    {
+        //The DeadLetterService is custom configurable Service. It is defined in 
+        //the jbossesb.esb an by default it stores the message in the
+        //MessageStore under the DLQ categorization.
+        MessageStore ms = MessageStoreFactory.getInstance().getMessageStore();
+        
+        try {
+            //empty out the DLQ
+            Map<URI, Message> messageMap = ms.getAllMessages(MessageStore.CLASSIFICATION_DLQ);
+            for (URI key : messageMap.keySet()) {
+                ms.removeMessage(key, MessageStore.CLASSIFICATION_DLQ);
+            }
+            Service noneExistingService = new Service("none-exising-category", "none-existing-service-name");
+            ServiceInvoker si = new ServiceInvoker(noneExistingService);
+            si.deliverSync(message, 1000);
+        } catch (MessageStoreException mse) {
+            throw new ActionProcessingException(mse.getMessage(), mse);
+        } catch (MessageDeliverException mde) {
+            //Adding this control code to show where the message now is.
+            //We should get here on and we should have a message in the DLQ.
+            try {
+                Map<URI, Message> messageMap = ms.getAllMessages(MessageStore.CLASSIFICATION_DLQ);
+                while (messageMap.size() == 0) { //we may have to wait for the DLQ Service to act.
+                    messageMap = ms.getAllMessages(MessageStore.CLASSIFICATION_DLQ);
+                    for (URI key : messageMap.keySet()) {
+                        Message dlqMessage = messageMap.get(key);
+                        logger.info("*******************************");
+                        logger.info("Message in the DLQ should be the same message: " + message.getBody().toString().equals(dlqMessage.getBody().toString()));
+                        logger.info("Message=" + message.getBody());
+                        logger.info("dlqMessage=" + dlqMessage.getBody());
+                        logger.info("*******************************");
+                    }
+                    if (messageMap.size() == 0) {
+                        logger.info("...Waiting for the DLQ Service to act.");
+                        try {
+                            Thread.sleep(100);
+                        } catch (InterruptedException ie) {
+                            logger.error(ie);
+                        }
+                    }
+                }
+            } catch (MessageStoreException mse) {
+                throw new ActionProcessingException(mse.getMessage(), mse);
+            }
+            throw new ActionProcessingException(mde.getMessage(), mde);
+        } catch (RegistryException re) {
+            throw new ActionProcessingException(re.getMessage(), re);
+        } catch (FaultMessageException fme) {
+            throw new ActionProcessingException(fme.getMessage(), fme);
+        }
+        return message;
+
+    }
+
+}
\ No newline at end of file

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-21 16:22:21 UTC (rev 14423)
+++ labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/internal/soa/esb/persistence/format/db/DBMessageStoreImpl.java	2007-08-21 19:07:26 UTC (rev 14424)
@@ -92,7 +92,6 @@
 		{
 			release(conn);
 		}
-
 		return uid;
 	}
 
@@ -307,7 +306,7 @@
         {
             con = mgr.getConnection();
             con.setAutoCommit(false);
-            con.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
+            con.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
                
             Message message=select(uuid, con);
             

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-21 16:22:21 UTC (rev 14423)
+++ labs/jbossesb/trunk/product/services/jbossesb/src/main/java/org/jboss/soa/esb/actions/MessagePersister.java	2007-08-21 19:07:26 UTC (rev 14424)
@@ -63,6 +63,7 @@
             //the message can override the classification
             if (message.getProperties().getProperty(MessageStore.CLASSIFICATION)!=null) {
                 classification = String.valueOf(message.getProperties().getProperty(MessageStore.CLASSIFICATION));
+                message.getProperties().remove(MessageStore.CLASSIFICATION);
             }
             URI uri = messageStore.addMessage(message, classification);
             message.getProperties().setProperty(MessageStore.MESSAGE_URI, uri);

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-21 16:22:21 UTC (rev 14423)
+++ labs/jbossesb/trunk/product/services/jbossesb/src/main/resources/META-INF/jboss-esb.xml	2007-08-21 19:07:26 UTC (rev 14424)
@@ -20,7 +20,7 @@
               </jms-bus>
           </jms-provider>
            <schedule-provider name="schedule">
-            <simple-schedule scheduleid="5-min-trigger" frequency="300" execCount="-1"/>
+            <simple-schedule scheduleid="5-min-trigger" frequency="300" repeatCount="-1"/>
         </schedule-provider>
       </providers>
       




More information about the jboss-svn-commits mailing list