servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r752095 - in /servicemix/components/bindings/servicemix-jms/trunk/src/main/java/org/apache/servicemix/jms/endpoints: DefaultConsumerMarshaler.java JmsSoapConsumerMarshaler.java
Date Tue, 10 Mar 2009 12:50:12 GMT
Author: gnodet
Date: Tue Mar 10 12:50:11 2009
New Revision: 752095

URL: http://svn.apache.org/viewvc?rev=752095&view=rev
Log:
SMXCOMP-474: Regression introduced in servicemix-jms default consumer which does not rollback
the transactions by default when an exchange with an ERROR status comes back

Modified:
    servicemix/components/bindings/servicemix-jms/trunk/src/main/java/org/apache/servicemix/jms/endpoints/DefaultConsumerMarshaler.java
    servicemix/components/bindings/servicemix-jms/trunk/src/main/java/org/apache/servicemix/jms/endpoints/JmsSoapConsumerMarshaler.java

Modified: servicemix/components/bindings/servicemix-jms/trunk/src/main/java/org/apache/servicemix/jms/endpoints/DefaultConsumerMarshaler.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-jms/trunk/src/main/java/org/apache/servicemix/jms/endpoints/DefaultConsumerMarshaler.java?rev=752095&r1=752094&r2=752095&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-jms/trunk/src/main/java/org/apache/servicemix/jms/endpoints/DefaultConsumerMarshaler.java
(original)
+++ servicemix/components/bindings/servicemix-jms/trunk/src/main/java/org/apache/servicemix/jms/endpoints/DefaultConsumerMarshaler.java
Tue Mar 10 12:50:11 2009
@@ -16,45 +16,44 @@
  */
 package org.apache.servicemix.jms.endpoints;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.io.InputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.OutputStream;
+import java.io.Serializable;
 import java.net.URI;
 import java.util.Map;
 import java.util.Set;
 
+import javax.activation.DataHandler;
 import javax.jbi.component.ComponentContext;
 import javax.jbi.messaging.Fault;
 import javax.jbi.messaging.MessageExchange;
 import javax.jbi.messaging.NormalizedMessage;
 import javax.jms.Message;
+import javax.jms.ObjectMessage;
 import javax.jms.Session;
 import javax.jms.TextMessage;
-import javax.jms.ObjectMessage;
-import javax.xml.transform.Source;
 import javax.xml.stream.XMLStreamReader;
-import javax.activation.DataHandler;
+import javax.xml.transform.Source;
 
 import org.apache.servicemix.common.JbiConstants;
-import org.apache.servicemix.jbi.jaxp.SourceTransformer;
-import org.apache.servicemix.jbi.jaxp.StringSource;
-import org.apache.servicemix.soap.core.PhaseInterceptorChain;
 import org.apache.servicemix.soap.core.MessageImpl;
+import org.apache.servicemix.soap.core.PhaseInterceptorChain;
 import org.apache.servicemix.soap.interceptors.mime.AttachmentsInInterceptor;
 import org.apache.servicemix.soap.interceptors.mime.AttachmentsOutInterceptor;
+import org.apache.servicemix.soap.interceptors.xml.BodyOutInterceptor;
 import org.apache.servicemix.soap.interceptors.xml.StaxInInterceptor;
 import org.apache.servicemix.soap.interceptors.xml.StaxOutInterceptor;
-import org.apache.servicemix.soap.interceptors.xml.BodyOutInterceptor;
 import org.apache.servicemix.soap.util.stax.StaxSource;
 
 public class DefaultConsumerMarshaler extends AbstractJmsMarshaler implements JmsConsumerMarshaler
{
     
     private URI mep;
+    private boolean rollbackOnError;
 
