File Component - Implementing onCompletionExceptionHandler for older versions

2016-01-06 Thread calyan.bandi
Hi,

Below is the warning that is received due to an exception at any time during
processing of a file. This basically does a rollback of the entire file and
it starts to read again. 

WARN thread #0 - [GenericFileOnCompletion] Rollback file strategy:
org.apache.camel.component.file.strategy.GenericFileDeleteProcessStrategy@41a7d9e7
for file: G

I am trying to override the class GenericFileOnCompletion and handle the
methods onComplete() and onFailure() and few other methods provided in it. I
am not sure how i can attach my class to the file end point in the route as
i see no option provided for camel version 2.13.2.

I can see in the documentation that a new file consumer option
"onCompletionExceptionHandler" is provided to handle any thrown exceptions
but this is in the newer version of camel (2.16.2). 

I also believe that an option should be provided for the file component
which would say either true or false i.e., if an exception occur during
processing, a rollback should happen or it shouldn't. By having this option
end users can simply control the behaviour on the URI itself...something
like below.



Thanks,
Kalyan





--
View this message in context: 
http://camel.465427.n5.nabble.com/File-Component-Implementing-onCompletionExceptionHandler-for-older-versions-tp5775863.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel Stream caching unable to capture the entire stream

2015-12-16 Thread calyan.bandi
Hi,

I found the anwer to the problem in apache cxf forums. 

http://cxf.547215.n5.nabble.com/How-to-increase-the-max-size-of-a-REST-response-td563077.html

This is more of a issue in the CXF component than camel. But still for
referene, i am sharing this information. 

At the server side, we saw the below response headers for each of the
requests.

ID: 2
Response-Code: 200
Content-Type: application/json
Headers: {Content-Type=[application/json], Date=[Wed, 16 Dec 2015 11:21:34
GMT]}
Messages: Outbound Message (saved to tmp file):
Filename: C:\Users\Temp\cxf-tmp-309797\cos8635606649006238176tmp
(message truncated to 65536 bytes)

And from the client logs, whatever the payload that is received from the
server, we are seeing only the first chunk in the logs (calculated the
response payload size from the logs and it is 65536 bytes). This is only a
concern during logging and in my camel routes at the client side the entire
response is getting unmarshalled from JSON and things are working fine.  

Thanks,
Kalyan



--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-Stream-caching-unable-to-capture-the-entire-stream-tp5775055p5775145.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Camel Stream caching unable to capture the entire stream

2015-12-14 Thread calyan.bandi
Hi,

I have a camel route which invokes a webservice, and tries to processes the
response. I am using cxfrs component for the invocation. The response i am
receiving is very huge and hence most of the content is removed from the
end. 

To remedy this, i am using stream caching -
org.apache.camel.spi.StreamCachingStrategy. These options are not helping me
in the route as i still see that the response is not fully captured and the
end of the response is getting purged. Below are the settings i am using the
camel context and the streamCache is enabled per route. I have tried to set
the streamCache value per route and on the whole context, it didn't make any
difference. Hence i am setting this value per route.





30




And in the logs i can see the settings being applied as:
[main] 2015-12-14 06:47:22 INFO  AbstractCamelContextFactoryBean:892 - Using
custom StreamCachingStrategy:
DefaultStreamCachingStrategy[spoolDirectory=/home/testing/tmp,
spoolChiper=null, spoolThreshold=131072, spoolUsedHeapMemoryThreshold=30,
bufferSize=4096, anySpoolRules=false]
[main] 2015-12-14 06:47:22 INFO  CamelContextFactoryBean:273 - Bridging
Camel and Spring property placeholder configurer with id:
bridgePropertyPlaceholder
[main] 2015-12-14 06:47:22 INFO  SpringCamelContext:1637 - Apache Camel
2.13.2 (CamelContext: context) is starting
[main] 2015-12-14 06:47:22 INFO  ManagedManagementStrategy:187 - JMX is
enabled
[main] 2015-12-14 06:47:22 INFO  DefaultTypeConverter:50 - Loaded 206 type
converters
[main] 2015-12-14 06:47:23 INFO  SpringCamelContext:1831 -
AllowUseOriginalMessage is enabled. If access to the original message is not
needed, then its recommended to turn this option off as it may improve
performance.
[main] 2015-12-14 06:47:23 INFO  DefaultStreamCachingStrategy:314 -
StreamCaching in use with spool directory: /home/testing/tmp and rules:
[Spool > 128K body size, Spool > 30% used of Max heap memory]
 

