Re: Persist messages body between different endpoints ?

2009-02-19 Thread Claus Ibsen
On Wed, Feb 18, 2009 at 3:26 PM, cmoulliard cmoulli...@gmail.com wrote:

 Hi,

 I would like to know if a persisting (like serialization of messages) exist
 and can be activated easily between different endpoints ?

 Let's see what I'm thinking about with an example

 from(file=).unmarshal().to(bean=A).to(bean=B).to(bean=C).to(activemq:queue:xx)

 In this routing, the content of a file is unmarshaled and the objects
 created will go to different endpoints (bean A, B and C) encapsulated in the
 body of messages. If something occurs during the processing of the messages,
 then the messages/objects will be lost (e.g. this situation can occur in
 case of system crash, exception raised during process execution inside a
 bean)

 Is there a mechanism that we can use to persist java objects and restore
 them in case of server crash or exception (like the mechanism that we have
 in EJB, ...)
Use persistence JMS queues. Then its the brokers job to not loose the messages.

But you also have it as files and they survive server crashes :)
So in your route if there is a crash in the processing in bean B then
the original file
is still there and when the server restarts it will read the file again.

You might have to remove/cleanup some internmediate marker files that
Camel leaves when it markes a file as being in progress
The file is named .camelLock




 Regards

 -
 Charles Moulliard
 SOA Architect

 My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/
 --
 View this message in context: 
 http://www.nabble.com/Persist-messages-body-between-different-endpoints---tp22079859s22882p22079859.html
 Sent from the Camel - Users mailing list archive at Nabble.com.





-- 
Claus Ibsen
Apache Camel Committer

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


Re: Persist messages body between different endpoints ?

2009-02-19 Thread cmoulliard

Claus,

Will the lock on the file removed when the process will reached the last
step route - so in this case, when the messages will go to the queue : xx ? 

Can you confirm or infirm this ?

Does it makes sense to design the route like this to avoid to lost messages
and objects ?

from(file=).unmarshal().(activemq:queue:xx) 

from(activemq:queue:xx).to(bean=A).to(activemq:queue:xx)

from(activemq:queue:xx).to(bean=B).to(activemq:queue:xx) 

from(activemq:queue:xx).to(bean=C).to(activemq:queue:xx)

Regards,


cmoulliard wrote:
 
 Hi,
 
 I would like to know if a persisting (like serialization of messages)
 exist and can be activated easily between different endpoints ?
 
 Let's see what I'm thinking about with an example
 
 from(file=).unmarshal().to(bean=A).to(bean=B).to(bean=C).to(activemq:queue:xx)
 
 In this routing, the content of a file is unmarshaled and the objects
 created will go to different endpoints (bean A, B and C) encapsulated in
 the body of messages. If something occurs during the processing of the
 messages, then the messages/objects will be lost (e.g. this situation can
 occur in case of system crash, exception raised during process execution
 inside a bean)
 
 Is there a mechanism that we can use to persist java objects and restore
 them in case of server crash or exception (like the mechanism that we have
 in EJB, ...)
 
 Regards 
 


-
Charles Moulliard
SOA Architect

My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/  
-- 
View this message in context: 
http://www.nabble.com/Persist-messages-body-between-different-endpoints---tp22079859s22882p22103322.html
Sent from the Camel - Users mailing list archive at Nabble.com.



Re: Newbie Question - Content Filtering

2009-02-19 Thread Ashwin Karpe

Hi,

Your approach is valid and will work as expected. However there is no need
for this header field to be added.

I would add an exception clause to deal with any exceptions thrown by the
DBFilter. For more on exception handling check out 
http://camel.apache.org/exception-clause.html
http://camel.apache.org/exception-clause.html 

from(jms:queue:testQueue)
  .process(new TestDBFilter())
 
.onException(OrderExistsException.class).handled(true).maximumRedeliveries(0).to(mock:RecordExists).end()
  .to(jms:queue:otherTestQueue);

Hope this helps.

Cheers,

Ashwin...


triswork wrote:
 
 I am new to Camel and am trying to migrate some code I wrote using the
 javax.jms classes across to Camel. I have a specific problem and I am not
 too sure if my approach is the optimal solution. I would really appreciate
 some feedback from the veterans on this list.
 
 Basically, my application performs the following:
 1) A consumer retrieves a Serialized Java object from a Queue.
 2) The contents of a data field within the object are matched against a
 set of database records.
 3) If the content corresponds to an existing record, the database record
 is updated and the object is discarded.
 4) If the content is new, it is written to the database, some of the
 object data is updated and it is routed to another JMS queue for further
 processing.
 
 My approach in Camel has been to create a RouteBuilder that works
 something like this
 from(jms:queue:testQueue)
   .process(new TestDBFilter())
  
 .filter(header(newContent).isEqualTo(true)).to(jms:queue:otherTestQueue);
 
 My TestDBFilter class basically
  - extracts the content from the message using getIn();
  - Performs the DB lookup
  - Updates the message headers on getOut()
 
 Is this a valid approach? It seems a bit contrived to me that I have to
 put a filter on a header field after my processor executes. Two specific
 questions:
 1) Is there a simpler/more efficient way to do this?
 2) Do I have to do anything special to the message to get rid of it (in
 cases where the DB record already exists). Or will it just be discarded
 when it fails on my filter predicate?
 
 Thanks in advance for any feedback/advice
 
 Tristan
 


