我创建了一个小的 Apache Camel 示例,它使用了 camel-zeromq 组件。JeroMQ 被配置为 ZMQ 实现。
这里摘录build.gradle.kts
dependencies {
// 3.0.0-M1, see https://stackoverflow.com/q/55314360/1809463
val camelVersion = "2.23.1"
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.apache.camel:camel-spring-boot-starter:$camelVersion")
implementation("org.apache-extras.camel-extra:camel-zeromq:2.22.0") {
exclude(group = "org.zeromq", module = "zeromq-scala-binding_2.10")
exclude(group = "com.typesafe.akka", module = "akka-zeromq_2.10")
exclude(group = "com.typesafe.akka", module = "akka-actor_2.10")
}
implementation("org.zeromq:jeromq:0.4.0") // versions > 0.4.0 don't work
testImplementation("junit:junit:4.12")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.apache.camel:camel-test:$camelVersion")
testImplementation("org.apache.camel:camel-test-spring:$camelVersion")
}
当设置了一个小的超时值时,关闭时会发生以下两个错误ShutdownStrategy
,否则不会记录错误并且应用程序不会完全终止。
java.lang.IllegalStateException: null at zmq.Ctx.terminate(Ctx.java:198) ~[jeromq-0.4.0.jar:na] at org.zeromq.ZMQ$Context.term(ZMQ.java:316) ~ [jeromq-0.4.0.jar:na] 在 org.apacheextras.camel.component.zeromq.Listener.stop(Listener.java:130) ~[camel-zeromq-2.22.0.jar:2.22.0] 在 org .apacheextras.camel.component.zeromq.ZeromqConsumer.doStop(ZeromqConsumer.java:63) [camel-zeromq-2.22.0.jar:2.22.0]
和
java.lang.InterruptedException: null at java.lang.Object.wait(Native Method) ~[na:1.8.0_40] at java.lang.Thread.join(Thread.java:1253) [na:1.8.0_40] at org.apacheextras.camel.component.zeromq.ZeromqProducer.stop(ZeromqProducer.java:122) ~[camel-zeromq-2.22.0.jar:2.22.0]