Spring integration 春季整合:无法与动物园管理员进行领袖选举
我正在尝试从我的应用程序容器中选出领导者来完成一些任务 我编写了以下代码Spring integration 春季整合:无法与动物园管理员进行领袖选举,spring-integration,apache-zookeeper,spring-integration-dsl,spring-cloud-zookeeper,Spring Integration,Apache Zookeeper,Spring Integration Dsl,Spring Cloud Zookeeper,我正在尝试从我的应用程序容器中选出领导者来完成一些任务 我编写了以下代码 @Configuration @EnableIntegration public class LeaderConfiguration { @Bean public LeaderInitiatorFactoryBean leaderInitiator(CuratorFramework client) { return new LeaderInitiatorFactoryBean() .setC
@Configuration
@EnableIntegration
public class LeaderConfiguration {
@Bean
public LeaderInitiatorFactoryBean leaderInitiator(CuratorFramework client) {
return new LeaderInitiatorFactoryBean()
.setClient(client)
.setPath("/app/test/")
.setRole("app");
}
@Bean
@Primary
CuratorFrameworkFactoryBean curatorFramework() {
return new CuratorFrameworkFactoryBean("127.0.0.1:2181");
}
@Bean
@InboundChannelAdapter(channel = "attributeChannel", autoStartup = "false", poller = @Poller(fixedDelay = "100"))
@Role("app")
public Supplier<String> inboundChannelAdapter() {
return () -> "app";
}
@Bean("attributeChannel")
public MessageChannel attributeChannel() {
return new DirectChannel();
}
@ServiceActivator(inputChannel = "attributeChannel", autoStartup = "false")
public void listen(Object a) {
System.out.println("I am leader");
}
}
我当地的动物园管理员已经开始工作了
我不断收到错误,可能是我的连接设置错误
019-05-02 19:08:57.178 INFO 38709 --- [ain-EventThread] o.a.c.f.state.ConnectionStateManager : State change: RECONNECTED
2019-05-02 19:08:57.180 INFO 38709 --- [127.0.0.1:2181)] org.apache.zookeeper.ClientCnxn : Unable to read additional data from server sessionid 0x10006f79d980001, likely server has closed socket, closing socket connection and attempting reconnect
2019-05-02 19:08:57.285 INFO 38709 --- [ain-EventThread] o.a.c.f.state.ConnectionStateManager : State change: SUSPENDED
2019-05-02 19:08:58.808 INFO 38709 --- [127.0.0.1:2181)] org.apache.zookeeper.ClientCnxn : Opening socket connection to server 127.0.0.1/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2019-05-02 19:08:58.808 INFO 38709 --- [127.0.0.1:2181)] org.apache.zookeeper.ClientCnxn : Socket connection established, initiating session, client: /127.0.0.1:56077, server: 127.0.0.1/127.0.0.1:2181
2019-05-02 19:08:58.810 INFO 38709 --- [127.0.0.1:2181)] org.apache.zookeeper.ClientCnxn : Session establishment complete on server 127.0.0.1/127.0.0.1:2181, sessionid = 0x10006f79d980001, negotiated timeout = 40000
2019-05-02 19:08:58.810 INFO 38709 --- [ain-EventThread] o.a.c.f.state.ConnectionStateManager : State change: RECONNECTED
2019-05-02 19:08:58.816 WARN 38709 --- [127.0.0.1:2181)] org.apache.zookeeper.ClientCnxn : Session 0x10006f79d980001 for server 127.0.0.1/127.0.0.1:2181, unexpected error, closing socket connection and attempting reconnect
java.io.IOException: Xid out of order. Got Xid 21 with err -6 expected Xid 20 for a packet with details: clientPath:/app/test/app serverPath:/app/test/app finished:false header:: 20,12 replyHeader:: 0,0,-4 request:: '/app/test/app,F response:: v{}
我做错了什么。看起来像是compile(“org.apache.curator:curator recipes:4.2.0”)
附带org.apache.zookeer:zookeer:3.5.4-beta
要使它与zookeer3.4.x
一起工作,我们需要遵循策展人框架的指示:
Curator 4.0以软兼容模式支持ZooKeeper 3.4.x集成。若要使用此模式,在将管理员添加到依赖项管理工具时,必须排除ZooKeeper
因此,包括zookeeper
对3.4.14
版本的依赖关系
嗯。看起来你也需要将它从
spring cloud zookeeper core
依赖项中排除。我想知道你是否使用最新的zookeeper版本:@ArtemBilan。我使用的zookeeper 3.4.3与zookeeper集成5.1.4.0版本不兼容。我降级到5.0.2.RELEASE,然后开始正常工作。非常感谢
019-05-02 19:08:57.178 INFO 38709 --- [ain-EventThread] o.a.c.f.state.ConnectionStateManager : State change: RECONNECTED
2019-05-02 19:08:57.180 INFO 38709 --- [127.0.0.1:2181)] org.apache.zookeeper.ClientCnxn : Unable to read additional data from server sessionid 0x10006f79d980001, likely server has closed socket, closing socket connection and attempting reconnect
2019-05-02 19:08:57.285 INFO 38709 --- [ain-EventThread] o.a.c.f.state.ConnectionStateManager : State change: SUSPENDED
2019-05-02 19:08:58.808 INFO 38709 --- [127.0.0.1:2181)] org.apache.zookeeper.ClientCnxn : Opening socket connection to server 127.0.0.1/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2019-05-02 19:08:58.808 INFO 38709 --- [127.0.0.1:2181)] org.apache.zookeeper.ClientCnxn : Socket connection established, initiating session, client: /127.0.0.1:56077, server: 127.0.0.1/127.0.0.1:2181
2019-05-02 19:08:58.810 INFO 38709 --- [127.0.0.1:2181)] org.apache.zookeeper.ClientCnxn : Session establishment complete on server 127.0.0.1/127.0.0.1:2181, sessionid = 0x10006f79d980001, negotiated timeout = 40000
2019-05-02 19:08:58.810 INFO 38709 --- [ain-EventThread] o.a.c.f.state.ConnectionStateManager : State change: RECONNECTED
2019-05-02 19:08:58.816 WARN 38709 --- [127.0.0.1:2181)] org.apache.zookeeper.ClientCnxn : Session 0x10006f79d980001 for server 127.0.0.1/127.0.0.1:2181, unexpected error, closing socket connection and attempting reconnect
java.io.IOException: Xid out of order. Got Xid 21 with err -6 expected Xid 20 for a packet with details: clientPath:/app/test/app serverPath:/app/test/app finished:false header:: 20,12 replyHeader:: 0,0,-4 request:: '/app/test/app,F response:: v{}
compile('org.springframework.integration:spring-integration-zookeeper') {
exclude group: 'org.apache.zookeeper', module: 'zookeeper'
}