Camel 2.1 : Error Handler Recover Original Message

2009-12-16 Thread titexe

Hello,

I would like to know the configuration of error handler  dead letter
channel to do the following:

- Recover the original message an error in the route.
- Generating an error message in a dead letter queue (with a level of debug
or error).

my definitions of roads in spring xml. And the version I use camel 2.1 and
ActiveMQ 5.3.

Thank you in advance.

titexe
-- 
View this message in context: 
http://old.nabble.com/Camel-2.1-%3A-Error-Handler---Recover-Original-Message-tp26808679p26808679.html
Sent from the Camel - Users mailing list archive at Nabble.com.



Re: Camel 2.1 : Error Handler Recover Original Message

2009-12-16 Thread Claus Ibsen
On Wed, Dec 16, 2009 at 10:49 AM, titexe tit...@yahoo.fr wrote:

 Hello,

 I would like to know the configuration of error handler  dead letter
 channel to do the following:

 - Recover the original message an error in the route.

See useOriginalMessage


 - Generating an error message in a dead letter queue (with a level of debug
 or error).



You can just use a bean or another route as dead letter queue endpoint
and do whatever you want.

See more here
http://camel.apache.org/error-handling-in-camel.html
http://camel.apache.org/dead-letter-channel.html
... and chapter 5 in the Camel in Action book


 my definitions of roads in spring xml. And the version I use camel 2.1 and
 ActiveMQ 5.3.

 Thank you in advance.

 titexe
 --
 View this message in context: 
 http://old.nabble.com/Camel-2.1-%3A-Error-Handler---Recover-Original-Message-tp26808679p26808679.html
 Sent from the Camel - Users mailing list archive at Nabble.com.





-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus


Problem with injection of endpoint (cxf - producer - camel 2.2 - osgi)

2009-12-16 Thread Charles Moulliard
The code hereafter generates an error which was not there before :

@EndpointInject(name = jms:queue:inout)
ProducerTemplate producer;

public ReportIncidentService() {
init();
}

@GET
public Incidents getIncidents() {

Incidents l = new Incidents();

// Call the distant service to get result (SYNCHR WAY)

ListIncident i = (ListIncident)
producer.requestBody(GET_INCIDENTS);
l.setIncidents(i);

return l;
}

Caused by: org.apache.cxf.interceptor.Fault: defaultEndpoint must be
specified
at
org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:155)
at
org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:121)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:130)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:82)
at
org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at
org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
at
org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
... 37 more


If I use the following method, everything works fine

ListIncident i = (ListIncident) producer.requestBody(
jms:queue:inout,GET_INCIDENTS);

Regards,

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*
blog : http://cmoulliard.blogspot.com
twitter : http://twitter.com/cmoulliard
Linkedlin : http://www.linkedin.com/in/charlesmoulliard

Apache Camel Group :
http://www.linkedin.com/groups?home=gid=2447439trk=anet_ug_hm


Re: Problem with injection of endpoint (cxf - producer - camel 2.2 - osgi)

2009-12-16 Thread Claus Ibsen
On Wed, Dec 16, 2009 at 2:14 PM, Charles Moulliard cmoulli...@gmail.com wrote:
 The code hereafter generates an error which was not there before :

   �...@endpointinject(name = jms:queue:inout)
    ProducerTemplate producer;

Use (uri = jms:queue:inout) as it appears as a uri and not a
reference to an endpoint.

We should probably add some validation (if possible) that the default
endpoint could not be resolved.




    public ReportIncidentService() {
        init();
    }

   �...@get
    public Incidents getIncidents() {

        Incidents l = new Incidents();

        // Call the distant service to get result (SYNCHR WAY)

        ListIncident i = (ListIncident)
 producer.requestBody(GET_INCIDENTS);
        l.setIncidents(i);

        return l;
    }

 Caused by: org.apache.cxf.interceptor.Fault: defaultEndpoint must be
 specified
 at
 org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:155)
 at
 org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:121)
 at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:130)
 at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:82)
 at
 org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
 at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
 at java.util.concurrent.FutureTask.run(FutureTask.java:138)
 at
 org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
 at
 org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)
 at
 org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
 ... 37 more


 If I use the following method, everything works fine

 ListIncident i = (ListIncident) producer.requestBody(
 jms:queue:inout,GET_INCIDENTS);

 Regards,

 Charles Moulliard
 Senior Enterprise Architect
 Apache Camel Committer

 *
 blog : http://cmoulliard.blogspot.com
 twitter : http://twitter.com/cmoulliard
 Linkedlin : http://www.linkedin.com/in/charlesmoulliard

 Apache Camel Group :
 http://www.linkedin.com/groups?home=gid=2447439trk=anet_ug_hm




-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus


Re: Problem with injection of endpoint (cxf - producer - camel 2.2 - osgi)

2009-12-16 Thread Charles Moulliard
This is much better now.

Thx.

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*
blog : http://cmoulliard.blogspot.com
twitter : http://twitter.com/cmoulliard
Linkedlin : http://www.linkedin.com/in/charlesmoulliard

