End point :start meaning in Apache camel - apache-camel

I am new to Apache camel.
Please explain me what is the meaning of iso and :start (in below code snippet) in apache camel context xml file?
There is bean with id iso defined in camel-context.xml. But, if camel route to endpoint is referring to iso bean then what is the meaning of :start?
<to uri="iso:start" />

According to the book "Camel in Action", an endpoint URI is compose of three parts, which are: a scheme, a context path and options in forms of
<Scheme>:<Context Path>?<Options>
The scheme denotes which Camel component handles that type of
endpoint
For example, if your scheme is file, then it is using camel defined file component. Base on Camel Component List, iso is not a camel-defined component. Thus, it is most likely a user-defined component and its behavior depends on the java class behind the setting.
The meaning of context path vary by scheme
The meaning of context path depends on the scheme in use. Take below 4 endpoint URI as example
file:path/to/file
ftp://localhost:21/path/to/file
jms:queue:this.is.a.queue.name
timer:t1
For file component, it act as a path. For ftp component, it act as authentication information and a path. For jms component, it act as queue name. For timer component, it act as route id.
So, the meaning of start in your endpoint depends on the iso component and you need to figure it yourself as iso component is not camel-defined component.

Related

Apache camel - How to retrieve Endpoint URIs for a given Component

I use Apache Camel 2.20x.
A camel component can be developed with a uri scheme for example "sample-component". Now the Endpoint of this component can actually extend an existing Endpoint say SQL which has uri syntax as "sql:<select query">.
Now I am listening to camel Exchange event (ExchangeSentEvent) When I retrive the uri from the event I get "sql:<select query">. But what I want is to get "sample-component". How can we achieve that. In simple terms following is the ask
How can we get all Endpoint uri schemes for a camel component.
Thanks in advance
Gk
ComponentName+Endpoint . You can see all the uri that the component will take. All camel components are named this way.There may be exceptions. also if u use intellij idea apache camel plugin it show .
examples
HttpEndpoint
TimerEndpoint
SedaEndpoint
DirectEndpoint
You can also find the consumer and producer classes of these components as follows.
HtppProducer if support HttpConsumer ..

Passing a property value across different camel Context in apache camel

How to pass properties in camel to different camel context's? My current architecture will process 4 different kind of messages (A,B,C,D) and it uses same routes for all of them only while saving it changes the DB table names based on message type, but now I have a requirement that I need to save only few values from the exchange object for a particular message. I'm thinking of setting a property in a route and message type is 'E' I'll direct that to another route. but how do I pass the property value to different camel context
I don't know if you mean application properties (such as in Java property files) or an Exchange property as in Camels Exchange object to wrap a message.
However, it sounds like the latter since application properties are normally not passed around.
Exchange properties are just part of the Camel wrapper around a message during processing. If you send a message during route processing to another endpoint as with .to(endpoint), normally only the message is sent and the Exchange is thrown away.
from(endpoint)
.setProperty("myProperty", value)
.to("activemq:queue:myQueue")
// myProperty is no more available at myQueue
There are of course exceptions, it depends on the endpoint type. For example when sending to direct endpoints (synchronous Camel in-memory endpoint), the Exchange survives. But direct endpoints do not work across different Camel contexts. For other endpoint types like HTTP, JMS etc the properties are lost.
Therefore, if you want to set a "message variable" that is passed to other endpoints, especially across different Camel contexts, you have to set a message header.
from(endpoint)
.setHeader("myHeader", value)
.to("activemq:queue:myQueue")
// myHeader is still available at myQueue

Using header, body, and property in Apache Camel

When do I use the following syntax in Apache Camel? I have used in a sample, but don't understand the exact use of it.
exchange.setProperty("xx","xx");
exchange.getIn().setHeader("YY","YY");
exchange.getIn().setBody("ZZ")
Properties are something that related to the message itself and can be passed between routes.
Headers are often converted to/from protocol headers or affect external communication. The rule is mostly:
Metadata related to message that is used only inside routes - properties
Metadata related to some protocol (like HTTP/JMS headers etc) which is outside for routes - headers

camel: error handling during route startup

Looking for some help handling the error conditions that may occur during camel route(s) startup in a context. We are using java dsl to create routes after reading a configuration. when one of the configuration is wrong (e.g. missing host name in sftp uri. runtime discovery of error in this case), all subsequent routes are not even started by camel. What we are trying to achieve is, log an error for faulty case and proceed with subsequent route.
Is there any interceptor for same?
I would need more information to provide you with a more exact answer; however, it looks like you should be able to use the onException clause as part of RouteBuilder configuration. Here is an excerpt from the JBoss Camel guide:
Scopes
The onException clauses can be effective in either of the following scopes:
RouteBuilder scope—onException clauses defined as standalone statements inside a RouteBuilder.configure() method affect all of the routes defined in that RouteBuilder instance. On the other hand, these onException clauses have no effect whatsoever on routes defined inside any other RouteBuilder instance. The onException clauses must appear before the route definitions.
All of the examples up to this point are defined using the RouteBuilder scope.
Route scope—onException clauses can also be embedded directly within a route. These onException clauses affect only the route in which they are defined.
https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Fuse/6.1/html-single/Apache_Camel_Development_Guide/#BasicPrinciples-ExceptionHandling

Apache Camel: Keeping routing information completely independent of the Java Code

First of all thanks to folks who are currently involved in the development of Camel, I am grateful for all the hard work they have put in.
I am looking for some design advice.
The architecture is something like this:
I have a bunch of Java classes which when instantiated are required to connect to each other and send messages using Apache Camel. The design constraints require me to create a framework such that all routing information, producers, consumers, endpoints etc should be a part of the camel-context.xml.
An individual should have the capability to modify such a file and completely change the existing route without having the Java code available to him.(The Java code would not be provided, only the compiled Jar would be)
For example in One setup,
Bean A ->Bean B->Bean C->file->email.
in another
Bean B->Bean A->Bean C->ftp->file->email
We have tried various approached, but if the originating bean is not implemented as a Java DSL, the messages rate is very high because camel constantly invokes Bean A in the first example and Bean B in the second(they being the source).
Bean A and Bean B originate messages and are event driven. In case the required event occurs, the beans send out a notification message.
My transformations are very simple and I do not require the power of Java DSL at all.
To summarize, I have the following questions:
1) Considering the above constraints, I do I ensure all routing information, including destination addresses, everything is a part of the camel context file?
2) Are there example I can look at for keeping the routing information completely independent of the java code?
3) How do I ensure Camel does not constantly invoke the originating bean?
4) Does Camel constantly invoke just the originating bean or any bean it sends & messages to irrespective of the position of the bean in the entire messaging queue?
I have run out of options trying various ways to set this up. Any help would be appreciated.
Read about hiding the middleware on the Camel wiki pages. This allows you to let clients use an interface to send/receive messages but totally unaware of Camel (no Camel API used at all).
Even better consider buying the Camel in Action book and read chapter 14 which talks about this.
http://www.manning.com/ibsen/
Save 41% on Manning books: Camel in Action or ActiveMQ in Action. Use code s2941. Expires 6th oct. http://www.manning.com/ibsen/
If you consider using ServiceMix of FuseESB, you might want to separate your routes in two parts.
First part would be the Event-driver bean that trigger the route. It could push messages to the ServiceNMR (see http://camel.apache.org/nmr.html).
The other part would be left to the framework users, using Spring DSL. It would just listen to message on the NMR (push by the other route) and do whatever they want with it.
Of course endpoint definition could be propertized using servicemix configuration service (see http://camel.apache.org/properties.html#Properties-UsingBlueprintpropertyplaceholderwithCamelroutes)

Resources