0
votes

My Spring boot camel application uses camel-corda component and failing to start when corda node (RPC connection) is not up and running

My current camel route is

@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")
    }
}

Stack trace :

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]

How can handle above RuntimeCamelException during the startup?

1
This page explains how to do exception handling on Camel routes. However, what do you mean by How can handle above RuntimeCamelException during the startup?. Do you want the route with corda component,to start up, even when the Corda node is down? If yes, when do you expect it to wake up and activate?ShellDragon

1 Answers

0
votes

Please use lazyStartProducer=true parameter on the corda endpoint to make sure the route starts even if corda is not available (a lazy start).

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