-
--- 
Ashwin Karpe, Principal Consultant, PS - Opensource Center of Competence 
Progress Software Corporation
14 Oak Park Drive
Bedford, MA 01730
--- 
+1-972-304-9084 (Office) 
+1-972-971-1700 (Mobile) 
 
Blog: http://opensourceknowledge.blogspot.com/


-- 
View this message in context: 
http://www.nabble.com/Newbie-Question---Content-Filtering-tp22107198s22882p22114960.html
Sent from the Camel - Users mailing list archive at Nabble.com.



Re: ActiveMQ DLQ

2009-02-19 Thread Ashwin Karpe

Hi,

Please check out this link dealing with exception handling. This area has
been substantially revamped in Camel 1.5.x.x. It should answer all of your
questions

http://camel.apache.org/exception-clause.html
http://camel.apache.org/exception-clause.html 


pevgen wrote:
 
 Hi.
 How can i save a message in my special endpoint only, and not save this
 message in ActiveMQ.DLQ ?
 
 my route
 route errorHandlerRef=deadLetterErrorHandlerNull
 from uri=activemq:queue:inA/
 process ref=exceptionProcessor/ !-- throw new
 Exception(new Exception) --
 to uri=activemq:queue:outA/
 /route
 with 
 bean id=deadLetterErrorHandlerNull
 class=org.apache.camel.builder.DeadLetterChannelBuilder
 property name=redeliveryPolicy
 ref=redeliveryPolicyConfigNull/
 property name=defaultDeadLetterEndpointUri
 value=file://c:/Temp/amqtest/out/log/
 /bean
 
 bean id=redeliveryPolicyConfigNull
 class=org.apache.camel.processor.RedeliveryPolicy
 property name=maximumRedeliveries value=0/
 property name=delay value=0/
 /bean
 
 in this configuration, i get my message (from activemq:queue:inA) and in
 file://c:/Temp/amqtest/out/log, and in ActiveMQ.DLQ...
 of couse, i can create another route from ActiveMQ.DLQ to log, but it is
 no fine  
 
 Thanks, 
 Evgeny
 


-
--- 
Ashwin Karpe, Principal Consultant, PS - Opensource Center of Competence 
Progress Software Corporation
14 Oak Park Drive
Bedford, MA 01730
--- 
+1-972-304-9084 (Office) 
+1-972-971-1700 (Mobile) 
 
Blog: http://opensourceknowledge.blogspot.com/


-- 
View this message in context: 
http://www.nabble.com/ActiveMQ-DLQ-tp22076570s22882p22115149.html
Sent from the Camel - Users mailing list archive at Nabble.com.



JMS Exception

2009-02-19 Thread Nivetha Shri
Hi All

Am getting the following exception when i send an xml message to a output
queue using apache camel and servicemix.

My xml is a valid one

Here is the stack trace:

WARN  - DefaultMessageListenerContainer - Execution of JMS message listener
failed
javax.jms.JMSException: Error sending JBI exchange
   at
org.apache.servicemix.jms.endpoints.AbstractConsumerEndpoint.onMessage(AbstractConsumerEndpoint.java:569)
   at
org.apache.servicemix.jms.endpoints.JmsConsumerEndpoint$1.onMessage(JmsConsumerEndpoint.java:446)
   at
org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:506)
   at
org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:463)
   at
org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:435)
   at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:322)
   at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:260)
   at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:944)
   at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:868)
   at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.UnsupportedOperationException: JMS message is not a
TextMessage
   at
org.apache.servicemix.jms.endpoints.DefaultConsumerMarshaler.populateMessage(DefaultConsumerMarshaler.java:104)
   at
org.apache.servicemix.jms.endpoints.DefaultConsumerMarshaler.createExchange(DefaultConsumerMarshaler.java:72)
   at
org.apache.servicemix.jms.endpoints.AbstractConsumerEndpoint.onMessage(AbstractConsumerEndpoint.java:536)
   ... 9 more
WARN  - JbiBinding - Unable to convert message body of
type class [Ljava.lang.String; into an XML Source


Any insight on this will be very helpful


RegardsNivi