You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Stefan Meisner Larsen <st...@meisner-larsen.dk> on 2017/01/27 13:58:34 UTC
Cant get simple ZooKeeperRoutePolicy example to work
Hi,
I'm trying to get this simple example to work:
In Karaf I create two camel contexts each with an instance of this
routebuilder:
package dk.jppol.ip.app.service.adorderservice.camel;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.zookeeper.policy.ZooKeeperRoutePolicy;
public class SimpleServiceRouteBuilder extends RouteBuilder {
private String routeId;
public void setRouteId(final String routeId) {
this.routeId = routeId;
}
@Override
public void configure() throws Exception {
from("timer://timer1?fixedRate=true&period=10000")
.routeId(routeId)
.routePolicy(new
ZooKeeperRoutePolicy("zookeeper:localhost:2181/test/test.lock", 1))
.log("Hello from " + routeId);
}
}
As expected, one of the routes logs the "Hello" message, and I see two
entries in the zookeeper lock.
When I stop the camel context with the active route, I see that the entry
in the zookeeper locks goes away. So far so good.
My problem is, that the other route is never started. I should expect
that...right?!
Apache Karaf 4.0.4, Apache Camel 2.18.1
Any help appreciated! :-)
Log file:
2017-01-27 14:42:48,832 | INFO | - timer://timer1 |
ZooKeeperElection | 95 - org.apache.camel.camel-zookeeper -
2.18.1 | Initializing ZookeeperElection with uri
'zookeeper:localhost:2181/test/test.lock'
2017-01-27 14:42:48,834 | WARN | - timer://timer1 |
ZooKeeperProducer | 83 - org.apache.camel.camel-core -
2.18.1 | Node
'/test/test.lock/stefan-ThinkPad-T450-3409987f-dadd-4199-9fe5-432893680a55'
did not exist, creating it.
2017-01-27 14:42:48,836 | INFO | - timer://timer1 |
ZooKeeper | 118 - org.apache.hadoop.zookeeper -
3.4.7 | Initiating client connection, connectString=localhost:2181
sessionTimeout=5000
watcher=org.apache.camel.component.zookeeper.ConnectionHolder@6b965df0
2017-01-27 14:42:48,839 | INFO | (localhost:2181) |
ClientCnxn | 118 - org.apache.hadoop.zookeeper -
3.4.7 | Opening socket connection to server localhost/127.0.0.1:2181. Will
not attempt to authenticate using SASL (unknown error)
2017-01-27 14:42:48,840 | INFO | (localhost:2181) |
ClientCnxn | 118 - org.apache.hadoop.zookeeper -
3.4.7 | Socket connection established to localhost/127.0.0.1:2181,
initiating session
2017-01-27 14:42:48,845 | INFO | (localhost:2181) |
ClientCnxn | 118 - org.apache.hadoop.zookeeper -
3.4.7 | Session establishment complete on server localhost/127.0.0.1:2181,
sessionid = 0x159dff1aae5000e, negotiated timeout = 5000
2017-01-27 14:42:48,854 | WARN | - timer://timer1 |
ZooKeeperProducer | 83 - org.apache.camel.camel-core -
2.18.1 | Node
'/test/test.lock/stefan-ThinkPad-T450-be961ca6-348d-43e0-9676-43c7412f5fa5'
did not exist, creating it.
2017-01-27 14:42:48,872 | INFO | - timer://timer1 |
ZooKeeperElection | 95 - org.apache.camel.camel-zookeeper -
2.18.1 | Candidate node
'/test/test.lock/stefan-ThinkPad-T450-be961ca6-348d-43e0-9676-43c7412f5fa5'
has been created
2017-01-27 14:42:48,879 | INFO | - timer://timer1 |
ZooKeeperElection | 95 - org.apache.camel.camel-zookeeper -
2.18.1 | Candidate node
'/test/test.lock/stefan-ThinkPad-T450-3409987f-dadd-4199-9fe5-432893680a55'
has been created
2017-01-27 14:42:48,936 | INFO | - timer://timer1 |
BlueprintCamelContext | 83 - org.apache.camel.camel-core -
2.18.1 | Route:
election-route-stefan-ThinkPad-T450-3409987f-dadd-4199-9fe5-432893680a55
started and consuming from: zookeeper://localhost:2181/test/test.lock
2017-01-27 14:42:48,942 | INFO | - timer://timer1 |
BlueprintCamelContext | 83 - org.apache.camel.camel-core -
2.18.1 | Route:
election-route-stefan-ThinkPad-T450-be961ca6-348d-43e0-9676-43c7412f5fa5
started and consuming from: zookeeper://localhost:2181/test/test.lock
2017-01-27 14:42:48,974 | WARN | - timer://timer1 |
TimerConsumer | 83 - org.apache.camel.camel-core -
2.18.1 | Error processing exchange.
Exchange[ID-stefan-ThinkPad-T450-45149-1485524544339-2-2]. Caused by:
[java.lang.IllegalStateException - Zookeeper based route policy prohibits
processing exchanges, stopping route and failing the exchange]
java.lang.IllegalStateException: Zookeeper based route policy prohibits
processing exchanges, stopping route and failing the exchange
at
org.apache.camel.component.zookeeper.policy.ZooKeeperRoutePolicy.onExchangeBegin(ZooKeeperRoutePolicy.java:88)[95:org.apache.camel.camel-zookeeper:2.18.1]
at
org.apache.camel.processor.CamelInternalProcessor$RoutePolicyAdvice.before(CamelInternalProcessor.java:490)[83:org.apache.camel.camel-core:2.18.1]
at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:145)[83:org.apache.camel.camel-core:2.18.1]
at
org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:192)[83:org.apache.camel.camel-core:2.18.1]
at
org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:76)[83:org.apache.camel.camel-core:2.18.1]
at java.util.TimerThread.mainLoop(Timer.java:555)[:1.8.0_121]
at java.util.TimerThread.run(Timer.java:505)[:1.8.0_121]
2017-01-27 14:42:48,976 | INFO | - timer://timer1 |
2 | 83 - org.apache.camel.camel-core -
2.18.1 | Hello from zootest.2
2017-01-27 14:42:48,980 | ERROR | - timer://timer1 |
DefaultErrorHandler | 83 - org.apache.camel.camel-core -
2.18.1 | Failed delivery for (MessageId:
ID-stefan-ThinkPad-T450-45149-1485524544339-2-1 on ExchangeId:
ID-stefan-ThinkPad-T450-45149-1485524544339-2-2). Exhausted after delivery
attempt: 1 caught: java.lang.IllegalStateException: Zookeeper based route
policy prohibits processing exchanges, stopping route and failing the
exchange
Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId ProcessorId
Processor
Elapsed (ms)
[zootest.1 ] [zootest.1 ]
[timer://timer1?fixedRate=true&period=10000
] [ 224]
[zootest.1 ] [log4 ]
[log
] [ 2]
Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
java.lang.IllegalStateException: Zookeeper based route policy prohibits
processing exchanges, stopping route and failing the exchange
at
org.apache.camel.component.zookeeper.policy.ZooKeeperRoutePolicy.onExchangeBegin(ZooKeeperRoutePolicy.java:88)[95:org.apache.camel.camel-zookeeper:2.18.1]
at
org.apache.camel.processor.CamelInternalProcessor$RoutePolicyAdvice.before(CamelInternalProcessor.java:490)[83:org.apache.camel.camel-core:2.18.1]
at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:145)[83:org.apache.camel.camel-core:2.18.1]
at
org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:192)[83:org.apache.camel.camel-core:2.18.1]
at
org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:76)[83:org.apache.camel.camel-core:2.18.1]
at java.util.TimerThread.mainLoop(Timer.java:555)[:1.8.0_121]
at java.util.TimerThread.run(Timer.java:505)[:1.8.0_121]
2017-01-27 14:42:58,834 | INFO | - timer://timer1 |
2 | 83 - org.apache.camel.camel-core -
2.18.1 | Hello from zootest.2
2017-01-27 14:43:08,833 | INFO | - timer://timer1 |
2 | 83 - org.apache.camel.camel-core -
2.18.1 | Hello from zootest.2
2017-01-27 14:43:18,833 | INFO | - timer://timer1 |
2 | 83 - org.apache.camel.camel-core -
2.18.1 | Hello from zootest.2
2017-01-27 14:43:28,833 | INFO | - timer://timer1 |
2 | 83 - org.apache.camel.camel-core -
2.18.1 | Hello from zootest.2
2017-01-27 14:43:38,833 | INFO | - timer://timer1 |
2 | 83 - org.apache.camel.camel-core -
2.18.1 | Hello from zootest.2
2017-01-27 14:43:48,833 | INFO | - timer://timer1 |
2 | 83 - org.apache.camel.camel-core -
2.18.1 | Hello from zootest.2
2017-01-27 14:43:58,833 | INFO | - timer://timer1 |
2 | 83 - org.apache.camel.camel-core -
2.18.1 | Hello from zootest.2
2017-01-27 14:44:08,833 | INFO | - timer://timer1 |
2 | 83 - org.apache.camel.camel-core -
2.18.1 | Hello from zootest.2
2017-01-27 14:44:18,833 | INFO | - timer://timer1 |
2 | 83 - org.apache.camel.camel-core -
2.18.1 | Hello from zootest.2
2017-01-27 14:44:28,833 | INFO | - timer://timer1 |
2 | 83 - org.apache.camel.camel-core -
2.18.1 | Hello from zootest.2
2017-01-27 14:44:38,832 | INFO | - timer://timer1 |
2 | 83 - org.apache.camel.camel-core -
2.18.1 | Hello from zootest.2
2017-01-27 14:44:48,832 | INFO | - timer://timer1 |
2 | 83 - org.apache.camel.camel-core -
2.18.1 | Hello from zootest.2
2017-01-27 14:44:49,397 | INFO | nsole user karaf |
BlueprintCamelContext | 83 - org.apache.camel.camel-core -
2.18.1 | Apache Camel 2.18.1 (CamelContext: service.test.core.2) is
shutting down
2017-01-27 14:44:49,400 | INFO | nsole user karaf |
DefaultShutdownStrategy | 83 - org.apache.camel.camel-core -
2.18.1 | Starting to graceful shutdown 2 routes (timeout 300 seconds)
2017-01-27 14:44:49,413 | INFO | 5 - ShutdownTask |
ZooKeeper | 118 - org.apache.hadoop.zookeeper -
3.4.7 | Session: 0x159dff1aae5000e closed
2017-01-27 14:44:49,413 | INFO | mer1-EventThread |
ClientCnxn | 118 - org.apache.hadoop.zookeeper -
3.4.7 | EventThread shut down for session: 0x159dff1aae5000e
2017-01-27 14:44:49,414 | INFO | 5 - ShutdownTask |
DefaultShutdownStrategy | 83 - org.apache.camel.camel-core -
2.18.1 | Route:
election-route-stefan-ThinkPad-T450-be961ca6-348d-43e0-9676-43c7412f5fa5
shutdown complete, was consuming from:
zookeeper://localhost:2181/test/test.lock
2017-01-27 14:44:49,415 | INFO | 5 - ShutdownTask |
DefaultShutdownStrategy | 83 - org.apache.camel.camel-core -
2.18.1 | Route: zootest.2 shutdown complete, was consuming from:
timer://timer1?fixedRate=true&period=10000
2017-01-27 14:44:49,416 | INFO | nsole user karaf |
DefaultShutdownStrategy | 83 - org.apache.camel.camel-core -
2.18.1 | Graceful shutdown of 2 routes completed in 0 seconds
2017-01-27 14:44:49,462 | INFO | nsole user karaf |
BlueprintCamelContext | 83 - org.apache.camel.camel-core -
2.18.1 | Apache Camel 2.18.1 (CamelContext: service.test.core.2) uptime 2
minutes
2017-01-27 14:44:49,462 | INFO | nsole user karaf |
BlueprintCamelContext | 83 - org.apache.camel.camel-core -
2.18.1 | Apache Camel 2.18.1 (CamelContext: service.test.core.2) is
shutdown in 0.064 seconds