Showing posts with label camel. Show all posts
Showing posts with label camel. Show all posts

Friday, August 5, 2016

How to set message headers for a apache camel restlet request

It is simple to set message headers for camel restlet request (Here we follow XML method to add those headers to a camel routing).

Following route will send a GET request to  http://192.168.1.20:8081/abcsys/services/esbInboundAdaptorServiceRest/V1.0/receiveMessage including Basic Authentication headers with username admin and password admin. A query param also get appended to the URI as http://192.168.1.20:8081/abcsys/services/esbInboundAdaptorServiceRest/V1.0/receiveMessage?message=new message

<route>

                    <!-- Set the query parameters to URI -->
                    <setHeader headerName="CamelHttpQuery">
                        <simple>message=new message</simple>
                    </setHeader>

                    <!-- Set the authentication header username for endpoint authorization -->
                    <setHeader headerName="CamelRestletLogin">
                        <simple>admin</simple>
                    </setHeader>

                    <!-- Set the authorization header password for endpoint authorization -->
                    <setHeader headerName="CamelRestletPassword">
                        <simple>admin</simple>
                    </setHeader>

                    <to
                        uri="restlet:http://192.168.1.20:8081/abcsys/services/esbInboundAdaptorServiceRest/V1.0/receiveMessage" />


</route>

Refer this for possible lists of headers that can be set to restlet requests.

Friday, July 22, 2016

Camel installing dependencies

[Note : Following content is related to a Apache-servicemix-7.0.0.M2 test setup]


When we are creating routing with Camel, we may need to install dependencies to Camel.
As an example if we have created a mail sending route and deploy it in a fresh camel installation, you may get a error like following:

2016-07-22 14:50:35,439 | ERROR | rint Extender: 2 | BlueprintContainerImpl           | 28 - org.apache.aries.blueprint.core - 1.6.1 | Unable to start blueprint container for bundle blueprint.jms/0.0.1.SNAPSHOT due to unresolved dependencies [(&(component=smtps)(objectClass=org.apache.camel.spi.ComponentResolver))]
java.util.concurrent.TimeoutException
    at org.apache.aries.blueprint.container.BlueprintContainerImpl$1.run(BlueprintContainerImpl.java:371)[28:org.apache.aries.blueprint.core:1.6.1]
    at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)[28:org.apache.aries.blueprint.core:1.6.1]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_79]
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)[:1.7.0_79]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)[:1.7.0_79]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)[:1.7.0_79]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_79]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_79]
    at java.lang.Thread.run(Thread.java:745)[:1.7.0_79]
 


It is because we have not installed a feature called "mail" as a dependency for Camel. There are several dependencies available. We can display them by typing karaf@root>feature:install camel-  and tab.

We can install those dependencies with following command.
karaf@root>feature:install camel-mail  

Now issue should be resolved.