@Test public void incompatibleRequirements_PropagatesAndSuspends() { PolicyUtil.require(exchange, TransactionPolicy.PROPAGATES_TRANSACTION); PolicyUtil.require(exchange, TransactionPolicy.SUSPENDS_TRANSACTION); exchange.setPhase(ExchangePhase.IN); try { handler.handleMessage(exchange); } catch (HandlerException handlerEx) { System.out.println(handlerEx.toString()); return; } Assert.fail("Expected a handler exception due to incompatible policy"); }
@Override public void handleMessage(Exchange exchange) throws HandlerException { if (_transactionManager == null) { return; } Property prop = exchange.getContext().getProperty(BEFORE_INVOKED_PROPERTY, Scope.EXCHANGE); if (prop != null && Boolean.class.cast(prop.getValue())) { handleAfter(exchange); } else { exchange.getContext().setProperty(BEFORE_INVOKED_PROPERTY, Boolean.TRUE, Scope.EXCHANGE).addLabels(BehaviorLabel.TRANSIENT.label()); handleBefore(exchange); } }
TransactionHandler implements ExchangeHandler { @Override public void handleMessage(Exchange exchange) throws HandlerException { if (_transactionManager == null) { return; } Property prop = exchange.getContext().getProperty(BEFORE_INVOKED_PROPERTY, Scope.EXCHANGE); if (prop != null && Boolean.class.cast(prop.getValue())) { handleAfter(exchange); } else { exchange.getContext().setProperty(BEFORE_INVOKED_PROPERTY, Boolean.TRUE, Scope.EXCHANGE).addLabels(BehaviorLabel.TRANSIENT.label()); handleBefore(exchange); } } }
TransactionHandler implements ExchangeHandler { @Override public void handleMessage(Exchange exchange) throws HandlerException { if (_transactionManager == null) { return; } Property prop = exchange.getContext().getProperty(BEFORE_INVOKED_PROPERTY, Scope.EXCHANGE); if (prop != null && Boolean.class.cast(prop.getValue())) { handleAfter(exchange); } else { exchange.getContext().setProperty(BEFORE_INVOKED_PROPERTY, Boolean.TRUE, Scope.EXCHANGE).addLabels(BehaviorLabel.TRANSIENT.label()); handleBefore(exchange); } } TransactionHandler(); }
TransactionHandler implements ExchangeHandler { @Override public void handleMessage(Exchange exchange) throws HandlerException { if (_transactionManager == null) { return; } Property prop = exchange.getContext().getProperty(BEFORE_INVOKED_PROPERTY, Scope.EXCHANGE); if (prop != null && Boolean.class.cast(prop.getValue())) { handleAfter(exchange); } else { exchange.getContext().setProperty(BEFORE_INVOKED_PROPERTY, Boolean.TRUE, Scope.EXCHANGE).addLabels(BehaviorLabel.TRANSIENT.label()); handleBefore(exchange); } } TransactionHandler(); @Override void handleMessage(Exchange exchange); @Override void handleFault(Exchange exchange); }
TransactionHandler implements ExchangeHandler { @Override public void handleMessage(Exchange exchange) throws HandlerException { if (_transactionManager == null) { return; } Property prop = exchange.getContext().getProperty(BEFORE_INVOKED_PROPERTY, Scope.EXCHANGE); if (prop != null && Boolean.class.cast(prop.getValue())) { handleAfter(exchange); } else { exchange.getContext().setProperty(BEFORE_INVOKED_PROPERTY, Boolean.TRUE, Scope.EXCHANGE).addLabels(BehaviorLabel.TRANSIENT.label()); handleBefore(exchange); } } TransactionHandler(); @Override void handleMessage(Exchange exchange); @Override void handleFault(Exchange exchange);  }