1 17 package org.apache.servicemix.common; 18 19 import javax.jbi.messaging.MessageExchange; 20 import javax.transaction.Status ; 21 22 import org.apache.servicemix.MessageExchangeListener; 23 24 32 public class BaseLifeCycle extends AsyncBaseLifeCycle implements MessageExchangeListener { 33 34 public BaseLifeCycle(BaseComponent component) { 35 super(component); 36 } 37 38 41 public void onMessageExchange(MessageExchange exchange) { 42 try { 43 processExchange(exchange); 44 } catch (Exception e) { 45 logger.error("Error processing exchange " + exchange, e); 46 try { 47 if (transactionManager != null && 50 transactionManager.getStatus() == Status.STATUS_ACTIVE && 51 exceptionShouldRollbackTx(e)) { 52 transactionManager.setRollbackOnly(); 53 } 54 exchange.setError(e); 55 channel.send(exchange); 56 } catch (Exception inner) { 57 logger.error("Error setting exchange status to ERROR", inner); 58 } 59 } 60 } 61 62 } 63 | Popular Tags |