Apache Camel Group :
http://www.linkedin.com/groups?home=gid=2447439trk=anet_ug_hm


On Wed, Dec 16, 2009 at 2:18 PM, Claus Ibsen claus.ib...@gmail.com wrote:

 On Wed, Dec 16, 2009 at 2:14 PM, Charles Moulliard cmoulli...@gmail.com
 wrote:
  The code hereafter generates an error which was not there before :
 
 @EndpointInject(name = jms:queue:inout)
 ProducerTemplate producer;

 Use (uri = jms:queue:inout) as it appears as a uri and not a
 reference to an endpoint.

 We should probably add some validation (if possible) that the default
 endpoint could not be resolved.



 
 public ReportIncidentService() {
 init();
 }
 
 @GET
 public Incidents getIncidents() {
 
 Incidents l = new Incidents();
 
 // Call the distant service to get result (SYNCHR WAY)
 
 ListIncident i = (ListIncident)
  producer.requestBody(GET_INCIDENTS);
 l.setIncidents(i);
 
 return l;
 }
 
  Caused by: org.apache.cxf.interceptor.Fault: defaultEndpoint must be
  specified
  at
 
 org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:155)
  at
 
 org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:121)
  at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:130)
  at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:82)
  at
 
 org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
  at
 java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
  at java.util.concurrent.FutureTask.run(FutureTask.java:138)
  at
 
 org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
  at
 
 org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)
  at
 
 org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
  ... 37 more
 
 
  If I use the following method, everything works fine
 
  ListIncident i = (ListIncident) producer.requestBody(
  jms:queue:inout,GET_INCIDENTS);
 
  Regards,
 
  Charles Moulliard
  Senior Enterprise Architect
  Apache Camel Committer
 
  *
  blog : http://cmoulliard.blogspot.com
  twitter : http://twitter.com/cmoulliard
  Linkedlin : http://www.linkedin.com/in/charlesmoulliard
 
  Apache Camel Group :
  http://www.linkedin.com/groups?home=gid=2447439trk=anet_ug_hm
 



 --
 Claus Ibsen
 Apache Camel Committer

 Author of Camel in Action: http://www.manning.com/ibsen/
 Open Source Integration: http://fusesource.com
 Blog: http://davsclaus.blogspot.com/
 Twitter: http://twitter.com/davsclaus



Re: Camel 2.1 : Error Handler Recover Original Message

2009-12-16 Thread titexe

thank you for your reply

you're right, it is described in Chapter 5 Camel in Action.

For cons, I still have a problem with this config, property 'endpointUri'
does not recognize, below my config:


route errorHandlerRef=myDeadLetterChannel
/route

bean id=myDeadLetterChannel
class=org.apache.camel.builder.DeadLetterChannelBuilder
property name=endpointUri value=activemq:queue:dead.original/
property name=useOriginalMessage value=true/
property name=deadLetterUri
value=activemq:queue:dead.error?level=ERROR/
/bean


Thanks in advance,

titexe


Claus Ibsen-2 wrote:
 
 On Wed, Dec 16, 2009 at 10:49 AM, titexe tit...@yahoo.fr wrote:

 Hello,

 I would like to know the configuration of error handler  dead letter
 channel to do the following:

 - Recover the original message an error in the route.
 
 See useOriginalMessage
 
 
 - Generating an error message in a dead letter queue (with a level of
 debug
 or error).

 
 
 You can just use a bean or another route as dead letter queue endpoint
 and do whatever you want.
 
 See more here
 http://camel.apache.org/error-handling-in-camel.html
 http://camel.apache.org/dead-letter-channel.html
 ... and chapter 5 in the Camel in Action book
 
 
 my definitions of roads in spring xml. And the version I use camel 2.1
 and
 ActiveMQ 5.3.

 Thank you in advance.

 titexe
 --
 View this message in context:
 http://old.nabble.com/Camel-2.1-%3A-Error-Handler---Recover-Original-Message-tp26808679p26808679.html
 Sent from the Camel - Users mailing list archive at Nabble.com.


 
 
 
 -- 
 Claus Ibsen
 Apache Camel Committer
 
 Author of Camel in Action: http://www.manning.com/ibsen/
 Open Source Integration: http://fusesource.com
 Blog: http://davsclaus.blogspot.com/
 Twitter: http://twitter.com/davsclaus
 
 

-- 
View this message in context: 
http://old.nabble.com/Camel-2.1-%3A-Error-Handler---Recover-Original-Message-tp26808679p26811087.html
Sent from the Camel - Users mailing list archive at Nabble.com.



Re: Camel 2.1 : Error Handler Recover Original Message

2009-12-16 Thread Claus Ibsen
On Wed, Dec 16, 2009 at 2:33 PM, titexe tit...@yahoo.fr wrote:

 thank you for your reply

 you're right, it is described in Chapter 5 Camel in Action.


Its just that error handling is complex and to explain and
documentation that in a way that holds hands and guides people is hard
to do with wiki pages where it get cluttered and more becomes a stack
of notes for reference.

