Content Enrich Error when upgrading Apache Camel from 2.9.2 to any higher version

2012-12-17 Thread Neo
)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)   at
org.apache.camel.processor.Pipeline.process(Pipeline.java:80)   at
org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at
org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)
at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)
at
org.apache.camel.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:48)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at
org.apache.camel.component.seda.SedaConsumer.sendToConsumers(SedaConsumer.java:275)
at org.apache.camel.component.seda.SedaConsumer.doRun(SedaConsumer.java:183)
at org.apache.camel.component.seda.SedaConsumer.run(SedaConsumer.java:139)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
... 1 moreCaused by: java.lang.NullPointerException at
org.apache.camel.component.http.RequestEntityConverter.toRequestEntity(RequestEntityConverter.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597) at
org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:923)  ...
50 more]

Can some one please throw light on this issue ? I went through all the
release notes in Camel 2.9.3 and 2.9.4 , didnt really get any pointers. I
tried changing my code to call the service with no HTTP_QUERY parameters (
but I did embed them directly in the HTTP_URI - but no change same
exception.

Can anyone please provide me some light :) ??Cheers,Sree



--
View this message in context: 
http://camel.465427.n5.nabble.com/Content-Enrich-Error-when-upgrading-Apache-Camel-from-2-9-2-to-any-higher-version-tp5724244.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Content Enrich Error when upgrading Apache Camel from 2.9.2 to any higher version

2012-12-17 Thread Willem jiang
:99)
 at
 org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
 at
 org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)
 at
 org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
 at
 org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:334)
 at
 org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:220)
 at
 org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
 at
 org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
 at
 org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)
 at
 org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
 at org.apache.camel.processor.Pipeline.process(Pipeline.java:117) at
 org.apache.camel.processor.Pipeline.process(Pipeline.java:80) at
 org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
 at
 org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
 at
 org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)
 at
 org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)
 at
 org.apache.camel.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:48)
 at
 org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
 at
 org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
 at
 org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
 at
 org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
 at
 org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73)
 at
 org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
 at
 org.apache.camel.component.seda.SedaConsumer.sendToConsumers(SedaConsumer.java:275)
 at org.apache.camel.component.seda.SedaConsumer.doRun(SedaConsumer.java:183)
 at org.apache.camel.component.seda.SedaConsumer.run(SedaConsumer.java:139)
 at
 java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
 at
 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
 ... 1 moreCaused by: java.lang.NullPointerException at
 org.apache.camel.component.http.RequestEntityConverter.toRequestEntity(RequestEntityConverter.java:51)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597) at
 org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:923) ...
 50 more]
  
 Can some one please throw light on this issue ? I went through all the
 release notes in Camel 2.9.3 and 2.9.4 , didnt really get any pointers. I
 tried changing my code to call the service with no HTTP_QUERY parameters (
 but I did embed them directly in the HTTP_URI - but no change same
 exception.
  
 Can anyone please provide me some light :) ??Cheers,Sree
  
  
  
 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Content-Enrich-Error-when-upgrading-Apache-Camel-from-2-9-2-to-any-higher-version-tp5724244.html
 Sent from the Camel - Users mailing list archive at Nabble.com 
 (http://Nabble.com).





Re: Content enrich via WS

2012-05-17 Thread Christian Müller
My recommendation:

from(direct:start)
  .enrich(direct:sub, MyAggregationStrategy()) // see [1] and [2]
  .to(direct:end);

from(direct:sub)
  .convertBodyTo(WebServiceRequest.class) // see [3]
  .to(cxf:bean:SomeWebService);

The MyAggregationStrategy.aggregate(Exchange oldExchange, Exchange
newExchange) is called with the oldExchange which contains your original
message (oldExchange.getIn()) and with the newExchange which contains the
response of the web service you called (newExchange.getIn()). Than you can
merge or whatever you want with both exchanges.

[1] http://camel.apache.org/content-enricher.html
[2]
http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/processor/aggregate/AggregationStrategy.html
[3] http://camel.apache.org/type-converter.html

Best,
Christian

On Thu, May 17, 2012 at 3:52 AM, Willem Jiang willem.ji...@gmail.comwrote:

 You can put your XML message into exchange as property, it will be copy
 across the endpoints.
 And you can extract the ID, and send it to a camel-cxf[1] endpoint without
 create the entire SOAP message yourself.

 Then you need to put all these information back in your custom bean[2].

 [1]http://camel.apache.org/**cxf.html http://camel.apache.org/cxf.html
 [2]http://camel.apache.org/**bean.html http://camel.apache.org/bean.html


 On Wed May 16 22:32:38 2012, pvunckx wrote:

 Case:
 I receive an XML message who contains a lot of data, one of the fields is
 an
 ID of a person.
 Via this ID (and only this ID) I need to construct a SOAP message to make
 a
 WS-call who will return extra information that I need to merge with the
 initial (!!) message.


 I support I have to use the ‘enrich’ method
 1/ But for the uri what do I need to use ? A CXF uri ?
 2/ I can construct a message for the CXF WS but doesn’t I lose that way
 the
 original message ? Which I still need to do the merge (Of how do I get
 this
 message back?)

 Pseudo-code:
  From (“direct:start’)
   .transform() //convert xml msg to xml msg for first ws call
   .enrich (uri, strategy)  //uri ? , strategy  can I access the initial
 msg?
 .to(cxf-ws);//call second ws with enrich initial msg

 Thanks for tips and tricks!!
 Pieter


 --
 View this message in context: http://camel.465427.n5.nabble.**
 com/Content-enrich-via-WS-**tp5710911.htmlhttp://camel.465427.n5.nabble.com/Content-enrich-via-WS-tp5710911.html
 Sent from the Camel - Users mailing list archive at Nabble.com.




 --
 Willem
 --**
 CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
 FuseSource
 Web: http://www.fusesource.com
 Blog:
 http://willemjiang.blogspot.**comhttp://willemjiang.blogspot.com(English)
http://jnn.javaeye.com (Chinese)
 Twitter: willemjiang
 Weibo: willemjiang




Content enrich via WS

2012-05-16 Thread pvunckx
Case:
I receive an XML message who contains a lot of data, one of the fields is an
ID of a person.
Via this ID (and only this ID) I need to construct a SOAP message to make a
WS-call who will return extra information that I need to merge with the
initial (!!) message.


I support I have to use the ‘enrich’ method 
1/ But for the uri what do I need to use ? A CXF uri ? 
2/ I can construct a message for the CXF WS but doesn’t I lose that way the
original message ? Which I still need to do the merge (Of how do I get this
message back?)

Pseudo-code:
From (“direct:start’)
  .transform() //convert xml msg to xml msg for first ws call
  .enrich (uri, strategy)  //uri ? , strategy  can I access the initial
msg?
.to(cxf-ws);//call second ws with enrich initial msg

Thanks for tips and tricks!!
Pieter


--
View this message in context: 
http://camel.465427.n5.nabble.com/Content-enrich-via-WS-tp5710911.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Content enrich via WS

2012-05-16 Thread Willem Jiang
You can put your XML message into exchange as property, it will be copy 
across the endpoints.
And you can extract the ID, and send it to a camel-cxf[1] endpoint 
without create the entire SOAP message yourself.


Then you need to put all these information back in your custom bean[2].

[1]http://camel.apache.org/cxf.html
[2]http://camel.apache.org/bean.html

On Wed May 16 22:32:38 2012, pvunckx wrote:

Case:
I receive an XML message who contains a lot of data, one of the fields is an
ID of a person.
Via this ID (and only this ID) I need to construct a SOAP message to make a
WS-call who will return extra information that I need to merge with the
initial (!!) message.


I support I have to use the ‘enrich’ method
1/ But for the uri what do I need to use ? A CXF uri ?
2/ I can construct a message for the CXF WS but doesn’t I lose that way the
original message ? Which I still need to do the merge (Of how do I get this
message back?)

Pseudo-code:
 From (“direct:start’)
   .transform() //convert xml msg to xml msg for first ws call
   .enrich (uri, strategy)  //uri ? , strategy  can I access the initial
msg?
.to(cxf-ws);//call second ws with enrich initial msg

Thanks for tips and tricks!!
Pieter


--
View this message in context: 
http://camel.465427.n5.nabble.com/Content-enrich-via-WS-tp5710911.html
Sent from the Camel - Users mailing list archive at Nabble.com.





--
Willem
--
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Web: http://www.fusesource.com
Blog:http://willemjiang.blogspot.com (English)
http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang



Re: content-enrich

2009-03-03 Thread Martin Krasser
... just updated the enricher documentation with an example aggregation 
strategy.


Martin

Peter Maas schrieb:


On Mar 3, 2009, at 8:10 , Claus Ibsen wrote:


On Tue, Mar 3, 2009 at 7:56 AM, Peter Maas pfmm...@gmail.com wrote:
I think you've solved my problem. I was looking at the 'in' message 
of the
resource exchange, whereas I should be looking at the 'out' message. 
And,
btw, yes the CinemaQueryAssembler is thread-safe, I actually think 
all code

should be threadsafe ;)

Yeah if we could just got some basic annotations in the JDK, eg
@ThreadSafe then you could document it like that :)

Maybe we need to improve the wiki for using the enricher to state you
should check the OUT for the response.
http://camel.apache.org/content-enricher.html


Yeah, I actually think the documentation of the content-enricher is 
quite sparse, a simple example AggregationStrategy might help a lot:



public class ProgramMerger implements AggregationStrategy {

public Exchange aggregate(Exchange original, Exchange resource) {

Document org = original.getIn().getBody(Document.class);
Document additional = resource.getOut().getBody(Document.class);

   
// create the new 'enriched' message

Document result = ...;
original.getOut().setBody(result);
   
return original;

}

}





On Tue, Mar 3, 2009 at 7:02 AM, Martin Krasser 
d...@martin-krasser.dewrote:



Hi Peter,

the route looks good to me.

* The in-messages of the original exchange and the resource 
exchange are
always identical. The out-message of the resource exchange will 
contain the

result from 'direct:enrichMovie'.
* What message exchange pattern do you use when you test (print the
contents of) the 'direct:enrichMovie' route?
* Is the CinemaQueryAssembler thread-safe? You're doing parallel 
processing

of split messages.

Martin

Peter Maas schrieb:

 Hi list,


I'm developing a proof-of-concept application using Camel 2.0. 
Everything

seems to work just find... except for the content-enricher. Both the
resource exchange passed to my AggregationStrategy look identical. 
Whilst if
I print the contents of the resource route I the the correct xml 
in the

exchange after calling the http service. My routes look like this:

   // split messages when received from the incoming mq
   // enrich if move. Always stor in database
   from(activemq:topic:incomingVPROGuide)
   
.split(vpro.xpath(//vpro:program)).parallelProcessing(true)

   .choice()
   .when(vpro.xpath(/vpro:progr...@ismovie = 'true']))
   .enrich(direct:enrichMovie, new ProgramMerger())
   .to(direct:save)
   .otherwise().to(direct:save);
   // the generic save route
   from(direct:save)
   .setHeader(xmldb.resource.name,
vpro.xpath(//vpro:program/@id, String.class))
   .process(sanitize(xmldb.resource.name))
   .to(xmldb:/programs);
 // route to retrieve data from external
   // rest service
   from(direct:enrichMovie)
   .setHeader(title,
vpro.xpath(/vpro:program/vpro:title[1]/text(), String.class))
   .setHeader(director, vpro.xpath(//vpro:pers...@urn =
'urn:mpeg:mpeg7:cs:RoleCS:2001:DIRECTOR' and 
1]/vpro:familyName/text(),

String.class))
   .setHeader(year, vpro.xpath(//vpro:year[1]/text(),
String.class))
   .process(new CinemaQueryAssembler())
   
.to(http://cinema.test.vpro.nl/api/1/rest/movie/find.xml;);


The xmldb producer is a patched version of the camel-extra project.
Everything works fine, apart from the enricher...

Any hints?

kind regards,

Peter Maas










--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/







Re: content-enrich

2009-03-02 Thread Martin Krasser

Hi Peter,

the route looks good to me.

* The in-messages of the original exchange and the resource exchange are 
always identical. The out-message of the resource exchange will contain 
the result from 'direct:enrichMovie'.
* What message exchange pattern do you use when you test (print the 
contents of) the 'direct:enrichMovie' route?
* Is the CinemaQueryAssembler thread-safe? You're doing parallel 
processing of split messages.


Martin

Peter Maas schrieb:

Hi list,

I'm developing a proof-of-concept application using Camel 2.0. 
Everything seems to work just find... except for the content-enricher. 
Both the resource exchange passed to my AggregationStrategy look 
identical. Whilst if I print the contents of the resource route I the 
the correct xml in the exchange after calling the http service. My 
routes look like this:


// split messages when received from the incoming mq
// enrich if move. Always stor in database
from(activemq:topic:incomingVPROGuide)
.split(vpro.xpath(//vpro:program)).parallelProcessing(true)
.choice()
.when(vpro.xpath(/vpro:progr...@ismovie = 'true']))   
.enrich(direct:enrichMovie, new ProgramMerger())

.to(direct:save)
.otherwise().to(direct:save);

// the generic save route

from(direct:save)
.setHeader(xmldb.resource.name, 
vpro.xpath(//vpro:program/@id, String.class))

.process(sanitize(xmldb.resource.name))
.to(xmldb:/programs);
   
// route to retrieve data from external

// rest service
from(direct:enrichMovie)
.setHeader(title, 
vpro.xpath(/vpro:program/vpro:title[1]/text(), String.class))
.setHeader(director, vpro.xpath(//vpro:pers...@urn = 
'urn:mpeg:mpeg7:cs:RoleCS:2001:DIRECTOR' and 
1]/vpro:familyName/text(), String.class))
.setHeader(year, vpro.xpath(//vpro:year[1]/text(), 
String.class))

.process(new CinemaQueryAssembler())
.to(http://cinema.test.vpro.nl/api/1/rest/movie/find.xml;);

The xmldb producer is a patched version of the camel-extra project. 
Everything works fine, apart from the enricher...


Any hints?

kind regards,

Peter Maas