I ran a java utility seperately to capture the entire response with which i
captured the full JSON response and the size of the entire string is around
71172 bytes. 

Any pointers around this issue, kindly suggest.

Thanks,
Kalyan




--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-Stream-caching-unable-to-capture-the-entire-stream-tp5775055.html
Sent from the Camel - Users mailing list archive at Nabble.com.


How do you define the camel ProducerTemplate?

2015-11-26 Thread calyan.bandi
Hi,

I have been going through the redhat documentation for camel and see that
the definiton of a ProducerTemplate is described as 

"The producer template supports a variety of different approaches to
invoking producer endpoints. There are methods that support different
formats for the request message "

Isn't a producer template is used to produce messages into a route? i.e., to
a consumer endpoint. How can a producer template be used / defined as an
entity to produce messages to a producer endpoint itself? Can someone please
elaborate?


Link:
https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Fuse/6.2/html/Apache_Camel_Development_Guide/Templates.html#Templates-Producer

Note - I am not sure if this is the right forum to raise this question as
the content i am referring to is related to redhat documentation for fuse
product.

Thanks,
Kalyan 



--
View this message in context: 
http://camel.465427.n5.nabble.com/How-do-you-define-the-camel-ProducerTemplate-tp5774460.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How do I pass on my query parameters?

2015-11-26 Thread calyan.bandi
Hi,

The query parameters does not directly get added as headers to your camel
exchange. They will be added as key value pairs to the exchange header
"CamelHttpQuery" and "CamelHttpPath". Please take a look at my post to see
how it works.

https://onegoodexample.wordpress.com/2015/07/28/camel-cxfrs-and-multiple-pathparam-and-queryparam-arguments/


Thanks,
Kalyan



--
View this message in context: 
http://camel.465427.n5.nabble.com/How-do-I-pass-on-my-query-parameters-tp5774413p5774459.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: file component - file producer - setting file permissions

2015-11-19 Thread calyan.bandi
Thank you claus. It works as expected.

Regards,
Kalyan



--
View this message in context: 
http://camel.465427.n5.nabble.com/file-component-file-producer-setting-file-permissions-tp5774036p5774100.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Spring-ws response when using split/aggregate

2015-11-19 Thread calyan.bandi
Hi,

You may need to provide the reply aggregation strategy in the split() method
itself. It should be something like below. Also i doubt that the MEP needs
to be set before splitting.

  split(new MyExpression(), new
SoapAttachmentAggregationStrategy());

I recently worked on a similar thing, and we were sending data via direct
component. We got the aggregated response back to the caller. I had used
scatter-gatherer EIP for this to work.

Thanks,
Kalyan



--
View this message in context: 
http://camel.465427.n5.nabble.com/Spring-ws-response-when-using-split-aggregate-tp5773994p5774103.html
Sent from the Camel - Users mailing list archive at Nabble.com.


file component - file producer - setting file permissions

2015-11-18 Thread calyan.bandi
Hi,

I have a requirement where in my route creates a file and writes some data
into it. The file is getting created successfully with default permissions
which is 0600. I want the file permissions to be changed to 0777 so that
applications running for different users can also have their hands on this
file. 

I know that from in Camel 2.15.x version, 'chmod' option has been introduced
on the file producer component, but we are not using this version in our
project. How can i achieve this in 2.13.x version?

Thanks,
Kalyan



--
View this message in context: 
http://camel.465427.n5.nabble.com/file-component-file-producer-setting-file-permissions-tp5774036.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How to read XML Payload

2015-11-06 Thread calyan.bandi
Hi,

Thanks everyone for giving their suggestions. I was able to solve this using
xslt component in a camel-loop . I am giving the route here just for your
reference:

 


count(/PricePlans/Body/customer)   


CamelLoopIndex 