So when the book go over this in 30 pages then I would refer to it, as
its the best we got if you want to learn how to use Camel error
handling in more details.
I am not as much trying to sell the book as such, but I dont foresee
any of us sitting down and writing a tutuorial on Camel error handling
in or spare time which would take many many hours to write.


 For cons, I still have a problem with this config, property 'endpointUri'
 does not recognize, below my config:


 route errorHandlerRef=myDeadLetterChannel
 /route

 bean id=myDeadLetterChannel
 class=org.apache.camel.builder.DeadLetterChannelBuilder
        property name=endpointUri value=activemq:queue:dead.original/
        property name=useOriginalMessage value=true/
        property name=deadLetterUri
 value=activemq:queue:dead.error?level=ERROR/
        /bean


There is no such property on the dead letter channel
property name=deadLetterUri
value=activemq:queue:dead.error?level=ERROR/

And there are no level option on the JMS component either.

You can send it to a little route instead where you can log it before
sending to JMS
deadLetterUri=direct:toDLC

from(direct:toDLC).to(log:toDLC?showCaughtException=true).to(amq:queue:dead)

BTW: ActiveMQ do have a DLQ itself and can handle redelivery itself.





 Thanks in advance,

 titexe


 Claus Ibsen-2 wrote:

 On Wed, Dec 16, 2009 at 10:49 AM, titexe tit...@yahoo.fr wrote:

 Hello,

 I would like to know the configuration of error handler  dead letter
 channel to do the following:

 - Recover the original message an error in the route.

 See useOriginalMessage


 - Generating an error message in a dead letter queue (with a level of
 debug
 or error).



 You can just use a bean or another route as dead letter queue endpoint
 and do whatever you want.

 See more here
 http://camel.apache.org/error-handling-in-camel.html
 http://camel.apache.org/dead-letter-channel.html
 ... and chapter 5 in the Camel in Action book


 my definitions of roads in spring xml. And the version I use camel 2.1
 and
 ActiveMQ 5.3.

 Thank you in advance.

 titexe
 --
 View this message in context:
 http://old.nabble.com/Camel-2.1-%3A-Error-Handler---Recover-Original-Message-tp26808679p26808679.html
 Sent from the Camel - Users mailing list archive at Nabble.com.





 --
 Claus Ibsen
 Apache Camel Committer

 Author of Camel in Action: http://www.manning.com/ibsen/
 Open Source Integration: http://fusesource.com
 Blog: http://davsclaus.blogspot.com/
 Twitter: http://twitter.com/davsclaus



 --
 View this message in context: 
 http://old.nabble.com/Camel-2.1-%3A-Error-Handler---Recover-Original-Message-tp26808679p26811087.html
 Sent from the Camel - Users mailing list archive at Nabble.com.





-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus


Re: Implementing Publish Subscribe Channel

2009-12-16 Thread Claus Ibsen
On Wed, Dec 16, 2009 at 2:29 PM, Hendy Irawan he...@soluvas.com wrote:


 Claus Ibsen-2 wrote:

 I got some time today and have implemented this feature. See the
 ticket and wiki page for details.

 Thank you VERY much Dr. Claus.. Exactly what the patient asked :-)

You are welcome, its a good new feature for Camel. Just keep us on the
toes in case the patient needs to visit the doctor again :)

 --
 View this message in context: 
 http://old.nabble.com/Implementing-Publish-Subscribe-Channel-tp26654086p26811032.html
 Sent from the Camel - Users mailing list archive at Nabble.com.





-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus


Re: Maven problem

2009-12-16 Thread Mond Ray Mond

Excellent - that worked thanks!
Ray

janstey wrote:
 
 Also maybe try deleting your local cache of that file. Like delete the
 following:
 
 c:\.m2\org\apache\camel\camel-spring-integration
 
 On Tue, Dec 15, 2009 at 12:36 PM, Jon Anstey jans...@gmail.com wrote:
 
 Hmm... the pom.xml file looks fine from the actual Apache snapshot repo


 https://repository.apache.org/content/repositories/snapshots/org/apache/camel/camel-spring-integration/2.1-SNAPSHOT/camel-spring-integration-2.1-SNAPSHOT.pom

 I'm assuming cde.foobar.com is an internal URL for you? :) Your Nexus
 instance may have a corrupt cache of that pom or something... you may
 want
 to go into the Nexus UI and clear out its cache for
 org/apache/camel/camel-spring-integrationhttps://cde.foobar.com/nexus/content/groups/public/org/apache/camel/camel-spring-integration/2.1-SNAPSHOT/camel-spring-integration-2.1-SNAPSHOT.pomand
 see if that works.


 On Tue, Dec 15, 2009 at 12:29 PM, Mond Ray Mond
 opengr...@gmail.comwrote:


 Guys,

 I am trying to obtain the 2.1 SNAPSHOT and Maven is puking.

 Any ideas?

 Downloading:

 https://cde.foobar.com/nexus/content/groups/public/org/apache/camel/camel-spring-integration/2.1-SNAPSHOT/camel-spring-integration-2.1-SNAPSHOT.pom
 [INFO]
 
 [ERROR] BUILD ERROR
 [INFO]
 
 [INFO] Error building POM (may not be this project's POM).


 Project ID: org.apache.camel:camel-spring-integration

 Reason: Failed to build model from file

 'c:\.m2\org\apache\camel\camel-spring-integration\2.1-SNAPSHOT\camel-spring-integration-2.1-SNAPSHOT.pom'.
 Error: 'no more data available - expected end tags
 /dependency/dependencies/project to close start tag dependency
 from
 line 110 and start tag dependencies from line 101 and start tag
 project
 from line 18, parser stopped on END_TAG seen
 ...version${spring-integration-version}/version\n ... @114:6'
 for
 project org.apache.camel:camel-spring-integration

 Thanks

 Ray
 --
 View this message in context:
 http://old.nabble.com/Maven-problem-tp26796124p26796124.html
 Sent from the Camel - Users mailing list archive at Nabble.com.




 --
 Cheers,
 Jon

 Camel in Action: http://manning.com/ibsen
 Blog: http://janstey.blogspot.com

 
 
 
 -- 
 Cheers,
 Jon
 
 Camel in Action: http://manning.com/ibsen
 Blog: http://janstey.blogspot.com
 
 

-- 
View this message in context: 
http://old.nabble.com/Maven-problem-tp26796124p26813090.html
Sent from the Camel - Users mailing list archive at Nabble.com.



Re: Help to understand xpath expression in camel routebuilder

2009-12-16 Thread Jon Anstey
Have you created a mapping file for your custom class? You need to provide
JiBX with a mapping file so it knows how to do the marshalling. In the
article, they've defined one for their classes in
InsuranceSMDZone/jibx/InsuranceMapping.xml

On Wed, Dec 16, 2009 at 1:43 PM, Kenneth H phecda...@gmail.com wrote:



 janstey wrote:
 
  In JBI applications, each SU has its own classloader so I *think* if you
  make sure that your custom classes are available on the Camel SU's
  classpath
  and the JMS SU's classpath all will be well.
 

 You were right. After moving the relevant classes to the classpath
 directory, the exception is gone. However, it would be to easy if things
 just worked, so Servicmix throws a new exception. This time it's JiBX,
 annoying:

 javax.jms.JMSException: Error sending JBI exchange
at

 org.apache.servicemix.jms.endpoints.AbstractConsumerEndpoint.onMessage(AbstractConsumerEndpoint.java:575)
at

 org.apache.servicemix.jms.endpoints.JmsConsumerEndpoint$1.onMessage(JmsConsumerEndpoint.java:505)
at

 org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:518)
at

 org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:479)
at

 org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:451)
at

 org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:323)
at

 org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:261)
at

 org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:982)
at

 org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:974)
at

 org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:876)
at java.lang.Thread.run(Thread.java:619)
 Caused by: org.jibx.runtime.JiBXException: Error marshalling XML to Object
at terror.util.JiBXUtil.marshalDocument(JiBXUtil.java:51)
at
 terror.util.TerrorJMSMarshaler.populateMessage(TerrorJMSMarshaler.java:19)
 at

 org.apache.servicemix.jms.endpoints.DefaultConsumerMarshaler.createExchange(DefaultConsumerMarshaler.java:99)
at

 org.apache.servicemix.jms.endpoints.AbstractConsumerEndpoint.onMessage(AbstractConsumerEndpoint.java:544)
... 10 more

 The function that throws the exceptions is this:

 public static Source marshalDocument(Object src, String encoding) throws
 JiBXException {
Source result = null;

try {
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
IMarshallingContext ctx =
 BindingDirectory.getFactory(src.getClass())
.createMarshallingContext();
ctx.marshalDocument(src, UTF-8, null, bOut);
result = new StreamSource(new
 ByteArrayInputStream(bOut.toByteArray()));
}
  catch (Exception e) {
throw new JiBXException(Error marshalling XML to
 Object,e);
}
return result;
 }

 I don't know where the problems is. The exceptiopns doesn't give much
 information.

 Kind regards,
 Kenneth
 --
 View this message in context:
 http://old.nabble.com/Help-to-understand-xpath-expression-in-camel-routebuilder-tp26779963p26814820.html
 Sent from the Camel - Users mailing list archive at Nabble.com.




-- 
Cheers,
Jon

Camel in Action: http://manning.com/ibsen
Blog: http://janstey.blogspot.com


camel : xpath text()

2009-12-16 Thread titexe

hello,

my xpath query does not work, when I put the text value () to finish:

/request/header/source/text()

body of my message :

?xml version=1.0 encoding=UTF-8?
request
header
source![CDATA[ALLAH]]/source
/header
/request


my route :

route
from uri=activemq:queue:IN1/
split
xpath/request/header/source/text()/ xpath

t uri=activemq:queue:XML/
/ Split
t uri=activemq:queue:RESULT/
/ route

