using useSystemProperties for apache camel http component - apache-camel

According to apache camel document
useSystemProperties could be used as query param for http component like below shown
https://URL ?useSystemProperties=true
But I want to use do it via API(method) way. Is it possible and how?
Thanks in advance

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 ..

Bridging http request with path variable in CAMEL REST

I am trying to bridge Camel REST endpoints to a backend server. Corresponding REST DSL is as follows:
from("rest:get:tt:/{id}")
.toF("%s/%s?bridgeEndpoint=true","http://192.168.1.1:80","jjjj/llll/pppp/{id}");
My expectation is that the request should be forwarded to http://192.168.1.1:80/jjjj/llll/pppp/id But what actually happens is that the request gets forwarded to http://192.168.1.1:80/jjjj/llll/pppp/%7Bid%7D/tt/id
Can any one suggest, what am I doing wrong and how I can achieve the desired behaviour? I am using Spring Boot Camel 2.3.4 which uses Camel 3.5.0 internally.
Mean while, I have found a work around that to use .to() instead of .toF(). With .to(), I achieved desired behavior. Camel route DSL is Something like
from("rest:get:tt:/{id}").to("rest:get:jjjj/llll/pppp/{id}?host=http://192.168.1.1:80")
But question still remains open that why it is not working with .toF().
Seems like you're using {id} syntax for http component uri, but I think it's only recognized by the rest component, so instead of having:
from("rest:get:tt:/{id}")
.toF("%s/%s?bridgeEndpoint=true", "http://192.168.1.1:80", "jjjj/llll/pppp/{id}");
you could try using dynamic endpoint .toD() with simple expression ${header.id}:
from("rest:get:tt:/{id}")
.toD("http://192.168.1.1:80/jjjj/llll/pppp/${header.id}?bridgeEndpoint=true");
Not exactly sure if that's what you're aiming for though

How to inject query parameters using camel REST DSL?

Actually I am playing with apache-camel 2.15.2, the REST DSL available since Camel 2.14 is not complicated. However I can't find in the official documentation how to retrieve a query parameter, basically I would like to target my REST service in this way:
http://myServer/myService/myMethod?myQueryParam=myValue
Is that possible, or is there any workaround ?
Thanks in advance.
Camel uses the REST/HTTP component of choice (restlet, jetty, servlet, netty-http, spark-rest, etc) which maps query parameters as Camel message headers.
So yes you can with the rest-dsl exposes a REST service where clients can call it with query parameters, which is then mapped to Camel message headers during routing.

Apache camel to invoke ejb 2

Can I use apache camel to invoke remote ejbs (ejb2.0)? How do I pass parameters to these ejsb? The example given on the camel website is not very clear. Also I'm not using spring. Can someone please help?
To call remote EJBs you can just use Java code, and let Camel call your java code.
If you want to try the camel-ejb component, then you need to configure the component for remote EJBs which is not so easy - there is a JIRA ticket to improve this in a future release.
So I suggest to just use Java code - eg just call these remote EJBs as you would do from regular Java code without using Apache Camel.

Using Apache Camel ProducerTemplate to send JSON message to ActiveMQ

I have a camel route setup like the following to send a java object to an activemq queue.
from("direct:clientRequest")
.marshal().json(JsonLibrary.Jackson)
.to("activemq:queue:command");
I want to do the following:
Map the "clientRequest" uri to some Java method
Use ProducerTemplate's "sendBody" method to send a JSON form of a Java object to the activemq queue.
Is this possible?
I am asking this question after a lot of homework. Please suggest a way to do this.
You can use pojo producing in Apache Camel. See this page for more details
http://camel.apache.org/pojo-producing.html
And there is an example that shows more about using pojo producing/consuming in Camel
http://camel.apache.org/pojo-messaging-example.html

Resources