     public DefaultConsumerMarshaler() {
         this.mep = JbiConstants.IN_ONLY;
@@ -63,7 +62,7 @@
     public DefaultConsumerMarshaler(URI mep) {
         this.mep = mep;
     }
-    
+
     /**
      * @return the mep
      */
@@ -78,6 +77,17 @@
         this.mep = mep;
     }
 
+    public boolean isRollbackOnError() {
+        return rollbackOnError;
+    }
+
+    /**
+     * @param rollbackOnError if exchange in errors should cause a rollback on the JMS side
+     */
+    public void setRollbackOnError(boolean rollbackOnError) {
+        this.rollbackOnError = rollbackOnError;
+    }
+
     public JmsContext createContext(Message message) throws Exception {
         return new Context(message);
     }
@@ -144,9 +154,13 @@
     }
 
     public Message createError(MessageExchange exchange, Exception error, Session session,
JmsContext context) throws Exception {
-        ObjectMessage message = session.createObjectMessage(error);
-        message.setBooleanProperty(ERROR_JMS_PROPERTY, true);
-        return message;
+        if (rollbackOnError) {
+            throw error;
+        } else {
+            ObjectMessage message = session.createObjectMessage(error);
+            message.setBooleanProperty(ERROR_JMS_PROPERTY, true);
+            return message;
+        }
     }
 
     protected void populateMessage(Message message, NormalizedMessage normalizedMessage)
throws Exception {

Modified: servicemix/components/bindings/servicemix-jms/trunk/src/main/java/org/apache/servicemix/jms/endpoints/JmsSoapConsumerMarshaler.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-jms/trunk/src/main/java/org/apache/servicemix/jms/endpoints/JmsSoapConsumerMarshaler.java?rev=752095&r1=752094&r2=752095&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-jms/trunk/src/main/java/org/apache/servicemix/jms/endpoints/JmsSoapConsumerMarshaler.java
(original)
+++ servicemix/components/bindings/servicemix-jms/trunk/src/main/java/org/apache/servicemix/jms/endpoints/JmsSoapConsumerMarshaler.java
Tue Mar 10 12:50:11 2009
@@ -44,7 +44,8 @@
     private Binding<?> binding;
     private boolean useJbiWrapper = true;
     private Policy[] policies;
-    
+    private boolean rollbackOnError;
+
     /**
      * @return the binding
      */
@@ -87,6 +88,17 @@
         this.useJbiWrapper = useJbiWrapper;
     }
 
+    public boolean isRollbackOnError() {
+        return rollbackOnError;
+    }
+
+    /**
+     * @param rollbackOnError if exchange in errors should cause a rollback on the JMS side
+     */
+    public void setRollbackOnError(boolean rollbackOnError) {
+        this.rollbackOnError = rollbackOnError;
+    }
+
     public JmsContext createContext(Message message) throws Exception {
         return new Context(message);
     }
@@ -135,23 +147,27 @@
     }
 
     public Message createError(MessageExchange exchange, Exception error, Session session,
JmsContext context) throws Exception {
-        org.apache.servicemix.soap.api.Message in = ((Context) context).msg;
-        org.apache.servicemix.soap.api.Message msg = binding.createMessage(in);
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        msg.setContent(OutputStream.class, baos);
-        msg.setContent(MessageExchange.class, exchange);
-        msg.put(SoapVersion.class, in.get(SoapVersion.class));
-        msg.put(JbiConstants.USE_JBI_WRAPPER, useJbiWrapper);
-        InterceptorChain phase = getChain(Phase.ServerOutFault);
-        SoapFault soapFault;
-        if (error instanceof SoapFault) {
-            soapFault = (SoapFault) error;
+        if (rollbackOnError) {
+            throw error;
         } else {
-            soapFault = new SoapFault(error);
+            org.apache.servicemix.soap.api.Message in = ((Context) context).msg;
+            org.apache.servicemix.soap.api.Message msg = binding.createMessage(in);
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            msg.setContent(OutputStream.class, baos);
+            msg.setContent(MessageExchange.class, exchange);
+            msg.put(SoapVersion.class, in.get(SoapVersion.class));
+            msg.put(JbiConstants.USE_JBI_WRAPPER, useJbiWrapper);
+            InterceptorChain phase = getChain(Phase.ServerOutFault);
+            SoapFault soapFault;
+            if (error instanceof SoapFault) {
+                soapFault = (SoapFault) error;
+            } else {
+                soapFault = new SoapFault(error);
+            }
+            msg.setContent(Exception.class, soapFault);
+            phase.doIntercept(msg);
+            return session.createTextMessage(baos.toString());
         }
-        msg.setContent(Exception.class, soapFault);
-        phase.doIntercept(msg);
-        return session.createTextMessage(baos.toString());
     }
 
     protected InterceptorChain getChain(Phase phase) {



Mime
View raw message