how to share data between different camel contexts - apache-camel

Is there a way to share data through different contexts.
I have created a custom component which i want to initialise only once.while initialising iam setting some properties which iam not able to access in another context.
How to access those?
Thanks.
Regards
Senthil Kumar Sekar

I believe you are looking for the VM component. This component provides an asynchronous way of sending messages across camel contexts with a SEDA-fashion. For more info, please refer to the actual documentation.
Also, I am not sure how you are setting those values but you could use two routes within the same context probably. Have you tried that?

Related

How to make React Service as Singleton, Injectable, and Redux Connected

Summary
I am writing a React-Redux application, and would like to create a service that can be accessed across multiple components, with the following characteristics:
Singleton (just gets instantiated once across the entire
application)
Injectable (can be injected into, and used by, multiple components across the application)
Redux Connected (can access the entire Redux state tree & received updates to state changes)
Code Example
The type of solution I have in mind, would allow me to inject a service int a React Component, and use in the following way:
{ featureAvailabilityService.isAvailable('myFeature') && (<MyFeature />) }
Ideas
I have read about High Order Components, Hooks, and the Context API. There are also some interesting libraries, such as Unstated, and Redux-Logic. I feel like the best answer probably lies somewhere between these, but could use some guidance to put me on the right track.
Use Case
In this instance, I would like to create a reusable service, which has methods to determine the availability of certain features. This involves relatively complex logic based on System, Tenant, and User configuration and state. It also requires the service to have access to state from several different parts of the application. It will also be reused broadly across the application.
Why Yet Another React Service Question?
I realize there are already a lot of similar questions to this, usually from people with an Angular background, looking for the React equivalent to an Angular Service. However, I have not yet found an answer that provides for the above three criteria... or at least not one that I understood.
Thanks for any input.

Sharing state in camel?

It appears I am running into issues sharing information between routes.
What is the camel pattern for passing around information ?
I looked at exchange properties but that does not stick around between routes I think...
eg:
one file has one has some configutations
i have a route to read this file
and several other routes that will act on based on the configs,
how do I accomplish this ?
I thought of puttin the values in a singleton bean, but that seems kind of ugly...
Exchange properties are preserved across routes inside camel (but there are some limitations and special cases when using splitter/aggregator etc.)
Assign ID's to all sub routes which will act on based on the config. Then get the suitable Route or RouteDefinition from camel context and check whether you can advice or share information to the route according.
ModelCamelContext modelContext;
modelContext.getRouteDefinition(String routeId) or modelContext.getRoute(String routeId)

Change Spring configuraton on runtime

I need to use two different properties in Spring application-context.xml file depending on the database that is used in the application.
Are there any way to change a property in the Spring context depending on java.sql.DatabaseMetaData before the context is initialized?
Thank you very much!:)
It's possible to refresh your context once you load data and change the configuration regarding the values from database.
See http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/context/ConfigurableApplicationContext.html#refresh--
In that case it helped to inherit from Spring configuration class, and override methods in which I need to change a parameter. Thus, change in parameters occurs in runtime.
Refreshing context doesn't fit my needs as I need to load context in the correct way the first time.

Disable Dynamic Routing capability in Camel

With Camel, it is possible to add routes dynamically to the context. And it appears the context is always passed as part of the exchange.
Is there a way to prevent applications from adding routes at runtime? I looked at Shiro security but did not seem to find something along those lines.
the only thing I can think of is to wrap interactions with these applications using POJO Bean Binding which only passes the body of the Exhchange around and limits access to the Exchange directly...
see http://camel.apache.org/bean-binding.html
Maybe you can extend DefaultContext and add security rule in that.

Per installation configuration for SalesForce Application

I want my SalesForce Application to behave differently depending on a value that's set per environment. The value can be one of two values at present and will result in a different page being loaded and a different object instance being updated by the page.
Where would be the best place to store this? A single instance of a custom object? Or is there a dedicated store for this? Ideally the value could be updated using the Api so that a we can updated it without having to get clients to do it.
Sounds to me like you want to use a Custom Setting — these are similar to objects but setup exactly for this kind of thing, and they can even be done in a hierarchy such that different settings are used for different users.
Help for custom settings is here (must be logged in) and reference docs are here.

Resources