Updating hystrix configuration in camel route - apache-camel

Is there a way to update hystrix configuration at runtime? I am using Java DSL to create route and referring to a hystrix configuration bean in SimpleRegistry (also tried with SpringBean registry). Nothing seems to change when I modify this bean and then do camelContext.addRouteDefinition().

Related

Apache camel developer console

Apache camel has added camel developer console in their latest release(3.15.0)
I was trying it but after adding dependencies and 'camel.main.dev-console-enabled = true' , I am not able to find the developer console I had tried with endpoint http://localhost:8080/dev
Also I am not able to enable dev console when I am using Camel Context wrote in XML DSL.
How can i add statement to enable developer console when i have camel context written in XML DSL
It is actually a very new feature, for now, the developer console is only available from http://localhost:8080/dev when you use Camel JBang as mentioned in the documentation.
For other modes, you can enable it programmatically by calling context.setDevConsole(true) or in case of Camel Main by setting camel.main.dev-console-enabled to true (as you mentioned) but it is not yet exposed, it can only be accessed programmatically from the DevConsoleRegistry (accessible with context.getExtension(DevConsoleRegistry.class)).

Apache Camel - How to set a private key in a dynamic sftp endpoint

Using Java DSL, I have a route in which I poll a file in an SFTP server using the file name set in the message headers
from("direct:download")
.pollEnrich()
.simple("sftp://my.host:22/folder/?username=foo&fileName=${header.CamelFileName}")
.to("file://state/downloaded");
The sftp endpoint needs to have set a private key. Usually something like this suffices:
endpoint("sftp://my.host:22/folder/?username=foo&fileName=my_file_explicitly_written_here", SftpEndpoint.class).getConfiguration().setPrivateKey(getSshPrivateKey());
However, I see no way to "mix" dynamic fields in the URI (${header.CamelFileName}) in the pollEnrich().simple()) with endpoint configuration.
Any suggestion on this?
You can reference privateKey as bean from registry.
.pollEnrich()
.simple("sftp://my.host:22/folder/?username=foo&privateKey=#myKeyInRegistry&fileName=${header.CamelFileName}")
Binding bean to registry depends on platform and Camel version you are using.

Difference between CamelContext and Registry in Camel

I'm new to Camel and bit confused between CamelContext and Registry.
As far as I know that CamelContext is the base object like ApplicationContext in Spring that is used for add routes and maintains the camel life cycle.
Also we got the Registry object from CamelContext but not sure what is the main purpose of this registry.
My intention is to add the component in the context/registry so that JNDIBind can look up the components.
CamelContext: Kind of Camel Runtime that keeps everything in Camel together, e.g.: Endpoints, TypeConverter, Routes, Components and Registry(!).
Registry: allows you to lookup beans, which by default will be JNDI beans. If you use the spring integration it will be Spring's ApplicationContext.
Generally camel when used with spring makes use of the ApplicationContextRegistry to lookup components, endpoints etc with the name of the bean defined in spring-bean.xml file. In places where we need to use JNDIRegistry we would have to add that registry when creating the CamelContext. This is used in places where JNDI objects are shared accross multiple JVMs where JNDI is the best solution.
Please see different types of registry implementation for camel: camel registries

How to access Default Idempotent Repository map from java dsl?

I am newbie to Apache Camel. How can i access Camel Default Idempotent Repository map in Java DSL.
Route:
from("file://C:/folderA?noop=true")
.to("file://C:/folderB")
.end();
When i say noop=true in route, then idempotent will be true. Now i need to get Idempotent map in java dsl. Please tell me how to access this?
Thanks in advance.
If you want to access the underlying map, you should specify your own idempotentRepository bean. Using the existing MemoryIdempotentRepository should be pretty easy.
//Instantiate repository and get map
IdempotentRepository<String> repo = MemoryIdempotentRepository.memoryIdempotentRepository()
Map<String, Object> map = repo.getCache();
//Bind the repo to the Camel Context Registry using the id "repo"
//This changes depending upon how you are running Camel
//In your RouteBuilder...
from("file://C:/folderA?noop=true&idempotentRepository=#repo")
.to("file://C:/folderB")
.end();

Apache camel Quartz endpoints : rescheduling at runtime

Is it possible to change cron expression of camel quartzendpoint at runtime using jmx or so ?
You can update the route itself (including configuration of the quartz endpoint). As an example you can see how Camel plugin of Hawt.io (http://hawt.io/plugins/camel/) does it
No, but you could experiment with CamelContext and see if you can add new routes at runtime.

Resources