any idea?

thanks in advance,

titexe
-- 
View this message in context: 
http://old.nabble.com/camel-%3A-xpath---text%28%29-tp26815065p26815065.html
Sent from the Camel - Users mailing list archive at Nabble.com.



Re: Help to understand xpath expression in camel routebuilder

2009-12-16 Thread Kenneth H

This is the consumer which the messages is sent to:

jms:consumer service=fork:terrorReceiver
   endpoint=jmsEndpoint
   targetService=fork:terrorDSLRouter
   destinationName=terror.in
   connectionFactory=#connectionFactory
   marshaler=#TerrorJMSMarshaler/

The TerrorJMSMarshaler is:
public class TerrorJMSMarshaler extends DefaultConsumerMarshaler {

protected void populateMessage(Message message, NormalizedMessage
normalizedMessage) throws Exception {
if (message instanceof ObjectMessage) {
ObjectMessage objectMessage = (ObjectMessage) message;
Object payload = objectMessage.getObject();
Source source = JiBXUtil.marshalDocument(payload, UTF-8);
if(payload instanceof TerrorResponse) {
TerrorResponse terrorResponse = (TerrorResponse) 
payload;

normalizedMessage.setProperty(org.apache.servicemix.eip.splitter.corrid,
terrorResponse.getRequestID());

normalizedMessage.setProperty(org.apache.servicemix.eip.splitter.index,
new Integer(1));

normalizedMessage.setProperty(org.apache.servicemix.eip.splitter.count,
new Integer(2));
}
normalizedMessage.setContent(source);
} else {
throw new UnsupportedOperationException(JMS message is not a
ObjectMessage);
}
}

} 

The message is NOT of type TerrorResponse, so it should not jump into the
statement. But from here the JiBXUtil (where the exception is thrown) is
used. Still I can't see where the error is.
-- 
View this message in context: 
http://old.nabble.com/Help-to-understand-xpath-expression-in-camel-routebuilder-tp26779963p26815131.html
Sent from the Camel - Users mailing list archive at Nabble.com.



Re: Help to understand xpath expression in camel routebuilder

2009-12-16 Thread Kenneth H


janstey wrote:
 
 Have you created a mapping file for your custom class? You need to provide
 JiBX with a mapping file so it knows how to do the marshalling. In the
 article, they've defined one for their classes in
 InsuranceSMDZone/jibx/InsuranceMapping.xml
 

You got me there, I haven't included this file. Do you know on which
classpath to put it? I'll put in the same folder as the other two JiBX
classes as a first try.
-- 
View this message in context: 
http://old.nabble.com/Help-to-understand-xpath-expression-in-camel-routebuilder-tp26779963p26815230.html
Sent from the Camel - Users mailing list archive at Nabble.com.



Re: Help to understand xpath expression in camel routebuilder

2009-12-16 Thread Kenneth H

Have you created a mapping file for your custom class? You need to provide
JiBX with a mapping file so it knows how to do the marshalling. In the
article, they've defined one for their classes in
InsuranceSMDZone/jibx/InsuranceMapping.xml


You got me there, I haven't included this file. Do you know on which
classpath to put it? I'll put in the same folder as the other two JiBX
classes as a first try.


That's strange. I can't find anywhere where the InsuranceMapping.xml is
referenced, so I don't know where to put it?! My project is a Maven project
and the orginal project is build with Ant, so I cannot just create the same
folder as him and put it there.
-- 
View this message in context: 
http://old.nabble.com/Help-to-understand-xpath-expression-in-camel-routebuilder-tp26779963p26815501.html
Sent from the Camel - Users mailing list archive at Nabble.com.



Re: Help to understand xpath expression in camel routebuilder

2009-12-16 Thread Kenneth H

- sorry for all the posts Jon...

If you look at the original Ant build file, you see:

target name=deploy-insurance description=Deploy the insurance example
echo message=Creating insurance service units /
antcall target=gn:create-serviceunit





/antcall

antcall target=gn:create-serviceunit





/antcall

The question is now: how do I do the same thing in Maven?
-- 
View this message in context: 
http://old.nabble.com/Help-to-understand-xpath-expression-in-camel-routebuilder-tp26779963p26815612.html
Sent from the Camel - Users mailing list archive at Nabble.com.



Re: Help to understand xpath expression in camel routebuilder

2009-12-16 Thread Kenneth H

- sorry for all the posts Jon...

If you look at the original Ant build file, you see (. infront of param
is to make sure the whole post is shown):

