Access Camel exchange property in XML DSL - apache-camel

Assuming I have set a Camel exchange property in a Processor ...Example
exchange.setProperty(LASTPROCESSED, sortedBody[0].attribute6)
What would be the proper way of referencing this property in my XML based route ?
I tried ${property:LASTPROCESSED} and ${exchangeProperty:LASTPROCESSED}
I have no trouble referencing exchange Headers ( i.e. ${headers.xxx} )
Yes ...I have trolled through countless answers here without finding a solution.
I am running Camel 3.x

Turns out I had an issue elsewhere in the Route ...the proper way to access appears to be ${exchangeProperty.xxx}

Related

How to set route node properties?

While monitoring an Apache Camel application with hawt.io, I noticed that the nodes of a camel route have some properties that I cannot influence with the Java DSL, but which are displayed in hawt.io. It would be pretty awesome if you could define them anyway.
I am particularly interested in the id and the description of a node in the route. My route currently looks something like this (screenshot below):
My route
rabbitmq://tso11
log4
process4
to3
process5
to4
The displayed names (log4, process4, process5, ...) are automatically generated "id" properties. There is also an always empty property "description".
It would be awesome if I could change this somehow for a much better readable route:
My route
rabbitmq://tso11
log incoming message
process for header extraction
to xslt processor additional-mappint.xslt
process for conversion to nms42 format
to nms42 endpoint
Maybe there is a way? Maybe only with XML based DSL?
Here is a screenshot:
In Java DSL, you can set the id of a node thanks to the method id(String id).
In the next example, the id of the endpoint mock:bar has been set to bar:
from("direct:start")
.to("mock:foo")
.to("mock:bar").id("bar")
.to("mock:result");

Apache Camel - Mybatis select with parameters and useIterator

I'm trying to use Apache Camel (version 2.20.0) with mybatis component.
More specifically, I have to export a large set or record from database to file.
I'd like to prevent memory issues so I want to use the option consumer.useIterator. My route is:
from("mybatis:selectItemsByDate?statementType=SelectList&consumer.useIterator=true")
.split()
.body()
.process(doSomething)
to(file:my-path-file);
but my query has in input a parameter (the starting date to get data). How should I set this parameter?
In many example on internet I saw the parameter in the body or in the header of the Exchange message but I think is possibile only if the mybatis endpoint is in a "to" method. But the option "consumer.useIterator" is working only when the enpdoint is in a "from" method.
Please help me to understand how I can set the input for my query or if this is not supported yet (in this case if you can give some hint how to implement would be great)
thank you.
Then you need to start your route from something else, like a timer or direct endpoint, and then call the mybatis endpoint in a to, where you have set that information in the message body/header you use in the mybatis query so its dynamic.
Also you should set the splitter to be in streaming mode so it walks the iterator it gets from mybatis on-demand.

Camel Restlet - Binding query parameters to message headers

Looking through Camel docs I couldn't find any way that allow me to bind the query parameters within the headers. For example :
Let's say I have an endpoint like that
http://localhost:8080/services/resource?filter=xxx
End I want to get that parameter from the header
exchange.getIn.().getHeaders().get('filter')
The query parameter 'filter' is not returned in the header. Anyone of you knows if this feature is coming by default in camel? I know I can build the binding by myself, but i am just looking for choose among camel-servlet (apparently that binding is implemented by default) and camel-restlet.
If you choose camel-restlet you can use the
restletBinding=#refName
to convert the query string parameters to headers.
The #refName is the bean ID of a RestletBinding object in the Camel Registry.

Bug in Camel 2.13.2 Release-Bud Id 7544

The XSD allows to specify customId="true" id="foo" in the route elements. But when reading the route using Spring you get a parse error in Spring. I can't able to understand this bug. Can you please clarify me?
You should not use customId but only id.
The customId is for internal usage when updating routes from XML that the id is auto assigned or assigned by the end user.

Solrj Block Join Bean support

I would like to use a Solrj Bean to save/query nested documents from Solr. Is this possible? I see that since version 4.5 it is possible to use addChildDocument(SolrInputDocument child) but looking at the source code for org.apache.solr.client.solrj.beans.DocumentObjectBinder I see that nested documents are not taken into consideration. A new annotation additional to the #Field annotation would also be required I guess. Does anyone have any experience with this?
If you want to insert nested document as a bean to solr using #Field(child=true) annotation then see below URL:
SOLRJ-6.0.0: Insertion of a bean object which associate list of bean object is giving null pointer exception

Resources