Re: Is onFinally() compulsory after doCatch()?
Check out the link I already sent to you [1]. [1] http://camel.apache.org/try-catch-finally.html Best, Christian - Software Integration Specialist Apache Camel committer: https://camel.apache.org/team V.P. Apache Camel: https://www.apache.org/foundation/ Apache Member: https://www.apache.org/foundation/members.html https://www.linkedin.com/pub/christian-mueller/11/551/642 On Tue, Jul 2, 2013 at 7:50 AM, Tarun Kumar agrawal.taru...@gmail.comwrote: my route looks like this: from(). .toTry().process() .doCatch(Exception.class) .to().to().process() .end() My questions are: 1. is .doFinally compulsory after doCatch()? 2. In my case, how does route know whether second .to() in line 4 is inside doCatch() or after doCatch()? 3. I am using cxfrs component, why is my exchange body not being returned back to caller. Caller is seeing 204 no content found. While, when i remove doTry and doCatch() with same code, caller is able to see proper response (exchange body, status and all). Why is that?
Re: Is onFinally() compulsory after doCatch()?
Above link doesn't answer my second ques. Could you please help? On Tue, Jul 2, 2013 at 12:41 PM, Christian Müller christian.muel...@gmail.com wrote: Check out the link I already sent to you [1]. [1] http://camel.apache.org/try-catch-finally.html Best, Christian - Software Integration Specialist Apache Camel committer: https://camel.apache.org/team V.P. Apache Camel: https://www.apache.org/foundation/ Apache Member: https://www.apache.org/foundation/members.html https://www.linkedin.com/pub/christian-mueller/11/551/642 On Tue, Jul 2, 2013 at 7:50 AM, Tarun Kumar agrawal.taru...@gmail.com wrote: my route looks like this: from(). .toTry().process() .doCatch(Exception.class) .to().to().process() .end() My questions are: 1. is .doFinally compulsory after doCatch()? 2. In my case, how does route know whether second .to() in line 4 is inside doCatch() or after doCatch()? 3. I am using cxfrs component, why is my exchange body not being returned back to caller. Caller is seeing 204 no content found. While, when i remove doTry and doCatch() with same code, caller is able to see proper response (exchange body, status and all). Why is that?
Entity Manager is null
Hi All, I am facing issue with EntityManager being null when I access it from my Java Code. Below is my camel-context in which I am defining Entity MAnager. bean id=entityManagerFactory class=org.springframework.orm.jpa.LocalEntityManagerFactoryBean property name=persistenceUnitName value=com.baselogic.jpa / property name=jpaVendorAdapter ref=jpaAdapter / property name=jpaProperties props prop key=openjpa.ConnectionURLjdbc:sqlserver://10.10.10.11:1433;databaseName=XYZ;instanceName=SQLEXPRESS;/prop prop key=openjpa.jdbc.DBDictionaryorg.apache.openjpa.jdbc.sql.SQLServerDictionary/prop prop key=openjpa.ConnectionDriverNamecom.microsoft.sqlserver.jdbc.SQLServerDriver/prop prop key=openjpa.ConnectionUserNameuser1/prop prop key=openjpa.ConnectionPasswordpass123/prop prop key=openjpa.LogEnhance=TRACE,SQL=TRACE/prop prop key=openjpa.jdbc.SynchronizeMappingstrue/prop /props /property /bean When I am persisting data using camel route its working perfectly fine, but when I am trying to access Entity manager through code its null. @PersistenceContext(unitName = com.baselogic.jpa) private EntityManager entityManager; Can anybody tell me if I am missing anything ? Thanks, Abhi -- View this message in context: http://camel.465427.n5.nabble.com/Entity-Manager-is-null-tp5735076.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Camel routes and threads
Hello Claus, We tried using threadPool, but it did not work either.. Any suggestions? Thank you Regards Vaibhav A. Karkhanis -- View this message in context: http://camel.465427.n5.nabble.com/Camel-routes-and-threads-tp5734326p5735077.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Camel in Master/Slave ActiveMQ config
All fyi - after some testing I went ahead with the approach suggested below http://camel.465427.n5.nabble.com/How-to-make-your-camel-routes-highly-available-when-only-one-may-be-active-at-a-time-td4984581.html#a4988271 http://www.liquid-reality.de/display/liquid/2011/11/11/Hot+Standby+failover+for+Apache+Camel+routes Only catch seems to be a connections exclusively used for holding the lock. Which should be ok. regards, Deepak. -- View this message in context: http://camel.465427.n5.nabble.com/Camel-in-Master-Slave-ActiveMQ-config-tp5734804p5735078.html Sent from the Camel - Users mailing list archive at Nabble.com.
logging to different (dynamic) appenders
Hi, I would like to define the name of a logger in a camel header variable. Unfortunately this doesn't seem to work. Example: .from(...) .log( LoggingLevel.INFO, mylogger, MyMessage ) .to(...) is working as expected, whereas .from(...) .setHeader( logger, constant(mylogger)) .log( LoggingLevel.INFO, ${header.logger}, MyMessage ) .to(...) is not ! Isn't that possible or do I understand something wrong ? Workarounds available ? Thanks for help in advance. -- View this message in context: http://camel.465427.n5.nabble.com/logging-to-different-dynamic-appenders-tp5735080.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Bug in org.apache.camel.main.Main#doStop() ?
I opened a bug report: https://issues.apache.org/jira/browse/CAMEL-6504 On 06/28/13 12:10, Christian Müller wrote: I cannot look into the code yet, but I think this should be fixed. Feel free to create a JIRA. Best, Christian Sent from a mobile device Am 28.06.2013 10:54 schrieb Sven Bauhan sven.bau...@ast.dfs.de: Hi, I think I found a bug in org.apache.camel.main.Main#**doStop(): When I call a Camel application with parameter -h all parameters are printed an the program exits. But it is no clean exit; it throws an java.lang.** IndexOutOfBoundsException. The reason for this is the expression in doStop(): + getCamelContexts().get(0).**stop(); I implemented a workaround in my class derived from org.apache.camel.main.Main: + @Override protected void doStop() throws Exception { List? contexts = getCamelContexts(); if (contexts != null ! contexts.isEmpty()) { super.doStop(); } else { completed(); } } Is this a real bug, or did I just use org.apache.camel.main.Main the wrong way? Thanks, Sven
Re: Entity Manager is null
Which version of Spring are you using? How did you use PersistenceContext? Maybe the class that you want to inject the EntityManager is not managed by Spring. -- Willem Jiang Red Hat, Inc. FuseSource is now part of Red Hat Web: http://www.fusesource.com | http://www.redhat.com Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English) http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese) Twitter: willemjiang Weibo: 姜宁willem On Tuesday, July 2, 2013 at 5:31 PM, abhi wrote: Hi All, I am facing issue with EntityManager being null when I access it from my Java Code. Below is my camel-context in which I am defining Entity MAnager. bean id=entityManagerFactory class=org.springframework.orm.jpa.LocalEntityManagerFactoryBean property name=persistenceUnitName value=com.baselogic.jpa / property name=jpaVendorAdapter ref=jpaAdapter / property name=jpaProperties props prop key=openjpa.ConnectionURLjdbc:sqlserver://10.10.10.11:1433;databaseName=XYZ;instanceName=SQLEXPRESS;/prop prop key=openjpa.jdbc.DBDictionaryorg.apache.openjpa.jdbc.sql.SQLServerDictionary/prop prop key=openjpa.ConnectionDriverNamecom.microsoft.sqlserver.jdbc.SQLServerDriver/prop prop key=openjpa.ConnectionUserNameuser1/prop prop key=openjpa.ConnectionPasswordpass123/prop prop key=openjpa.LogEnhance=TRACE,SQL=TRACE/prop prop key=openjpa.jdbc.SynchronizeMappingstrue/prop /props /property /bean When I am persisting data using camel route its working perfectly fine, but when I am trying to access Entity manager through code its null. @PersistenceContext(unitName = com.baselogic.jpa) private EntityManager entityManager; Can anybody tell me if I am missing anything ? Thanks, Abhi -- View this message in context: http://camel.465427.n5.nabble.com/Entity-Manager-is-null-tp5735076.html Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).
FileAsyncStressReadLockLockFileTest and maxMessagePerPoll
Can you explain a little bit more this comment in org.apache.camel.component.file.stress.FileAsyncStressReadLockLockFileTest? // leverage the fact that we can limit to max 50 files per poll // this will result in polling again and potentially picking up files // that already are in progress Is it safer to have a bigger or smaller maxMessagePerPoll in order to avoid picking files that are already in process? Is there a way to guaranty that a file will never be picked twice? -- View this message in context: http://camel.465427.n5.nabble.com/FileAsyncStressReadLockLockFileTest-and-maxMessagePerPoll-tp5735083.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Why is the file component parameter, consumer.regexPattern not recognized?
Bilgin, Thanks for that - I was always assuming file2 meant additionally added. I ended up using include=regex, as suggested in file2.html. Thanks, Chris On Wed, Jun 26, 2013 at 7:40 PM, Bilgin Ibryam bibr...@gmail.com wrote: Hi Chris, are you using Camel 1.x? As it says in the documentation, for Camel 2.x, the doc page of file component is http://camel.apache.org/file2.html Bilgin On 26 June 2013 22:24, Chris Wolf cwolf.a...@gmail.com wrote: ResolveEndpointFailedException: Failed to resolve endpoint: file://src/test/data?consumer.regexPattern=.*uu%24noop=true due to: There are 1 parameters that couldn't be set on the endpoint consumer. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown consumer parameters=[{regexPattern=.*uu$}] I copypasted the parameter name directly from the doc page: http://camel.apache.org/file.html Thanks, Chris
Re: Problem with DefaultCamelContext EndpointRegistry
Claus, Thanks, but the fact that attempting to add another instance of the same Endpoint type results in the name getting and instance number appended means that some consideration must have been given to accommodating multiple instances of the same Endpoint in the registry, right? In any case, I gave up on the idea of writing a custom component to solve the dynamic consumer problem and instead, create consumer routes, at runtime, with static consumer URIs, which solves my problem. Thanks, Chris On Fri, Jun 14, 2013 at 7:16 AM, Claus Ibsen claus.ib...@gmail.com wrote: Only singleton endpoints should be in the registry. Non singleton is prototype based and therefore a new instance is created when you call getEndpoint. On Wed, Jun 12, 2013 at 7:41 PM, Chris Wolf cwolf.a...@gmail.com wrote: Ok, have a partial answer - since my Endpoint is not a singleton, I see that DefaultCamelContext.getEndpointKey(String uri, Endpoint endpoint) appends that %3A2 - i.e. :2 - which appears to be an instance qualifier. The trouble is, DefaultEndpoint.getEndpointUri() will always return the URI *without* that instance qualifier, so it won;t be found in the endpoint registry. Is there an example of a Component whose Endpoint is not a singleton, that I can look at? Or are non-singleton Endpoints some new, untested feature? Thanks, Chris On Wed, Jun 12, 2013 at 3:28 PM, Chris Wolf cwolf.a...@gmail.com wrote: I am trying to develop a new component, but it needs to be able to have it's endpoint be registered in the CamelContext endpoint registry. Whenever the runtime tries to call DefaultCamelContext.getEndpoint(String uri) it returns null, even though, in the debugger, I can expand DefaultCamelContext.endpoints.map ...and see that, for sure, the endpoint is in the registry, except the key now has %3A2 appended, so of course, the EndpointKey, which looks like: dsftp://localhost:21000?binary=truedirectory=target%2Fres%2Fhomefilter=%23cpmdFileFilteridempotent=truelocalWorkDirectory=target%2Fres%2Ftmp%2Flocalmove=archive%2F%24%7Bfile%3Aname%7Dpassword=adpt5separator=UNIXusername=adpt5 ...won't match, so that explains why DefaultCamelContext.getEndpoint(String uri) returns null. DefaultCamelContext.endpoints.map: (other entries removed for clarity) {dsftp://localhost:21000binary=truedirectory=target%2Fres%2Fhomefilter=%23cpmdFileFilteridempotent=truelocalWorkDirectory=target%2Fres%2Ftmp%2Flocalmove=archive%2F%24%7Bfile%3Aname%7Dpassword=adpt5separator=UNIXusername=adpt5%3A2=java.lang.ref.SoftReference@f7e5307} *** So why does the key in the endpoints.map have %3A2 appended to it? *** Thanks, Chris -- Claus Ibsen - www.camelone.org: The open source integration conference. Red Hat, Inc. FuseSource is now part of Red Hat Email: cib...@redhat.com Web: http://fusesource.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen
Re: Cannot get filter() to work with mandatoryBodyAs
Christian - this was a user error on my part and I forgot that I could/should just overwrite and replace the in body of the exchange, in which case, I didn't need to filter out the no-longer-needed upstream message body. Thanks, Chris On Tue, Jun 11, 2013 at 11:19 AM, Christian Müller christian.muel...@gmail.com wrote: Can you try .filter(simple(${mandatoryBodyAs(org.apache.camel.component.file.remote.RemoteFile)}))? Best, Christian Müller - Software Integration Specialist Apache Camel committer: https://camel.apache.org/team V.P. Apache Camel: https://www.apache.org/foundation/ Apache Member: https://www.apache.org/foundation/members.html https://www.linkedin.com/pub/christian-mueller/11/551/642 On Tue, Jun 11, 2013 at 4:12 PM, Chris Wolf cwolf.a...@gmail.com wrote: I want to impose a filter such that only messages whose body is of type RemoteFile get through, So per the documentation: http://camel.apache.org/message-filter.html http://camel.apache.org/predicate.html http://camel.apache.org/simple.html I have: .filter(simple(${mandatoryBodyAs(RemoteFile.class)})) But I get: org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[Message: {}] at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1332) at org.apache.camel.builder.ExpressionBuilder$33.evaluate(ExpressionBuilder.java:781) at org.apache.camel.support.ExpressionAdapter.evaluate(ExpressionAdapter.java:36) at org.apache.camel.support.ExpressionSupport.matches(ExpressionSupport.java:32) at org.apache.camel.util.ExpressionToPredicateAdapter.matches(ExpressionToPredicateAdapter.java:32) at org.apache.camel.builder.SimpleBuilder.matches(SimpleBuilder.java:75) at org.apache.camel.processor.FilterProcessor.process(FilterProcessor.java:47) [] Caused by: java.lang.ClassNotFoundException: RemoteFile.class at org.apache.camel.impl.DefaultClassResolver.resolveMandatoryClass(DefaultClassResolver.java:52) at org.apache.camel.builder.ExpressionBuilder$33.evaluate(ExpressionBuilder.java:779) ... 67 more ...even though I imported RemoteFile. So then I tried: .filter(simple(${mandatoryBodyAs(org.apache.camel.component.file.remote.RemoteFile.class)})) and I get the same ClassNotFoundException, but with the full classname. How can I filter messages, such that only messages whose in-body is non-null and of a certain type get through? Thanks, Chris
Chunking issue with http producer
I've got a back-end web service returning large **chunked** data. I have defined a Camel route with a proxy to this web service. I do not want Camel to buffer the entire back-end response, and then return it as a whole to the client. Instead, i would like to preserve the original streaming (mainly to avoid read timeouts on the client side). How can i achieve this (a pipe actually) in Camel ? Even when I disable streamCache on CamelContext, it seems Camel is yet buffering internally the response. Hereunder the difference between a direct call to the back-end, and the same call via Camel: http://camel.465427.n5.nabble.com/file/n5735075/difference.png = see Latency ! In the first case, client gets a beginning of response after 2 sec, while in the second case, he has to wait for 12 sec before getting any data... I looked into the code of HttpProducer.java, and I'm a bit puzzled about what i can see in the doExtractResponseBodyAsStream method: private static InputStream doExtractResponseBodyAsStream(InputStream is, Exchange exchange) throws IOException { // As httpclient is using a AutoCloseInputStream, it will be closed when the connection is closed // we need to cache the stream for it. try { // This CachedOutputStream will not be closed when the exchange is onCompletion CachedOutputStream cos = new CachedOutputStream(exchange, false); IOHelper.copy(is, cos); // When the InputStream is closed, the CachedOutputStream will be closed return cos.getWrappedInputStream(); } finally { IOHelper.close(is, Extracting response body, LOG); } } If you always *copy* the stream, you need to read the whole stream :-( Where do you take account of the streamCache flag when deciding to cache or not cache the response input stream ? Thanks for your help. Bernard. -- View this message in context: http://camel.465427.n5.nabble.com/Chunking-issue-with-http-producer-tp5735075.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Is onFinally() compulsory after doCatch()?
The end() marks when doCatch ends. So all the stuff in between is inside the doCatch. On Tue, Jul 2, 2013 at 12:36 PM, Tarun Kumar agrawal.taru...@gmail.com wrote: Above link doesn't answer my second ques. Could you please help? On Tue, Jul 2, 2013 at 12:41 PM, Christian Müller christian.muel...@gmail.com wrote: Check out the link I already sent to you [1]. [1] http://camel.apache.org/try-catch-finally.html Best, Christian - Software Integration Specialist Apache Camel committer: https://camel.apache.org/team V.P. Apache Camel: https://www.apache.org/foundation/ Apache Member: https://www.apache.org/foundation/members.html https://www.linkedin.com/pub/christian-mueller/11/551/642 On Tue, Jul 2, 2013 at 7:50 AM, Tarun Kumar agrawal.taru...@gmail.com wrote: my route looks like this: from(). .toTry().process() .doCatch(Exception.class) .to().to().process() .end() My questions are: 1. is .doFinally compulsory after doCatch()? 2. In my case, how does route know whether second .to() in line 4 is inside doCatch() or after doCatch()? 3. I am using cxfrs component, why is my exchange body not being returned back to caller. Caller is seeing 204 no content found. While, when i remove doTry and doCatch() with same code, caller is able to see proper response (exchange body, status and all). Why is that? -- Claus Ibsen - www.camelone.org: The open source integration conference. Red Hat, Inc. FuseSource is now part of Red Hat Email: cib...@redhat.com Web: http://fusesource.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen
Re: Camel CXFRS endpoint unable to produce JSON
Can i send you my maven projects ? you can take a look at it high level and see if i m really missing something basic On Mon, Jul 1, 2013 at 4:00 PM, Sergey Beryozkin-3 [via Camel] ml-node+s465427n5735057...@n5.nabble.com wrote: This is bizarre...Can you please double check the custom code you may have and see if application/xml is 'hiding somewhere' ? Can you do a sanity check and confirm it is this endpoint which is being invoked after all ? Any chance you can attach a working route (test) to JIRA ? Cheers, Sergey On 01/07/13 17:19, ajaysam wrote: application/xml always works.. even if i am saying Produces json i still get output as xml On Mon, Jul 1, 2013 at 12:01 PM, Sergey Beryozkin-3 [via Camel] [hidden email] http://user/SendEmail.jtp?type=nodenode=5735057i=0 wrote: So, if you replace all of @Produces(application/json) with @Produces(application/xml) and do curl -HAccept:application/xml ... then it works ? Sergey On 01/07/13 16:40, ajaysam wrote: I am sending the request through curl - it is setting Accept header as shown below curl -HAccept:application/json http://pocman2.nsp.stf.bms.com:8080/CXF_REST-0.0.1-SNAPSHOT/webservices/Hello/SilpaY Hello is the path to refer to resource class We are stuck in this project and any help will be appreciated. At high level this is what the project is about 1. Camel exposes a REST endpoint thru CXFRS - this part works 2. We get the request data in POJO format - camel makes SOAP call to another web service passing this POJO 3. We get the response back from that service 4. Response POJO needs to be converted to JSON As of now as a workaround in last step - we are using marshal step of camel to explicitly convert from POJO to JSON - and that works - but we dont want to do it that way We thought just doing return Response.ok(resp).build(); from Processor should work We did all the configuration required as explained in article Our resource class says @Produces MediaType.Application_JSON Also provided the json provider to cxfrs configuration Now what else needs to be done? Can i send the application-context.xml file and Resource file to you somehow..maybe i m missing something fundamental attached is the xml section - util:list id=jsonTypes valueapplication/json/value /util:list - bean id=cxfJaxrsJsonProvider class=org.apache.cxf.jaxrs.provider.json.JSONProvider property name=namespaceMap ref=jsonNamespaceMap / property name=produceMediaTypes ref=jsonTypes / /bean bean id=restResource class=com.bms.web.HelloResource / - jaxrs:server id=restService staticSubresourceResolution=true - jaxrs:serviceBeans ref bean=restResource / /jaxrs:serviceBeans - jaxrs:providers ref bean=cxfJaxrsJsonProvider / bean class=org.apache.cxf.jaxrs.provider.JAXBElementProvider / /jaxrs:providers /jaxrs:server bean id=restRespProcessor class=com.bms.web.RESTResponseProcessor / cxf:rsServer id=HelloRsServer serviceClass=com.bms.web.HelloResource loggingFeatureEnabled=true / camelContext xmlns=http://camel.apache.org/schema/spring; route id=restToSoap streamCache=true from uri=cxfrs://bean://HelloRsServer?bindingStyle=SimpleConsumer / log message= Got ${headers} / log message= Got Body 111 : ${body} / to uri=bean:reqProcessor / log message= Got Headers 222 : ${headers} / log message= Got Body 333 : ${body} / to uri=cxf:bean:target_hello/ log message= Got Body 444 : ${body} / to uri=bean:restRespProcessor / log message= Got Body 555 : ${body} / /route /camelContext the the response processor does this MessageContentsList msgList = (MessageContentsList)exchg.getIn().getBody(); GetReferenceDataResponse resp = (GetReferenceDataResponse) msgList.get(0); exchg.getOut().setBody(Response.ok(resp).build()); Resource File is @Path(/Hello) @Produces({application/json}) public class HelloResource { public HelloResource() {} @GET @Path(/{referenceTypeName}) //@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) public Response getMessage( @PathParam(referenceTypeName) String name, @QueryParam() ReferenceDataRequest query) { System.out.println(Hello, i am here !!! In HelloResource ... updated 7.1.13); return null; } } -- View this message in context: http://camel.465427.n5.nabble.com/Camel-CXFRS-endpoint-unable-to-produce-JSON-tp5734967p5735046.html Sent from the Camel - Users mailing list archive at Nabble.com. -- If you reply to this email, your message
Re: Camel CXFRS endpoint unable to produce JSON
Sure, this will help to digging into the issue. Best, Christian Sent from a mobile device Am 02.07.2013 20:19 schrieb ajaysam ajay.sam...@gmail.com: Can i send you my maven projects ? you can take a look at it high level and see if i m really missing something basic On Mon, Jul 1, 2013 at 4:00 PM, Sergey Beryozkin-3 [via Camel] ml-node+s465427n5735057...@n5.nabble.com wrote: This is bizarre...Can you please double check the custom code you may have and see if application/xml is 'hiding somewhere' ? Can you do a sanity check and confirm it is this endpoint which is being invoked after all ? Any chance you can attach a working route (test) to JIRA ? Cheers, Sergey On 01/07/13 17:19, ajaysam wrote: application/xml always works.. even if i am saying Produces json i still get output as xml On Mon, Jul 1, 2013 at 12:01 PM, Sergey Beryozkin-3 [via Camel] [hidden email] http://user/SendEmail.jtp?type=nodenode=5735057i=0 wrote: So, if you replace all of @Produces(application/json) with @Produces(application/xml) and do curl -HAccept:application/xml ... then it works ? Sergey On 01/07/13 16:40, ajaysam wrote: I am sending the request through curl - it is setting Accept header as shown below curl -HAccept:application/json http://pocman2.nsp.stf.bms.com:8080/CXF_REST-0.0.1-SNAPSHOT/webservices/Hello/SilpaY Hello is the path to refer to resource class We are stuck in this project and any help will be appreciated. At high level this is what the project is about 1. Camel exposes a REST endpoint thru CXFRS - this part works 2. We get the request data in POJO format - camel makes SOAP call to another web service passing this POJO 3. We get the response back from that service 4. Response POJO needs to be converted to JSON As of now as a workaround in last step - we are using marshal step of camel to explicitly convert from POJO to JSON - and that works - but we dont want to do it that way We thought just doing return Response.ok(resp).build(); from Processor should work We did all the configuration required as explained in article Our resource class says @Produces MediaType.Application_JSON Also provided the json provider to cxfrs configuration Now what else needs to be done? Can i send the application-context.xml file and Resource file to you somehow..maybe i m missing something fundamental attached is the xml section - util:list id=jsonTypes valueapplication/json/value /util:list - bean id=cxfJaxrsJsonProvider class=org.apache.cxf.jaxrs.provider.json.JSONProvider property name=namespaceMap ref=jsonNamespaceMap / property name=produceMediaTypes ref=jsonTypes / /bean bean id=restResource class=com.bms.web.HelloResource / - jaxrs:server id=restService staticSubresourceResolution=true - jaxrs:serviceBeans ref bean=restResource / /jaxrs:serviceBeans - jaxrs:providers ref bean=cxfJaxrsJsonProvider / bean class=org.apache.cxf.jaxrs.provider.JAXBElementProvider / /jaxrs:providers /jaxrs:server bean id=restRespProcessor class=com.bms.web.RESTResponseProcessor / cxf:rsServer id=HelloRsServer serviceClass=com.bms.web.HelloResource loggingFeatureEnabled=true / camelContext xmlns=http://camel.apache.org/schema/spring; route id=restToSoap streamCache=true from uri=cxfrs://bean://HelloRsServer?bindingStyle=SimpleConsumer / log message= Got ${headers} / log message= Got Body 111 : ${body} / to uri=bean:reqProcessor / log message= Got Headers 222 : ${headers} / log message= Got Body 333 : ${body} / to uri=cxf:bean:target_hello/ log message= Got Body 444 : ${body} / to uri=bean:restRespProcessor / log message= Got Body 555 : ${body} / /route /camelContext the the response processor does this MessageContentsList msgList = (MessageContentsList)exchg.getIn().getBody(); GetReferenceDataResponse resp = (GetReferenceDataResponse) msgList.get(0); exchg.getOut().setBody(Response.ok(resp).build()); Resource File is @Path(/Hello) @Produces({application/json}) public class HelloResource { public HelloResource() {} @GET @Path(/{referenceTypeName}) //@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) public Response getMessage( @PathParam(referenceTypeName) String name, @QueryParam() ReferenceDataRequest query) { System.out.println(Hello, i am here !!! In HelloResource ... updated 7.1.13); return null;
Re: Choice sendTo and overwriting exchange body
Hi Willem, I guessed this much. Oracle Service Bus has a service call feature out which could do callouts to internal routes without affecting the incoming message which was quite useful. I might see if I can come up with a reusable Expression that does something similar. Cheers, David -- View this message in context: http://camel.465427.n5.nabble.com/Choice-sendTo-and-overwriting-exchange-body-tp5734867p5735107.html Sent from the Camel - Users mailing list archive at Nabble.com.
Weblogic JMS Security Issues - A possible resolution
Hello all, I've been attempting to use Camel/Spring JMS with Weblogic Server (10.3.6) JMS destinations and it works just fine without secure destinations, but using secure destinations results in the exception: /weblogic.jms.common.JMSSecurityException: Access denied to resource: type=jms, application=jms_module, destinationType=queue, resource=jms_response, action=receive / It appears that others in the Camel/Spring community have had similar issues (e.g. here http://camel.465427.n5.nabble.com/JMS-message-to-Weblogic-gt-Security-Exception-Access-denied-to-resource-td1438688.html ). Since there was no reasonable solution to this problem I did some research and created a new thread factory that creates Threads with the passed-in Runnable.run proxied through a Weblogic secured PrivilegedAction. The task executor for Camel and Spring JMS listeners is modified to use the new task factory to ensure all subscribing threads are 'privileged'. I've provided some code on github https://github.com/dmacdonald2013/weblogic-jms-spring with an example/test of publishing and subscribing to a secure WebLogic JMS destination using both Camel and Spring Stand-alone. Hopefully someone else in the Camel/Spring community benefits from this (and feedback is welcome!) - we needed Camel to do some things that Oracle Service Bus just isn't cut out for and the inability to use secure destination was a big blocker. Cheers, David -- View this message in context: http://camel.465427.n5.nabble.com/Weblogic-JMS-Security-Issues-A-possible-resolution-tp5735108.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Choice sendTo and overwriting exchange body
Maybe we can add an option in sendTo DSL, to let it restore the original Exchange if the option is enabled. Please feel free to fill a JIRA for it, if you like you can share us with the solution you have. -- Willem Jiang Red Hat, Inc. FuseSource is now part of Red Hat Web: http://www.fusesource.com | http://www.redhat.com Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English) http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese) Twitter: willemjiang Weibo: 姜宁willem On Wednesday, July 3, 2013 at 8:19 AM, David MacDonald wrote: Hi Willem, I guessed this much. Oracle Service Bus has a service call feature out which could do callouts to internal routes without affecting the incoming message which was quite useful. I might see if I can come up with a reusable Expression that does something similar. Cheers, David -- View this message in context: http://camel.465427.n5.nabble.com/Choice-sendTo-and-overwriting-exchange-body-tp5734867p5735107.html Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).
Re: Chunking issue with http producer
If you are using http client 3, it will clean up the input stream when you close the connection. You can find more information by checking the the comments in the doExtractResponseBodyAsStream. That is why we need to cache the input stream as it will be used in the other part of camel route. If you disable the streamCache it doesn't affect it, but you may consider to disable cache the stream into file as the default size is 64K. -- Willem Jiang Red Hat, Inc. FuseSource is now part of Red Hat Web: http://www.fusesource.com | http://www.redhat.com Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English) http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese) Twitter: willemjiang Weibo: 姜宁willem On Tuesday, July 2, 2013 at 5:10 PM, Bernard Ligny wrote: I've got a back-end web service returning large **chunked** data. I have defined a Camel route with a proxy to this web service. I do not want Camel to buffer the entire back-end response, and then return it as a whole to the client. Instead, i would like to preserve the original streaming (mainly to avoid read timeouts on the client side). How can i achieve this (a pipe actually) in Camel ? Even when I disable streamCache on CamelContext, it seems Camel is yet buffering internally the response. Hereunder the difference between a direct call to the back-end, and the same call via Camel: http://camel.465427.n5.nabble.com/file/n5735075/difference.png = see Latency ! In the first case, client gets a beginning of response after 2 sec, while in the second case, he has to wait for 12 sec before getting any data... I looked into the code of HttpProducer.java, and I'm a bit puzzled about what i can see in the doExtractResponseBodyAsStream method: private static InputStream doExtractResponseBodyAsStream(InputStream is, Exchange exchange) throws IOException { // As httpclient is using a AutoCloseInputStream, it will be closed when the connection is closed // we need to cache the stream for it. try { // This CachedOutputStream will not be closed when the exchange is onCompletion CachedOutputStream cos = new CachedOutputStream(exchange, false); IOHelper.copy(is, cos); // When the InputStream is closed, the CachedOutputStream will be closed return cos.getWrappedInputStream(); } finally { IOHelper.close(is, Extracting response body, LOG); } } If you always *copy* the stream, you need to read the whole stream :-( Where do you take account of the streamCache flag when deciding to cache or not cache the response input stream ? Thanks for your help. Bernard. -- View this message in context: http://camel.465427.n5.nabble.com/Chunking-issue-with-http-producer-tp5735075.html Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).
Re: Bug in org.apache.camel.main.Main#doStop() ?
Hi, I just had a quick look of the code and confirmed it's a bug. I will commit a quick fix for it shortly. -- Willem Jiang Red Hat, Inc. FuseSource is now part of Red Hat Web: http://www.fusesource.com | http://www.redhat.com Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English) http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese) Twitter: willemjiang Weibo: 姜宁willem On Tuesday, July 2, 2013 at 7:42 PM, Sven Bauhan wrote: I opened a bug report: https://issues.apache.org/jira/browse/CAMEL-6504 On 06/28/13 12:10, Christian Müller wrote: I cannot look into the code yet, but I think this should be fixed. Feel free to create a JIRA. Best, Christian Sent from a mobile device Am 28.06.2013 10:54 schrieb Sven Bauhan sven.bau...@ast.dfs.de (mailto:sven.bau...@ast.dfs.de): Hi, I think I found a bug in org.apache.camel.main.Main#**doStop(): When I call a Camel application with parameter -h all parameters are printed an the program exits. But it is no clean exit; it throws an java.lang.** IndexOutOfBoundsException. The reason for this is the expression in doStop(): + getCamelContexts().get(0).**stop(); I implemented a workaround in my class derived from org.apache.camel.main.Main: + @Override protected void doStop() throws Exception { List? contexts = getCamelContexts(); if (contexts != null ! contexts.isEmpty()) { super.doStop(); } else { completed(); } } Is this a real bug, or did I just use org.apache.camel.main.Main the wrong way? Thanks, Sven
Re: Choice sendTo and overwriting exchange body
Hi Willem, I made my own ExpressionAdapter which is effectively a copy paste of ExpressionBuilder.toExpression that accepts an additional boolean for whether to (shallow) copy the exchange, i.e. Exchange toExchange = replaceExchange ? exchange : exchange.copy(); I'll raise a JIRA/code sample it soon. Cheers, David -- View this message in context: http://camel.465427.n5.nabble.com/Choice-sendTo-and-overwriting-exchange-body-tp5734867p5735120.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Is onFinally() compulsory after doCatch()?
Thanks Claus. This is not mentioned in http://camel.apache.org/try-catch-finally.html. I think it will be great if this can be added to that page. It will really help beginners like me. On Tue, Jul 2, 2013 at 11:46 PM, Claus Ibsen claus.ib...@gmail.com wrote: The end() marks when doCatch ends. So all the stuff in between is inside the doCatch. On Tue, Jul 2, 2013 at 12:36 PM, Tarun Kumar agrawal.taru...@gmail.com wrote: Above link doesn't answer my second ques. Could you please help? On Tue, Jul 2, 2013 at 12:41 PM, Christian Müller christian.muel...@gmail.com wrote: Check out the link I already sent to you [1]. [1] http://camel.apache.org/try-catch-finally.html Best, Christian - Software Integration Specialist Apache Camel committer: https://camel.apache.org/team V.P. Apache Camel: https://www.apache.org/foundation/ Apache Member: https://www.apache.org/foundation/members.html https://www.linkedin.com/pub/christian-mueller/11/551/642 On Tue, Jul 2, 2013 at 7:50 AM, Tarun Kumar agrawal.taru...@gmail.com wrote: my route looks like this: from(). .toTry().process() .doCatch(Exception.class) .to().to().process() .end() My questions are: 1. is .doFinally compulsory after doCatch()? 2. In my case, how does route know whether second .to() in line 4 is inside doCatch() or after doCatch()? 3. I am using cxfrs component, why is my exchange body not being returned back to caller. Caller is seeing 204 no content found. While, when i remove doTry and doCatch() with same code, caller is able to see proper response (exchange body, status and all). Why is that? -- Claus Ibsen - www.camelone.org: The open source integration conference. Red Hat, Inc. FuseSource is now part of Red Hat Email: cib...@redhat.com Web: http://fusesource.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen