Repository: camel Updated Branches: refs/heads/master 79c96233d -> f8ca43d05
CAMEL-10288: Move RoutePolicy initialization logic in onStart Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f8ca43d0 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f8ca43d0 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f8ca43d0 Branch: refs/heads/master Commit: f8ca43d05dcb0b2bfd2977af7bf819355b089441 Parents: 79c9623 Author: lburgazzoli <lburgazz...@gmail.com> Authored: Mon Sep 5 15:51:51 2016 +0200 Committer: lburgazzoli <lburgazz...@gmail.com> Committed: Mon Sep 5 15:51:51 2016 +0200 ---------------------------------------------------------------------- .../hazelcast/policy/HazelcastRoutePolicy.java | 21 +++++++------------- 1 file changed, 7 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/f8ca43d0/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/policy/HazelcastRoutePolicy.java ---------------------------------------------------------------------- diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/policy/HazelcastRoutePolicy.java b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/policy/HazelcastRoutePolicy.java index 9dbb089..8d9e142 100644 --- a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/policy/HazelcastRoutePolicy.java +++ b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/policy/HazelcastRoutePolicy.java @@ -26,7 +26,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import com.hazelcast.core.HazelcastInstance; import com.hazelcast.core.IMap; -import org.apache.camel.Exchange; import org.apache.camel.NonManagedService; import org.apache.camel.Route; import org.apache.camel.component.hazelcast.HazelcastUtil; @@ -82,19 +81,9 @@ public class HazelcastRoutePolicy extends RoutePolicySupport implements NonManag } @Override - public void onExchangeBegin(Route route, Exchange exchange) { - if (leader.get()) { - if (shouldStopConsumer) { - startConsumer(route); - } - } else { - if (shouldStopConsumer) { - stopConsumer(route); - } - - exchange.setException(new IllegalStateException( - "Hazelcast based route policy prohibits processing exchanges, stopping route and failing the exchange") - ); + public void onStart(Route route) { + if (!leader.get() && shouldStopConsumer) { + stopConsumer(route); } } @@ -244,6 +233,10 @@ public class HazelcastRoutePolicy extends RoutePolicySupport implements NonManag this.tryLockTimeoutUnit = tryLockTimeoutUnit; } + public boolean isLeader() { + return leader.get(); + } + // ************************************************************************* // // *************************************************************************