${header.loopIndex}++





 

In my XSLT, i am making use of the header "custIndex" to reach out to each
customer node. The XSLT looks as below. I was able to achieve this with the
feature provided in XSLT component which is "all headers are added as
parameters which are available in the XSLT". 

http://www.w3.org/1999/XSL/Transform;>
























 



What bothers me here is the use of header values twice in the route. This is
because the camel's loop property 'CamelLoopIndex' starts with zero and i
cannot pass this directly into the XSLT file. The alternative way of doing
this via message translator looks good but i haven't tried it. Any ways, the
code is working now :)

Regards,
Kalyan



--
View this message in context: 
http://camel.465427.n5.nabble.com/How-to-read-XML-Payload-tp5773337p5773431.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How to read XML Payload

2015-11-04 Thread calyan.bandi
Hi Henry,

I tried both the options XPath and tokenize. But they didn't give me the
desired results. The route is defined as below:




 /PricePlans/Body/customer
 



The output that i receive from the XPath split is only the customer tag as
shown below. 


...


I need the meta-data information in the original XML file to be passed on in
the output XML. I even tried with the  as shown below but no
luck.



Thanks,
Kalyan



--
View this message in context: 
http://camel.465427.n5.nabble.com/How-to-read-XML-Payload-tp5773337p5773368.html
Sent from the Camel - Users mailing list archive at Nabble.com.


How to read XML Payload

2015-11-03 Thread calyan.bandi
Hi, 

Could someone please provide me the syntax for reading the XML payload with
only the relevant tags. My input XML contains data as below:



 ...


 
 
 
 
 
 
 
 
 



I need to split the input XML and do custom processing for each individual
customer. The XML after splitting should look as below i.e., from the entire
XML i should split only the 'customer' tags contained in the Body and the
non-body tags should remain untouched and added to the output XML. 



 ...


 
 
 




Any thoughts, please share.

Thanks,
Kalyan



--
View this message in context: 
http://camel.465427.n5.nabble.com/How-to-read-XML-Payload-tp5773337.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How to access payload from REST 404 reply in cxfrs?

2015-11-03 Thread calyan.bandi
Hi,

I am not sure if its works, but you can try enabling the option streamCache
on the route from which the web service is invoked. When using cxfrs
component with trace/debug enabled the payload (stream) received from server
is flushed once it is displayed - be it in logs or in your application. In
order to preserve it you can enable stream caching on the route.

Thanks,
Kalyan



--
View this message in context: 
http://camel.465427.n5.nabble.com/How-to-access-payload-from-REST-404-reply-in-cxfrs-tp5773325p5773336.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Bindy dataformat usage in Spring v/s Java DSL

2015-10-21 Thread calyan.bandi
Hi,

I am working on a camel route that reads an excel and does some processing.
I had this written in Spring DSL as shown below.



   


In the processor, the exchange body i received is
java.util.ArrayList. Using a simple iterator i was able to do my
processing. 

List orders = exchange.getIn().getBody(List.class);
for(Order order : orders)
{
  // simply reading the order object and doing processing
}


Recently, we moved to Java DSL and the code looks as below and below is how
we have our route written.

DataFormat bindy = new BindyCsvDataFormat("org.examples.camel.model");

from("file:csv?fileName=orders1.csv=true")
.unmarshal(bindy)
.process(new Processor() {
.
 });

The exchange body that i have received in my processor is of type:
java.util.ArrayList>

Why is there a difference in the way the exchange body is created in both
the cases? The camel documentation for bindy data format -
http://camel.apache.org/bindy.html also tells that the exchange body will be
of type List> but this is not the case with Spring
DSL. 

Thanks,
Kalyan



--
View this message in context: 
http://camel.465427.n5.nabble.com/Bindy-dataformat-usage-in-Spring-v-s-Java-DSL-tp5772940.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Apache Camel bean parameter binding issue with Spring DSL

2015-10-03 Thread calyan.bandi
Hi,

You may try one of the below two approaches:

1. Redefine your method signature and use the Bean annotations.

public void transformBodyUsingStyleSheet(Exchange exchange,
@Header("organizationStyleSheet") String styleSheet)
{
 ..
}

2. If the above didn't work, modify the bean delcaration in your xml file as
below and have the method signature in java to hold the Header annotation. 


This will ensure that camel will apply its internal rules to match the exact
method with the signatures provided in the method. 

I have a similar use case in my project and both the approaches worked well
for me. I am using camel version of 2.13.2

Thanks,
Kalyan



--
View this message in context: 
http://camel.465427.n5.nabble.com/Apache-Camel-bean-parameter-binding-issue-with-Spring-DSL-tp5772200p5772208.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: cxf endpoint configuration in java DSL

2015-10-03 Thread calyan.bandi
Hi,

I do not think that the below initialization would listen for the requests
on the url provided in the SERVICE_ADDRESS. 

CxfEndpoint serviceEndpoint = new CxfEndpoint(SERVICE_ADDRESS,
cxfComponent);

You initialize the CxfEndpoint with the required properties. If you want to
use it as a producer, you use it as below:
from("...")
.to("soapClientEndpoint");
When used in the to() section, camel will know that you are trying to make
use of the producer capability of the cxf endpoint and hence would make a
SOAP/REST request to the URI provided.

And if you use it in the from() section then it would listen for any
incoming SOAP/REST requests.

Thanks,
Kalyan



--
View this message in context: 
http://camel.465427.n5.nabble.com/cxf-endpoint-configuration-in-java-DSL-tp5771538p5772217.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: onCompletion / exchange.isFailed() does not 'see' exception.

2015-09-23 Thread calyan.bandi
Hi,

Hope the below gives a better understanding to the users.

There are two properties provided when dealing with exceptions - continued
and handled.

1. handled - Again this property can be set with either true/false.
TRUE:
Do not send it further down the route.
No exception sent back to the caller.
FALSE:
Do not send it further down the route.
Exception is sent back to the caller.

2. continued - In the onException clause one can set this property with
either true/false.
TRUE:
Send it further down the route
No exception sent back to the caller.
FALSE:
Do not send it further down the route
Exception is sent back to the caller.
   

The property continued is a new addition from V2.x+ as the documentation
says. 


Thanks,
Kalyan






--
View this message in context: 
http://camel.465427.n5.nabble.com/onCompletion-exchange-isFailed-does-not-see-exception-tp5771110p5771866.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Processing response from REST service - cxfrs client component

2015-09-23 Thread calyan.bandi
Hi,

Option "streamCache" can be set on the route in order to capture and buffer
the received inputstream and not to close it. Just use the option as
specified below:


...
...




First time developers who are working with cxfrs component will find this
very annoying unless they are aware of this streaming feature provided by
camel. I can see that this has been well documented for jetty component but
not for cxfrs component. 

Thanks,
Kalyan



--
View this message in context: 
http://camel.465427.n5.nabble.com/Processing-response-from-REST-service-cxfrs-client-component-tp5770935p5771868.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: cxf endpoint configuration in java DSL

2015-09-23 Thread calyan.bandi
Hi,

There is no such namespache as "camel-cxf". You should remove this and use
something like below:



If there is indeed a namespace such as "camel-cxf" it should be added in
your beans tag definition.

Thanks,
Kalyan



--
View this message in context: 
http://camel.465427.n5.nabble.com/cxf-endpoint-configuration-in-java-DSL-tp5771538p5771865.html
Sent from the Camel - Users mailing list archive at Nabble.com.


camel http v/s cxfrs component to consume REST service

2015-08-19 Thread calyan.bandi
Hi,

I am trying to consume a REST webservice using the cxfrs component. The code
looks as below:

cxf:rsClient id=restClient 
address=http://localhost:8080/camel-cxf-rest/webapi/myapp/hello/greet;
serviceClass=org.examples.camel.camel_cxfrs_client.HelloWorldIntf
cxf:features
ref bean=cxfLoggingFeature /
/cxf:features
cxf:providers
bean 
class=org.codehaus.jackson.jaxrs.JacksonJsonProvider/bean
/cxf:providers
/cxf:rsClient

And the corresponding route is as follows. From my java program i am
invoking this route which invokes the service and i am able to see the
response.