target name=deploy-insurance description=Deploy the insurance example
echo message=Creating insurance service units /
antcall target=gn:create-serviceunit
.param name=servicemix-conf value=servicemix/insurance-jms-su /
.param name=service-dest-file value=insurance-jms-su.zip /
.param name=jibx-mapping value=jibx/InsuranceMapping.xml /
.param name=include-classes value=esb/dzone/servicemix/model/* /
.param name=include-resource-dir
value=servicemix/insurance-jms-su/resources /
/antcall

antcall target=gn:create-serviceunit
.param name=servicemix-conf value=servicemix/insurance-file-su /
.param name=service-dest-file value=insurance-file-su.zip /
.param name=include-classes value=esb/dzone/servicemix/model/* /
.param name=jibx-mapping value=jibx/InsuranceMapping.xml /
.param name=include-resource-dir
value=servicemix/insurance-file-su/resources /
/antcall

The question is now: how do I do the same thing in my Maven project?
-- 
View this message in context: 
http://old.nabble.com/Help-to-understand-xpath-expression-in-camel-routebuilder-tp26779963p26815668.html
Sent from the Camel - Users mailing list archive at Nabble.com.



concurrent processing using JPA

2009-12-16 Thread Евгений Лукьянчук
Hello!

I am trying to use concurrent processing with Spring-configurated Camel.

After some time on heavy load,  exception
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
Communications link failure appears. Maximum of connections per user
in MySQL is set to 100.

Without property name=concurrentConsumers value=1/, property
name=maxConcurrentConsumers value=5/ everything is okay.

Any ideas?

configuration file:

context:annotation-config/

tx:annotation-driven transaction-manager=transactionManager/

bean id=orderProcessor class=com.itb.rfq.oms.OrderProcessor
scope=prototype/

bean id=jms
class=org.apache.activemq.camel.component.ActiveMQComponent
property name=brokerURL value=nio://localhost:61616/
property name=concurrentConsumers value=1/
property name=maxConcurrentConsumers value=5/
/bean

camelContext xmlns=http://camel.apache.org/schema/spring;
packagecom.oms/package
route
from uri=jms:queue:web-oms/
bean ref=orderProcessor method=processOrder/
to uri=jms:queue:oms-router/
/router
/camelContext

  bean id=entityManagerFactory
class=org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
property name=dataSource ref=dataSource/
property name=jpaVendorAdapter
bean
class=org.springframework.orm.jpa.vendor.TopLinkJpaVendorAdapter
property name=showSql value=false/
property name=generateDdl value=true/
property name=database value=MYSQL/
/bean
/property
property name=jpaProperties
props
prop key=toplink.weavingstatic/prop
prop key=toplink.logging.levelWARNING/prop
prop key=toplink.ddl-generationcreate-tables/prop
/props
/property
/bean

bean id=jpa class=org.apache.camel.component.jpa.JpaComponent
property name=entityManagerFactory ref=entityManagerFactory/
property name=transactionManager ref=transactionManager/
/bean

bean id=dataSource
class=com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource
property name=url value=jdbc:mysql://localhost:3306/itb_rfq/
property name=user value=root/
property name=password value=123456/
/bean

bean id=transactionManager
class=org.springframework.orm.jpa.JpaTransactionManager
property name=entityManagerFactory ref=entityManagerFactory/
/bean


Processor class:
public class OrderProcessor {

@PersistenceContext
private EntityManager manager;

@Transactional
public void processOrder(Order order) {
manager.persist(order);
}
...
}

Thanks in advance,

Eugene


Re: Help to understand xpath expression in camel routebuilder

2009-12-16 Thread Kenneth H


janstey wrote:
 
 Hmm... JBI deployment question eh... not really sure how to help you off
 the
 top of my head to be honest! Maybe try us...@servicemix.apache.org?
 

I'll try there and maybe also some Maven-folks :) 
-- 
View this message in context: 
http://old.nabble.com/Help-to-understand-xpath-expression-in-camel-routebuilder-tp26779963p26816636.html
Sent from the Camel - Users mailing list archive at Nabble.com.



Atomikos Transactions Created In Polling Type Fashion By ActiveMQ Component

2009-12-16 Thread greenbean

We are using Camel 2.0, ActiveMQ 5.3, Oracle, and the latest Atomikos for an
XA transaction manager with Spring 2.5.  Everything seems to work fine with
transaction commits and rollbacks.  However, Atomikos is constantly creating
transactions associated with routes that consume messages using the
ActiveMQComponent.  We have three queues, and five threads each consuming
from those queues.  We can see at load up that 15 transactions are created
and then committed.  Transactions are constantly created and committed even
when no messages are flowing through the queues.

If we comment out the routes that consume from queues, then the transactions
are not constantly created.

Also, you can see from the log snip that the transaction actions are
associated with a DefaultMessageListenerContainer.

Is there some way to prevent these transactions from constantly being
created when the queues are empty and no message processing is occurring?

Thanks.

2009-12-16 15:51:45,006 INFO  [atomikos] (DefaultMessageListenerContainer-1)
commit() done (by application) of transaction 127.0.0.1.tm0100900453
2009-12-16 15:51:45,010 INFO  [atomikos] (DefaultMessageListenerContainer-1)
createCompositeTransaction ( 30 ): created new ROOT transaction with id
127.0.0.1.tm0101300453
2009-12-16 15:51:45,112 INFO  [atomikos] (DefaultMessageListenerContainer-1)
commit() done (by application) of transaction 127.0.0.1.tm0101000453
2009-12-16 15:51:45,116 INFO  [atomikos] (DefaultMessageListenerContainer-1)
createCompositeTransaction ( 30 ): created new ROOT transaction with id
127.0.0.1.tm0101400453
2009-12-16 15:51:45,196 INFO  [atomikos] (DefaultMessageListenerContainer-1)
commit() done (by application) of transaction 127.0.0.1.tm0101100453
2009-12-16 15:51:45,201 INFO  [atomikos] (DefaultMessageListenerContainer-1)
createCompositeTransaction ( 30 ): created new ROOT transaction with id
127.0.0.1.tm0101500453
2009-12-16 15:51:45,240 INFO  [atomikos] (DefaultMessageListenerContainer-1)
commit() done (by application) of transaction 127.0.0.1.tm0101200453
2009-12-16 15:51:45,244 INFO  [atomikos] (DefaultMessageListenerContainer-1)
createCompositeTransaction ( 30 ): created new ROOT transaction with id
127.0.0.1.tm0101600453
-- 
View this message in context: 
http://old.nabble.com/Atomikos-Transactions-Created-In-Polling-Type-Fashion-By-ActiveMQ-Component-tp26818355p26818355.html
Sent from the Camel - Users mailing list archive at Nabble.com.



Re: camel : xpath text()

2009-12-16 Thread Stephen Gargan
I'm guessing that you expected to receive the 'ALLAH' string at your
endpoint and were receiving a DeferredCDATASectionImpl object instead is
this correct? The unit test below illustrates what is happening (it uses the
java DSL with the first of the 3 routes being pretty much the same as  what
your spring xml route is defining).

The test 'testFailsDueToTypeConversion' shows that what you actually receive
from the xpath split is a instance of DeferredCDATASectionImpl. I'm guessing
you expected this to be a String and were trying to use value() to make it
so. There are a couple of ways to do this as the rest of the test shows.

First and easiest is to use a result type in your xpath expression, e.g.
xpath(/request/header/source/text(), String.class), this will correctly
extract the data from the DeferredCDATASectionImpl object. Unfortunately,
you cannot currently specify a result type in an XML route, though It would
be an easy thing to add so maybe you should open a Jira ticket.

Secondly you could use an intermediate bean to grab the data from the
DeferredCDATASectionImpl and pass it on e.g. 'testWithBeanConversion.'

Third and probably the best would be to add an explicit type converter for
it. The test 'testWithRegisteredConverter' shows how using the
CDataTypeConverter bean below. There is excellent documentation on Type
converters at the Camel website http://camel.apache.org/type-converter.html

Hope this helps,

ste

public class CDataXPathTest extends ContextTestSupport
{
@Override
protected RouteBuilder createRouteBuilder() throws Exception
{
return new RouteBuilder()
{
@Override
public void configure() throws Exception
{


from(direct:xpath-no-conversion).split().xpath(/request/header/source/text()).to(mock:test);

from(direct:xpath-with-result-type).split().xpath(/request/header/source/text(),
String.class).to(mock:test);

from(direct:xpath-with-bean-converter).split().xpath(/request/header/source/text()).bean(new
MySourceProcessor()).to(mock:test);
}
};
}

public void testFailsDueToTypeConversion() throws Exception
{
MockEndpoint mock = getMockEndpoint(mock:test);
mock.expectedMessageCount(1);

String xml =
requestheadersource![CDATA[ALLAH]]/source/header/request;
sendBody(direct:xpath-no-conversion, xml);

mock.await();
mock.assertIsSatisfied();

Object receieved =
ExchangeHelper.getMandatoryInBody(mock.getReceivedExchanges().get(0));
assertIsInstanceOf(DeferredCDATASectionImpl.class, receieved);
}


public void testWithResultTypeConversion() throws Exception
{
MockEndpoint mock = getMockEndpoint(mock:test);
mock.expectedBodiesReceived(ALLAH);

String xml =
requestheadersource![CDATA[ALLAH]]/source/header/request;
sendBody(direct:xpath-with-result-type, xml);

mock.await();
mock.assertIsSatisfied();
}

public void testWithBeanConversion() throws Exception
{
MockEndpoint mock = getMockEndpoint(mock:test);
mock.expectedBodiesReceived(ALLAH);

String xml =
requestheadersource![CDATA[ALLAH]]/source/header/request;
sendBody(direct:xpath-with-bean-converter, xml);

mock.await();
mock.assertIsSatisfied();
}

public void testWithRegisteredConverter() throws Exception
{
context.getTypeConverterRegistry().addTypeConverter(String.class,
DeferredCDATASectionImpl.class, new CDataTypeConverter());
MockEndpoint mock = getMockEndpoint(mock:test);
mock.expectedBodiesReceived(ALLAH);

String xml =
requestheadersource![CDATA[ALLAH]]/source/header/request;
sendBody(direct:xpath-no-conversion, xml);

mock.await();
mock.assertIsSatisfied();
}

public static class MySourceProcessor
{
public String handleCdata(DeferredCDATASectionImpl payload)
{
return payload.getData();
}
}

public static class CDataTypeConverter implements TypeConverter
{
public T T convertTo(ClassT type, Object value) {
DeferredCDATASectionImpl cdata =
(DeferredCDATASectionImpl)value;
return (T) cdata.getData();
}

public T T convertTo(ClassT type, Exchange exchange, Object
value) {
return convertTo(type, value);
}

public T T mandatoryConvertTo(ClassT type, Object value) {
return convertTo(type, value);
}

public T T mandatoryConvertTo(ClassT type, Exchange exchange,
Object value) {
return convertTo(type, value);
}
}
}

On Wed, Dec 16, 2009 at 9:27 AM, titexe tit...@yahoo.fr wrote:


 hello,

 my xpath query does not work, when I put the text value () to finish:

 /request/header/source/text()

 body of my message :

 ?xml version=1.0 encoding=UTF-8?
 request
header
source![CDATA[ALLAH]]/source
   

Deadlock condition in BatchProcessor$BatchSender

2009-12-16 Thread jboyens

Hi.

I'm really hoping I'm wrong, but I was doing some load testing with Camel
and an aggregator coming off a asyncSendBody to a direct: component. 

I've set the ExecutorThreadPool on the producer so that I can watch what's
going on inside and eventually at about 16 msgs / second the threads start
to lock on the queue's Reentrant lock and deadlock. I've checked with jstack
and confirmed that they lock up on that queue lock.

It looks as though the run() method holds the lock while the enqueueExchange
method attempts to get the same lock and fails because the run() method
never lets it go.

There is a hole that opens up when sendExchanges() runs and the run() method
gives up the lock. So, exchanges will get enqueued at low speeds, but at
higher speeds the bulk up.
-- 
View this message in context: 
http://old.nabble.com/Deadlock-condition-in-BatchProcessor%24BatchSender-tp26822335p26822335.html
Sent from the Camel - Users mailing list archive at Nabble.com.



Re: Problem with injection of endpoint (cxf - producer - camel 2.2 - osgi)

2009-12-16 Thread Claus Ibsen
On Wed, Dec 16, 2009 at 2:25 PM, Charles Moulliard cmoulli...@gmail.com wrote:
 This is much better now.


BTW I am fixing it in Camel 2.2 so it will throw an exception when you
enter an invalid value in the attributes.
https://issues.apache.org/activemq/browse/CAMEL-2299


 Thx.

 Charles Moulliard
 Senior Enterprise Architect
 Apache Camel Committer

 *
 blog : http://cmoulliard.blogspot.com
 twitter : http://twitter.com/cmoulliard
 Linkedlin : http://www.linkedin.com/in/charlesmoulliard

 Apache Camel Group :
 http://www.linkedin.com/groups?home=gid=2447439trk=anet_ug_hm


 On Wed, Dec 16, 2009 at 2:18 PM, Claus Ibsen claus.ib...@gmail.com wrote:

 On Wed, Dec 16, 2009 at 2:14 PM, Charles Moulliard cmoulli...@gmail.com
 wrote:
  The code hereafter generates an error which was not there before :
 
    �...@endpointinject(name = jms:queue:inout)
     ProducerTemplate producer;

 Use (uri = jms:queue:inout) as it appears as a uri and not a
 reference to an endpoint.

 We should probably add some validation (if possible) that the default
 endpoint could not be resolved.



 
     public ReportIncidentService() {
         init();
     }
 
    �...@get
     public Incidents getIncidents() {
 
         Incidents l = new Incidents();
 
         // Call the distant service to get result (SYNCHR WAY)
 
         ListIncident i = (ListIncident)
  producer.requestBody(GET_INCIDENTS);
         l.setIncidents(i);
 
         return l;
     }
 
  Caused by: org.apache.cxf.interceptor.Fault: defaultEndpoint must be
  specified
  at
 
 org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:155)
  at
 
 org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:121)
  at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:130)
  at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:82)
  at
 
 org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
  at
 java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
  at java.util.concurrent.FutureTask.run(FutureTask.java:138)
  at
 
 org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
  at
 
 org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)
  at
 
 org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
  ... 37 more
 
 
  If I use the following method, everything works fine
 
  ListIncident i = (ListIncident) producer.requestBody(
  jms:queue:inout,GET_INCIDENTS);
 
  Regards,
 
  Charles Moulliard
  Senior Enterprise Architect
  Apache Camel Committer
 
  *
  blog : http://cmoulliard.blogspot.com
  twitter : http://twitter.com/cmoulliard
  Linkedlin : http://www.linkedin.com/in/charlesmoulliard
 
  Apache Camel Group :
  http://www.linkedin.com/groups?home=gid=2447439trk=anet_ug_hm
 



 --
 Claus Ibsen
 Apache Camel Committer

 Author of Camel in Action: http://www.manning.com/ibsen/
 Open Source Integration: http://fusesource.com
 Blog: http://davsclaus.blogspot.com/
 Twitter: http://twitter.com/davsclaus





-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus