ServiceMix Components
  1. ServiceMix Components
  2. SMXCOMP-348

Camel Service Engine Component not handling error from Camel processing

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.2.1, 3.2.2
    • Component/s: servicemix-camel
    • Labels:
      None
    • Environment:

      ServiceMix 3.2.1
      ServiceMix-Camel 3.2.2-SNAPSHOT
      Camel 1.4-SNAPSHOT

      Description

      When an exception occured in camel processor, the message exchange is sent back to the NMR without taking care of its failed status.
      ServiceMix MessageExchange ends in Done status instead of Error.

      The probably incorrect code is in CamelJbiEndpoint.handleActiveProviderExchange() :
      After calling "camelProcessor.process(camelExchange);", the method sould have a look at camelExchange.isFailed()
      and filling exchange with correct status and exception before calling "send(exchange);".

      http://svn.apache.org/repos/asf/servicemix/components/engines/servicemix-camel/trunk/src/main/java/org/apache/servicemix/camel/CamelJbiEndpoint.java

        Activity

        Manuel EVENO created issue -
        Hide
        Manuel EVENO added a comment -

        A possible workaround consists in creating an ErrorProcessor that handles status :

        public final class ErrorProcessor implements Processor {
        	
        	private static final Logger logger = Logger.getLogger(ErrorProcessor.class);
        	
        	public void process(Exchange exchange) throws Exception {
        		if (logger.isDebugEnabled()) {
        			logger.debug("Trying to find an exception in property: " + DeadLetterChannel.EXCEPTION_CAUSE_PROPERTY);
        		}
        		Throwable exception = (Throwable) exchange.getProperty(DeadLetterChannel.EXCEPTION_CAUSE_PROPERTY);
        		if (exception != null) {
        			exchange.setException(exception);
        		} else {
        			logger.debug("Trying to find an exception using: DeadLetterChannel.restoreExceptionOnExchange()");
        			DeadLetterChannel.restoreExceptionOnExchange(exchange);
        		}
        		exception = exchange.getException();
        		if (logger.isDebugEnabled()) {
        			logger.debug("Exchange exception is " + exception);
        			logger.debug("Exchange.isFailed()=" + exchange.isFailed());
        		}
        		if (exception != null && exchange instanceof JbiExchange) {
        			logger.info("An exception has occured, setting ServiceMix messageExchange status to Error");
        			MessageExchangeImpl messageExchange = (MessageExchangeImpl) ((JbiExchange) exchange).getMessageExchange();
        			messageExchange.setStatus(ExchangeStatus.ERROR);
        			if (exception instanceof Exception) {
        				messageExchange.setError((Exception)exception);
        			} else {
        				messageExchange.setError(new Exception(exception));
        			}
        		}
        	}
        }
        

        And setting it to the deadLetterChannel as the final endpoint :

        		deadLetterChannel.setDefaultDeadLetterEndpoint(new ErrorProcessor());
        
        Show
        Manuel EVENO added a comment - A possible workaround consists in creating an ErrorProcessor that handles status : public final class ErrorProcessor implements Processor { private static final Logger logger = Logger.getLogger(ErrorProcessor.class); public void process(Exchange exchange) throws Exception { if (logger.isDebugEnabled()) { logger.debug( "Trying to find an exception in property: " + DeadLetterChannel.EXCEPTION_CAUSE_PROPERTY); } Throwable exception = (Throwable) exchange.getProperty(DeadLetterChannel.EXCEPTION_CAUSE_PROPERTY); if (exception != null ) { exchange.setException(exception); } else { logger.debug( "Trying to find an exception using: DeadLetterChannel.restoreExceptionOnExchange()" ); DeadLetterChannel.restoreExceptionOnExchange(exchange); } exception = exchange.getException(); if (logger.isDebugEnabled()) { logger.debug( "Exchange exception is " + exception); logger.debug( "Exchange.isFailed()=" + exchange.isFailed()); } if (exception != null && exchange instanceof JbiExchange) { logger.info( "An exception has occured, setting ServiceMix messageExchange status to Error" ); MessageExchangeImpl messageExchange = (MessageExchangeImpl) ((JbiExchange) exchange).getMessageExchange(); messageExchange.setStatus(ExchangeStatus.ERROR); if (exception instanceof Exception) { messageExchange.setError((Exception)exception); } else { messageExchange.setError( new Exception(exception)); } } } } And setting it to the deadLetterChannel as the final endpoint : deadLetterChannel.setDefaultDeadLetterEndpoint( new ErrorProcessor());
        Hide
        Guillaume Nodet added a comment -

        Sending src/main/java/org/apache/servicemix/camel/CamelJbiEndpoint.java
        Sending src/test/java/org/apache/servicemix/camel/JbiInOnlyTest.java
        Transmitting file data ..
        Committed revision 691630.

        Show
        Guillaume Nodet added a comment - Sending src/main/java/org/apache/servicemix/camel/CamelJbiEndpoint.java Sending src/test/java/org/apache/servicemix/camel/JbiInOnlyTest.java Transmitting file data .. Committed revision 691630.
        Guillaume Nodet made changes -
        Field Original Value New Value
        Resolution Fixed [ 1 ]
        Fix Version/s 3.3 [ 11850 ]
        Assignee Guillaume Nodet [ gnt ]
        Status Open [ 1 ] Resolved [ 5 ]
        Hide
        Ron Gavlin added a comment -

        Would it be possible to also commit this fix to the smx 3.2.x branch?

        Show
        Ron Gavlin added a comment - Would it be possible to also commit this fix to the smx 3.2.x branch?
        Guillaume Nodet made changes -
        Status Resolved [ 5 ] Reopened [ 4 ]
        Resolution Fixed [ 1 ]
        Hide
        Guillaume Nodet added a comment -

        Fix for 3.2 branch

        Sending servicemix-camel/src/main/java/org/apache/servicemix/camel/CamelJbiEndpoint.java
        Transmitting file data .
        Committed revision 691885.

        Show
        Guillaume Nodet added a comment - Fix for 3.2 branch Sending servicemix-camel/src/main/java/org/apache/servicemix/camel/CamelJbiEndpoint.java Transmitting file data . Committed revision 691885.
        Guillaume Nodet made changes -
        Resolution Fixed [ 1 ]
        Status Reopened [ 4 ] Resolved [ 5 ]
        Fix Version/s 3.2.3 [ 11910 ]
        Guillaume Nodet made changes -
        Fix Version/s servicemix-camel-2008.01 [ 11935 ]
        Gert Vanthienen made changes -
        Fix Version/s 3.2.3 [ 11910 ]
        Component/s servicemix-camel [ 11688 ]
        Fix Version/s 3.3 [ 12055 ]
        Fix Version/s servicemix-camel-2008.01 [ 12046 ]
        Affects Version/s 3.2.1 [ 12057 ]
        Component/s servicemix-camel [ 11786 ]
        Fix Version/s servicemix-camel-2008.01 [ 11935 ]
        Fix Version/s 3.2.3 [ 12005 ]
        Affects Version/s 3.2.2 [ 12006 ]
        Key SM-1473 SMXCOMP-348
        Affects Version/s 3.2.1 [ 11847 ]
        Project ServiceMix [ 10950 ] ServiceMix Components [ 11080 ]
        Affects Version/s 3.2.2 [ 11861 ]
        Fix Version/s 3.3 [ 11850 ]
        Jeff Turner made changes -
        Project Import Sat Nov 27 01:42:42 EST 2010 [ 1290840162973 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        43d 5h 37m 1 Guillaume Nodet 03/Sep/08 14:52
        Resolved Resolved Reopened Reopened
        16h 8m 1 Guillaume Nodet 04/Sep/08 07:00
        Reopened Reopened Resolved Resolved
        23s 1 Guillaume Nodet 04/Sep/08 07:01

          People

          • Assignee:
            Guillaume Nodet
            Reporter:
            Manuel EVENO
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development