首页 > 解决方案 > 由于 Corda 节点的连接(RPC 连接)错误,Camel 上下文无法启动

问题描述

我的 Spring Boot Camel 应用程序使用 camel-corda 组件,并且当 corda 节点(RPC 连接)未启动和运行时无法启动

我目前的骆驼路线是

@Component
class CordaOpsRouteBuilder() : RouteBuilder() {

    override fun configure() {
     
        from("timer://terminate?repeatCount=1&delay=20").autoStartup("{{corda.terminate.node}}")
                .to("direct:terminate-node")

        from("direct:terminate-node")
                .log("Draining and shutting down node")
                .to("corda://{{corda.rpc.username}}:{{corda.rpc.password}}@{{corda.rpc.host}}:{{corda.rpc.port}}?operation=TERMINATE")
                
                .delay(10000).asyncDelayed()
                .to("direct:shutdown")

        from ("direct:shutdown")
                .setHeader(Exchange.HTTP_METHOD, constant("POST"))
                .to("http://localhost:{{server.port}}/actuator/shutdown")
    }
}

堆栈跟踪 :

Caused by: org.apache.camel.RuntimeCamelException: net.corda.client.rpc.RPCException: Cannot connect to server(s). Tried with all available servers.
        at org.apache.camel.RuntimeCamelException.wrapRuntimeCamelException(RuntimeCamelException.java:52) ~[camel-api-3.0.0-RC3.jar:3.0.0-RC3]
        at org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:63) ~[camel-support-3.0.0-RC3.jar:3.0.0-RC3]

启动过程中如何处理上述RuntimeCamelException?

标签: apache-camelcorda

解决方案


lazyStartProducer=true在端点上使用参数corda以确保即使路由corda不可用(延迟启动)也会启动。

https://camel.apache.org/components/latest/corda-component.html


推荐阅读