camel-exec : No endpoint could be found error - apache-camel

Below is the consumer endpoint. Trying to execute linux/unix command using camel exec process uri.
<recipientList>
<simple>exec:bash?args=-c CFTUTIL SEND IDF=${property[cftFlowIdentifier]}, PART=${property[cftParterName]}, FNAME=${property[cftFullFilePath]}, FNAME=${property[cftDestinationPath]}/${property[cftFileName]}</simple>
</recipientList>
Above endpoint resulting in below error..
org.apache.camel.NoSuchEndpointException: No endpoint could be found for: PART=
Kindly check if there is anything wrong in invoking above command using camel exec uri. Same command is getting executed successfully in normal java program.

Recipient List EIP accepts comma separated list of endpoints. If you need to use comma in URL, then disable or use another delimiter.
<recipientList delimiter="false">
<simple>...</simple>
</recipientList>
You can also switch to To D EIP, which is more suitable for your needs, as you call just one endpoint.
<toD uri="exec:bash?args=-c CFTUTIL SEND IDF=${property[cftFlowIdentifier]}, PART=${property[cftParterName]}, FNAME=${property[cftFullFilePath]}, FNAME=${property[cftDestinationPath]}/${property[cftFileName]}"/>

Related

splitResults option shows unknown in apache camel google-sheets-stream component

I'm using apache camel google-sheets-stream component to read google sheet and it is working fine, but I want to split the body into rows and columns, there is an option called "splitResults" given in camel doc, but when I'm using that option it throws "unknown parameters" error.
Does anybody have any idea about this?
Below is my camel route:
from uri="google-sheets-stream://spreadsheets?accessToken=MY_TOKEN_HERE&clientId=MY_CLIENT_ID&clientSecret=MY_CLIENT_SECRET&applicationName=CamelGoogleApp&refreshToken=1/zwgy73W-pcNoCtbOxs_t4b0&spreadsheetId=1hkw_0oOaQDIRZVX_19LpywE&range=Form Responses 1"
Camel Doc that I followed :
https://github.com/apache/camel/blob/master/components/camel-google-sheets/src/main/docs/google-sheets-stream-component.adoc
Camel google-sheet Version: 2.24.1
Log:
There are 1 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{splitResults=true}]
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:209)
at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:1143)
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3729)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3443)
at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:209)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3251)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3247)

Exchange body substring in log message

How to log exchange body substring as message attribute of log component?
I have tried these:
<log message="SEND RESPONSE TO WEB SERVICE: Headers:[${headers}]\nBody:[${bodyAs(String).substring(0,1000)}]"/>
<log message="SEND RESPONSE TO WEB SERVICE: Headers:[${headers}]\nBody:[${body.toString().substring(0,1000)}]"/>
but none works. First variant is marked as mistake by IDE Camel plugin and does not allow application to start, and the second one throws the exception about calling toString() at null (although body is not).
ps body is really instance of String.
Read this page, particularly the section "Full Customization of the Logged Output"

Apache Camel route with no "to" endpoint

I am using Apache Camel to assist with capturing message data emitted by a third party software package. In this particular instance, I only need to capture what is produced by the software, there is no receiver on the other end (really no "end" to go to).
So, I tried to set up a route with just the "from" endpoint and no "to" endpoint. Apparently this is incorrect usage as I received the following exception:
[2018-08-15 11:08:03.205] ERROR: string.Launcher:191 - Exception
org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>> From[mina:udp://localhost:9877?sync=false] <<< in route: Route(route1)[[From[mina:udp://localhost:9877?sync=false]] -... because of Route route1 has no output processors. You need to add outputs to the route such as to("log:foo").
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1063)
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:196)
at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:974)
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3301)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3024)
at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:175)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2854)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2850)
at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2873)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2850)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2819)
at {removed}.Launcher.startCamel(Launcher.java:189)
at {removed}.Launcher.main(Launcher.java:125)
Caused by: java.lang.IllegalArgumentException: Route route1 has no output processors. You need to add outputs to the route such as to("log:foo").
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1061)
... 13 more
How do I set up a camel route that allows me to intercept (capture) the message traffic coming from the source, and not send it "to" anything? There is no need for a receiver. What would be an appropriate "to" endpoint that just drops everything it receives?
The exception suggestion of to("log:foo"). What does this do?
You can see if the Stub component can help
http://camel.apache.org/stub.html
Example:
from("...")
.to("stub:nowhere");
The exception suggestion of to("log:foo"). What does this do?
It sends your route messages to an endpoint with a component of type log:
(http://camel.apache.org/log.html) - component which basically dumps message contents (body and/or headers and/or properties) to your log file using appropriate log category.
If you just want to drop everything received, it's a good choice:
to("log:com.company.camel.sample?level=TRACE&showAll=true&multiline=true")
Apparently if you're under Linux or Unix, you can also redirect to /dev/null like in this example:
to( "file:/dev?fileName=null")
I am not sure it can be used on Windows but I don't think so.
Note that the syntax: to( "file:/dev/null") does not work as it point to a directory called null but with the fileName option it will work.

Camel Routing Config File with Query Params

I have a '.route' file for a rest service that works, it has the resource in the middle of the URI:
<from uri='restlet:/foo/{id}/bar
This works just fine, I am able to retrieve the 'id' in code using:
String id = e.getIn().getHeader("id", String.class);
Now, I want a '.route' with a URI with a query parameter in it.
I tried a bunch of ways, like:
<from uri='restlet:/foo/baz?color={aColor}
But this does not work, I get a 404 error, the server cannot find the URI.
This seems to be a very easy/general thing, anybody know how to do this?
I looked over the docs, but I cannot figure out how to do it.
All params follow after the question mark receive as the camel options(for example restletMethod, connectionTimeout.... see http://camel.apache.org/restlet.html). Just use <from uri='restlet:/foo/{id}/bar in your route, pass the parameters in query like a http://localhost:8080/mywebapp/rs/foo/1234/bar?color=red and get it String id = e.getIn().getHeader("color", String.class);

Using smtp with recipientList in Camel

I am trying to use SMTP component inside recipientList.
.recipientList(simple("smtps://smtp.gmail.com?username=abc#gmail.com&password=RAW(abc)&to=${header.alertTo}&subject=RAW(alert)"));
When the value of ${header.alertTo} is just a single email address, this works. However, if it is comma separated list of address it throws exception.
No endpoint could be found for: def#gmail.com&subject=RAW(Alert), please check your classpath contains the needed Camel component jar. and the stracktrace is org.apache.camel.NoSuchEndpointException: No endpoint could be found for: def#gmail.com&subject=RAW(Alert), please check your classpath contains the needed Camel component jar.
at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:65)
at org.apache.camel.util.ExchangeHelper.resolveEndpoint(ExchangeHelper.java:85)
at org.apache.camel.processor.RecipientListProcessor.resolveEndpoint(RecipientListProcessor.java:223)
at org.apache.camel.processor.RecipientListProcessor.createProcessorExchangePairs(RecipientListProcessor.java:163)
at org.apache.camel.processor.MulticastProcessor.process(MulticastProcessor.java:208)
at org.apache.camel.processor.RecipientList.sendToRecipientList(RecipientList.java:153)
at org.apache.camel.processor.RecipientList.process(RecipientList.java:112)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
I was earlier using "to" to send these mails. That works fine. But later due to a change involving configurable email addresses for different routes I have to use recipientList.
You can change the delimiter char in the recipient list to something else than comma.
See the documentation for how to do that
http://camel.apache.org/recipient-list.html

Resources