route
from uri=direct:start /
setHeader headerName=CamelHttpMethod
camel:constantGET/camel:constant
/setHeader
to uri=cxfrs:bean:restClient?synchronous=true /
convertBodyTo type=java.lang.String /
log message=response received from service is.${body} / 
process ref=responseProcessor /
/route

In the console output i can see the following output:

ID: 1
Response-Code: 200
Encoding: ISO-8859-1
Content-Type: text/plain
Headers: {content-type=[text/plain], Date=[Wed, 19 Aug 2015 12:18:31 GMT],
Server=[Apache-Coyote/1.1], transfer-encoding=[chunked]}
Payload: Hi There!!!
--
[  main] Tracer INFO  
(route1) cxfrs://bean:restClient?synchronous=true -- log[response received
from service is.${body}]  Pattern:InOnly,
Headers:{CamelHttpMethod=GET, BodyType:null, Body:[Body is null]
[  main] route1 INFO 
response received from service is.
[  main] Tracer INFO  
(route1) log[response received from service is.${body}] --
ref:responseProcessor  Pattern:InOnly, Headers:{CamelHttpMethod=GET,
BodyType:null, Body:[Body is null]


As you can see i am getting my response from the Web service in the Payload
part. It is a simple GET request that returns a string - Hi There!!!. I am
trying to display the same using the ${body} in the log component,  but what
i am getting is null Body and the BodyType too is set to null.

I tried the same using camel http component. The route looks as below:
   route
from uri=direct:start /
log message=invoking the rest service /
setHeader headerName=CamelHttpMethod
camel:constantGET/camel:constant
/setHeader
to uri=http://localhost:8080/camel-cxf-rest/webapi/myapp/hello/greet;
/  

log message=response received from service is.${body} / 
process ref=responseProcessor /
/route


Console Output looks as below.

[ main] Tracer INFO   (route1) from(direct://start) -- log[invoking the
rest service]  Pattern:InOnly, Headers: BodyType:null, Body:[Body is
null]
[ main] route1 INFO  invoking the rest service
[ main] Tracer INFO   (route1) log[invoking the rest service] --
setHeader[CamelHttpMethod]  Pattern:InOnly, Headers: BodyType:null,
Body:[Body is null]
[ main] Tracer INFO   (route1) setHeader[CamelHttpMethod] --
http://localhost:8080/camel-cxf-rest/webapi/myapp/hello/greet 
Pattern:InOnly, Headers:{CamelHttpMethod=GET}, BodyType:null, Body:[Body is
null]
[ main] Tracer INFO   (route1)
http://localhost:8080/camel-cxf-rest/webapi/myapp/hello/greet --
log[response received from service is.${body}]  Pattern:InOnly,
Headers:{Content-Type=text/plain, CamelHttpResponseCode=200,
Server=Apache-Coyote/1.1, Transfer-Encoding=chunked, CamelHttpMethod=GET,
Date=Wed, 19 Aug 2015 12:22:56 GMT},
BodyType:org.apache.camel.converter.stream.CachedOutputStream.WrappedInputStream,
Body:[Body is instance of java.io.InputStream]
[ main] route1 INFO  response received from service is.Hi There!!!



Using http component, i am able to capture the response in the ${body} which
i can use further down in the route. I looked into the documentatino for the
cxfrs component to understand the behavior of the rs:Client module but it is
of less use. 

Can some body please provide some explaination on the below points.  

1) Why is it that for cxfrs component the payload was not set in the message
body? 
2) Any advantages/disadvantages of choosing cxfrs over http and vice-versa?
3) When using the cxfrs component, there is an option to set  httpClientAPI
to either true/false. When this value is set to true, CxfRsProducer will use
HttpClientAPI to invoke the service. What does this mean? Are there other
APIs available to invoke the service?  

Camel core and components Version - 2.13.2
CXF Version - 2.7.11

Thanks,
Kalyan





--
View this message in context: 
http://camel.465427.n5.nabble.com/camel-http-v-s-cxfrs-component-to-consume-REST-service-tp5770829.html
Sent from the Camel - Users mailing list archive at Nabble.com.