Reputation: 594
I'm using camel with spring. One of our routes should send a TCP message to a dynamically selected endpoint. As the endpoint is just a string, I know I can use
.toD("netty4://...")
but the problem is with setting ssl parameters.
Netty component defines this as route url parameter so it looks like this:
.toD("netty4://...?sslContextParameters=mySslContextParameters");
and to make this work I have a bean:
@Bean
public SslContextParameters mySslContextParameters() {
...
return sslContextParameters();
}
This binds it to this single bean instance but what I need, is a dynamically configured bean so that I may set different parameters of the SSL based on some data I get from the producer.
What I would like is something like this (I know this is not proper camel syntax), when I could invoke a factory method and pass some parameters to it:
.toD("netty://...?sslContextParameters=${bean('mySslContestParameters(${exchange.param1}, ${exchange.param2}')}");
Upvotes: 0
Views: 1674
Reputation: 53
You can use the recipient list EIP per this camel FAQ.
Thx Steve, it was a good advice.
I had a similiar question, I used your advice and it's work!
In my camel-context.xml, I define two sslContextParameters
...
<camel:sslContextParameters id="firstSsl">
<camel:keyManagers keyPassword="changeit">
<camel:keyStore resource="/test/client.keystore.jks" password="changeit" />
</camel:keyManagers>
<camel:trustManagers>
<camel:keyStore resource="/test/client.truststore.jks" password="changeit" />
</camel:trustManagers>
</camel:sslContextParameters>
<camel:sslContextParameters id="secondSsl">
<camel:keyManagers keyPassword="otherpassword">
<camel:keyStore resource="/test/other-keystore.jks" password="otherpassword" />
</camel:keyManagers>
<camel:trustManagers>
<camel:keyStore resource="/test/other-truststore.jks" password="otherpassword" />
</camel:trustManagers>
</camel:sslContextParameters>
...
In my routeBuilder
.setHeader("sslContext", constant("firstSsl"))
//or
.setHeader("sslContext", constant("secondSsl"))
...
.recipientList(simple("https4://override/?bridgeEndpoint=false&sslContextParametersRef=${headers.sslContext}"))
Upvotes: 0