Re: ActiveMQ DLQ
Ashwin, thank you very much ! It's really works :) Evgeny Ashwin Karpe wrote: 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 Hope this helps. Cheers, Ashwin... 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 -- View this message in context: http://www.nabble.com/ActiveMQ-DLQ-tp22076570s22882p22117878.html Sent from the Camel - Users mailing list archive at Nabble.com.
How to close Mina session ?
Hi, I'm new to Apache Camel and Mina. I'm writing a simple tcp sever and i'm facing a problem : i don't know how to close a Mina Endpoint Session. I use Camel 1.5.0 (available at maven official repository) The workflow is : the client send a Logout command, then the server says Bye and the _server_ close the connection. It's like and FTP server does. my route is this way configured : route from ref=myMinaEndpoint / to uri=myProcessor / /route The minaEndPoint URL is mina:tcp://localhost:1802?textline=falsesync=trueminaLogger=falsecodec=myCodec In my processor, i do in the process(Exchange exchange) method : MinaExchange minaExchange = (MinaExchange) exchange; // ... minaExchange.getOut().setBody(myResponse); and the classic request-response works well but if i add at the end if the case of a logout request minaExchange.getSession().close(); the tcp session is closed, but the response (Bye) is not sent. I got an exception on server side : 230583 [AnonymousIoService-11] WARN org.apache.camel.component.mina.MinaConsumer$ReceiveHandler - [/ 192.168.244.87:54868] Unexpected exception from exceptionCaught handler. org.apache.camel.CamelException: org.apache.camel.CamelExchangeException: Could not write body on the exchange: Exchange[Message: com.dclgroup.eurodns.epp.server.eppdatag...@109dc35] at org.apache.camel.component.mina.MinaConsumer$ReceiveHandler.exceptionCaught(MinaConsumer.java:88) at org.apache.mina.common.support.AbstractIoFilterChain$TailFilter.exceptionCaught(AbstractIoFilterChain.java:564) at org.apache.mina.common.support.AbstractIoFilterChain.callNextExceptionCaught(AbstractIoFilterChain.java:345) at org.apache.mina.common.support.AbstractIoFilterChain.access$1000(AbstractIoFilterChain.java:53) at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.exceptionCaught(AbstractIoFilterChain.java:643) at org.apache.mina.common.IoFilterAdapter.exceptionCaught(IoFilterAdapter.java:75) at org.apache.mina.common.support.AbstractIoFilterChain.callNextExceptionCaught(AbstractIoFilterChain.java:345) at org.apache.mina.common.support.AbstractIoFilterChain.access$1000(AbstractIoFilterChain.java:53) at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.exceptionCaught(AbstractIoFilterChain.java:643) at org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorFilter.java:224) at org.apache.mina.filter.executor.ExecutorFilter$ProcessEventsRunnable.run(ExecutorFilter.java:264) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51) at java.lang.Thread.run(Thread.java:619) Caused by: org.apache.camel.CamelExchangeException: Could not write body on the exchange: Exchange[Message: com.dclgroup.eurodns.epp.server.eppdatag...@109dc35] at org.apache.camel.component.mina.MinaHelper.writeBody(MinaHelper.java:47) at org.apache.camel.component.mina.MinaConsumer$ReceiveHandler.messageReceived(MinaConsumer.java:131) at org.apache.mina.common.support.AbstractIoFilterChain$TailFilter.messageReceived(AbstractIoFilterChain.java:570) at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299) at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilterChain.java:53) at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:648) at org.apache.mina.filter.codec.support.SimpleProtocolDecoderOutput.flush(SimpleProtocolDecoderOutput.java:58) at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:180) at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299) at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilterChain.java:53) at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:648) at org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorFilter.java:220) ... 5 more Any help would be much appreciated. Best regards, Nicolas.
Re: How to close Mina session ?
Hi I dont think you currently can both CLOSE a session and return a response when sync=true. Could you file a JIRA request for this? http://camel.apache.org/support.html We could introduce some special header you can add to the Message so Camel knows that it should close the session when its finished writing the response. On Fri, Feb 20, 2009 at 11:46 AM, Nicolas Bouillon nico...@bouil.org wrote: Hi, I'm new to Apache Camel and Mina. I'm writing a simple tcp sever and i'm facing a problem : i don't know how to close a Mina Endpoint Session. I use Camel 1.5.0 (available at maven official repository) The workflow is : the client send a Logout command, then the server says Bye and the _server_ close the connection. It's like and FTP server does. my route is this way configured : route from ref=myMinaEndpoint / to uri=myProcessor / /route The minaEndPoint URL is mina:tcp://localhost:1802?textline=falsesync=trueminaLogger=falsecodec=myCodec In my processor, i do in the process(Exchange exchange) method : MinaExchange minaExchange = (MinaExchange) exchange; // ... minaExchange.getOut().setBody(myResponse); and the classic request-response works well but if i add at the end if the case of a logout request minaExchange.getSession().close(); the tcp session is closed, but the response (Bye) is not sent. I got an exception on server side : 230583 [AnonymousIoService-11] WARN org.apache.camel.component.mina.MinaConsumer$ReceiveHandler - [/ 192.168.244.87:54868] Unexpected exception from exceptionCaught handler. org.apache.camel.CamelException: org.apache.camel.CamelExchangeException: Could not write body on the exchange: Exchange[Message: com.dclgroup.eurodns.epp.server.eppdatag...@109dc35] at org.apache.camel.component.mina.MinaConsumer$ReceiveHandler.exceptionCaught(MinaConsumer.java:88) at org.apache.mina.common.support.AbstractIoFilterChain$TailFilter.exceptionCaught(AbstractIoFilterChain.java:564) at org.apache.mina.common.support.AbstractIoFilterChain.callNextExceptionCaught(AbstractIoFilterChain.java:345) at org.apache.mina.common.support.AbstractIoFilterChain.access$1000(AbstractIoFilterChain.java:53) at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.exceptionCaught(AbstractIoFilterChain.java:643) at org.apache.mina.common.IoFilterAdapter.exceptionCaught(IoFilterAdapter.java:75) at org.apache.mina.common.support.AbstractIoFilterChain.callNextExceptionCaught(AbstractIoFilterChain.java:345) at org.apache.mina.common.support.AbstractIoFilterChain.access$1000(AbstractIoFilterChain.java:53) at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.exceptionCaught(AbstractIoFilterChain.java:643) at org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorFilter.java:224) at org.apache.mina.filter.executor.ExecutorFilter$ProcessEventsRunnable.run(ExecutorFilter.java:264) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51) at java.lang.Thread.run(Thread.java:619) Caused by: org.apache.camel.CamelExchangeException: Could not write body on the exchange: Exchange[Message: com.dclgroup.eurodns.epp.server.eppdatag...@109dc35] at org.apache.camel.component.mina.MinaHelper.writeBody(MinaHelper.java:47) at org.apache.camel.component.mina.MinaConsumer$ReceiveHandler.messageReceived(MinaConsumer.java:131) at org.apache.mina.common.support.AbstractIoFilterChain$TailFilter.messageReceived(AbstractIoFilterChain.java:570) at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299) at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilterChain.java:53) at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:648) at org.apache.mina.filter.codec.support.SimpleProtocolDecoderOutput.flush(SimpleProtocolDecoderOutput.java:58) at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:180) at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299) at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilterChain.java:53) at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:648) at org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorFilter.java:220) ... 5 more Any help would be much appreciated. Best regards, Nicolas. -- Claus Ibsen Apache Camel Committer Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/
Re: How to close Mina session ?
I've created the JIRA issue CAMEL-1362 https://issues.apache.org/activemq/browse/CAMEL-1362 In the meanwhile, do you have any workaround hint ? On Fri, Feb 20, 2009 at 11:52, Claus Ibsen claus.ib...@gmail.com wrote: Hi I dont think you currently can both CLOSE a session and return a response when sync=true. Could you file a JIRA request for this? http://camel.apache.org/support.html We could introduce some special header you can add to the Message so Camel knows that it should close the session when its finished writing the response.
Re: JMS Exception
Hi Nivi, is it possible to get a XML input sample ? Regards JB On Friday 20 February 2009 - 12:42, Nivetha Shri wrote: 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
Re: How to close Mina session ?
On Fri, Feb 20, 2009 at 12:13 PM, Nicolas Bouillon nico...@bouil.org wrote: I've created the JIRA issue CAMEL-1362 https://issues.apache.org/activemq/browse/CAMEL-1362 In the meanwhile, do you have any workaround hint ? You can use the Synchronization hooks on the UnitOfWork Then you need to route with a processor where you can add the hook from(mina).process(new Processor() { public void process(Exchange exchange) throws Exception { exchange.getUnitOfWork().addSynchronization(new MyMinaMaybeCloseSession()); } }).to(); And in the MyMinaMaybeCloseSession you have callbacks for onComplete, onFailure. Then you can check in the exchange if the body is that special stop command and then access the mina session and close it. On Fri, Feb 20, 2009 at 11:52, Claus Ibsen claus.ib...@gmail.com wrote: Hi I dont think you currently can both CLOSE a session and return a response when sync=true. Could you file a JIRA request for this? http://camel.apache.org/support.html We could introduce some special header you can add to the Message so Camel knows that it should close the session when its finished writing the response. -- Claus Ibsen Apache Camel Committer Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/
Re: FileConsumer ERROR,RejectedExecutionException (from file to jms)
Hi Strange however you are using transactedInOut=true. That should generally not be used. Try removing it. On Fri, Feb 20, 2009 at 12:37 PM, jden den.alexand...@gmail.com wrote: Hello! I use Camel 1.6 in the scheme: From file to jms and from jms to file. I have pdf file that being serialized and writed to queue. Every pdf file size is 1mb. If total count of files is 10-15 files, then all works fine.If files count bigger than 20 files than i get error: [nent.file.filecompon...@9319d9] FileConsumer ERROR java.util.concurrent.RejectedExecutionException at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:145) at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:133) at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68) at org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87) at org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82) at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52) at org.apache.camel.component.file.FileConsumer.pollFile(FileConsumer.java:154) at org.apache.camel.component.file.FileConsumer.pollFileOrDirectory(FileConsumer.java:90) at org.apache.camel.component.file.FileConsumer.pollFileOrDirectory(FileConsumer.java:100) at org.apache.camel.component.file.FileConsumer.poll(FileConsumer.java:66) at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:66) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) at java.lang.Thread.run(Thread.java:619) [ VMTransport] ServiceERROR Async error occurred: javax.jms.JMSException: Transaction 'TX:ID:denisa-4932-1235128722453-2:0:38' has not been started. javax.jms.JMSException: Transaction 'TX:ID:denisa-4932-1235128722453-2:0:38' has not been started. at org.apache.activemq.broker.TransactionBroker.getTransaction(TransactionBroker.java:270) at org.apache.activemq.broker.TransactionBroker.acknowledge(TransactionBroker.java:190) at org.apache.activemq.broker.BrokerFilter.acknowledge(BrokerFilter.java:74) at org.apache.activemq.broker.BrokerFilter.acknowledge(BrokerFilter.java:74) at org.apache.activemq.broker.MutableBrokerFilter.acknowledge(MutableBrokerFilter.java:85) at org.apache.activemq.broker.TransportConnection.processMessageAck(TransportConnection.java:456) at org.apache.activemq.command.MessageAck.visit(MessageAck.java:205) at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:305) at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:179) at org.apache.activemq.transport.ResponseCorrelator.onCommand(ResponseCorrelator.java:104) at org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:68) at org.apache.activemq.transport.vm.VMTransport.iterate(VMTransport.java:205) at org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:122) at org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:43) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) at java.lang.Thread.run(Thread.java:619) [nent.file.filecompon...@9319d9] FileConsumer ERROR java.util.concurrent.RejectedExecutionException at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:145) at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:133) at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68) at org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87) at
Re: How to close Mina session ?
Claus, Thanks for the tip. Howerver, it dones't seem to work. I have added the following code at the end of my process method : // add a hook to close the session after the exchange exchange.getUnitOfWork().addSynchronization(new Synchronization() { @Override public void onComplete(Exchange exchange) { MinaExchange minaExchange = (MinaExchange) exchange; System.out.println(Closing session); minaExchange.getSession().close().join(); System.out.println(Session closed); } @Override public void onFailure(Exchange exchange) { } }); But, as i can see as runtime and when debugging step by step in org.apache.camel.component.mina.MinaConsumer, the event onComplete is fired before the write to the the socket. So the problem keep the same. I've tried three ways : adding this to my process. Adding to a processor before mine, and after mine. Each time, the onComplete event is called before the MinaHelper.writeBody(session, body, exchange); Regards. Nicolas. On Fri, Feb 20, 2009 at 12:30, Claus Ibsen claus.ib...@gmail.com wrote: You can use the Synchronization hooks on the UnitOfWork Then you need to route with a processor where you can add the hook from(mina).process(new Processor() { public void process(Exchange exchange) throws Exception { exchange.getUnitOfWork().addSynchronization(new MyMinaMaybeCloseSession()); } }).to(); And in the MyMinaMaybeCloseSession you have callbacks for onComplete, onFailure. Then you can check in the exchange if the body is that special stop command and then access the mina session and close it.
Re: How to close Mina session ?
Ah yeah the UnitOfWork works on the processing of the exchange. So it completes just as MinaConsumer will write the reponse back to the client. I have commited a new feature into the next version in Camel. I am afraid I can not see an easy workaround. You can now set this special header and Camel will close the session afterwards exchange.getOut().setHeader(MinaConsumer.HEADER_CLOSE_SESSION_WHEN_COMPLETE, true); On Fri, Feb 20, 2009 at 1:52 PM, Nicolas Bouillon nico...@bouil.org wrote: Claus, Thanks for the tip. Howerver, it dones't seem to work. I have added the following code at the end of my process method : // add a hook to close the session after the exchange exchange.getUnitOfWork().addSynchronization(new Synchronization() { @Override public void onComplete(Exchange exchange) { MinaExchange minaExchange = (MinaExchange) exchange; System.out.println(Closing session); minaExchange.getSession().close().join(); System.out.println(Session closed); } @Override public void onFailure(Exchange exchange) { } }); But, as i can see as runtime and when debugging step by step in org.apache.camel.component.mina.MinaConsumer, the event onComplete is fired before the write to the the socket. So the problem keep the same. I've tried three ways : adding this to my process. Adding to a processor before mine, and after mine. Each time, the onComplete event is called before the MinaHelper.writeBody(session, body, exchange); Regards. Nicolas. On Fri, Feb 20, 2009 at 12:30, Claus Ibsen claus.ib...@gmail.com wrote: You can use the Synchronization hooks on the UnitOfWork Then you need to route with a processor where you can add the hook from(mina).process(new Processor() { public void process(Exchange exchange) throws Exception { exchange.getUnitOfWork().addSynchronization(new MyMinaMaybeCloseSession()); } }).to(); And in the MyMinaMaybeCloseSession you have callbacks for onComplete, onFailure. Then you can check in the exchange if the body is that special stop command and then access the mina session and close it. -- Claus Ibsen Apache Camel Committer Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/
Newbie Question #2: Transactional Client
I think I am starting to get the hang of Camel now. I have, however, run into one more problem that I would like some advice on. I have already read through the Transactional Client documentation page before anyone asks. More on that later :) My scenario is very simple. I have the following (simplified) route: from(jms:queue:A).process(new DBLogger()).process(new DBMessageFilter()).to(jms:queue:B) I receive a message and log its contents to a database. I then pass it through to a filter that extracts very specific bits of information from the message body. Finally, the modified message is added to another queue. The problem I have is that an error (such as a SQLException) could occur in DBMessageFilter(). If such an error occurs, I would want to roll-back the insert performed by DBLogger(). The way I see it, I have one of four options: 1. Use the Spring PlatformTransactionManager I would rather avoid this, because I am not (at all) familiar with the Spring Framework and would rather not code things I can't support properly. 2. Combine DBLogger and DBMessageFilter into a single class I don't want to do this, since I am looking at a general solution that I can use on a number of different routes. 3. Put an intermediate queue between DBLogger() and DBMessageFilter() This would be an enormous waste of resources and could also become very cumbersome as the number of routes grow. 4) Use DelegateProcessors. This is my favoured solution and the one I would like some comment on. Modify my route lo look like: from(jms:queue:A).intercept(new DBLogger()).process(new DBMessageFilter()).to(jms:queue:B) My DBLogger class would look something like this: public class DBLogger extends DelegateProcessor { public void process(Exchange exchange) throws Exception { // Connection conn = // conn.setAutoCommit(false); // Log message content try { processNext(exchange); catch (SQLException ex) { conn.rollback(); throw new SQLException(ex); // for the benefit of the Routemap finally { conn.commit(); } } Is this a valid approach, or does it have some major flaw that I am missing? Otherwise, is there a better (non-spring) way to do this. I recognise that at some point in the not-too-distant future, I am going to have to look at the Spring Framework, but I just don't have the time at present :( -- View this message in context: http://www.nabble.com/Newbie-Question--2%3A-Transactional-Client-tp22120447s22882p22120447.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How to close Mina session ?
Thank you very much for the patch, and for the velocity ! Best regards On Fri, Feb 20, 2009 at 16:12, Claus Ibsen claus.ib...@gmail.com wrote: Ah yeah the UnitOfWork works on the processing of the exchange. So it completes just as MinaConsumer will write the reponse back to the client. I have commited a new feature into the next version in Camel. I am afraid I can not see an easy workaround. You can now set this special header and Camel will close the session afterwards exchange.getOut().setHeader(MinaConsumer.HEADER_CLOSE_SESSION_WHEN_COMPLETE, true); On Fri, Feb 20, 2009 at 1:52 PM, Nicolas Bouillon nico...@bouil.org wrote: Claus, Thanks for the tip. Howerver, it dones't seem to work. I have added the following code at the end of my process method : // add a hook to close the session after the exchange exchange.getUnitOfWork().addSynchronization(new Synchronization() { @Override public void onComplete(Exchange exchange) { MinaExchange minaExchange = (MinaExchange) exchange; System.out.println(Closing session); minaExchange.getSession().close().join(); System.out.println(Session closed); } @Override public void onFailure(Exchange exchange) { } }); But, as i can see as runtime and when debugging step by step in org.apache.camel.component.mina.MinaConsumer, the event onComplete is fired before the write to the the socket. So the problem keep the same. I've tried three ways : adding this to my process. Adding to a processor before mine, and after mine. Each time, the onComplete event is called before the MinaHelper.writeBody(session, body, exchange); Regards. Nicolas. On Fri, Feb 20, 2009 at 12:30, Claus Ibsen claus.ib...@gmail.com wrote: You can use the Synchronization hooks on the UnitOfWork Then you need to route with a processor where you can add the hook from(mina).process(new Processor() { public void process(Exchange exchange) throws Exception { exchange.getUnitOfWork().addSynchronization(new MyMinaMaybeCloseSession()); } }).to(); And in the MyMinaMaybeCloseSession you have callbacks for onComplete, onFailure. Then you can check in the exchange if the body is that special stop command and then access the mina session and close it. -- Claus Ibsen Apache Camel Committer Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/
Newbie Question #2: Transactional Client
I think I am starting to get the hang of Camel now. I have, however, run into one more problem that I would like some advice on. I have already read through the Transactional Client documentation page before anyone asks. More on that later :) My scenario is very simple. I have the following (simplified) route: from(jms:queue:A).process(new DBLogger()).process(new DBMessageFilter()).to(jms:queue:B) I receive a message and log its contents to a database. I then pass it through to a filter that extracts very specific bits of information from the message body. Finally, the modified message is added to another queue. The problem I have is that an error (such as a SQLException) could occur in DBMessageFilter(). If such an error occurs, I would want to roll-back the insert performed by DBLogger(). The way I see it, I have one of four options: 1. Use the Spring PlatformTransactionManager I would rather avoid this, because I am not (at all) familiar with the Spring Framework and would rather not code things I can't support properly. 2. Combine DBLogger and DBMessageFilter into a single class I don't want to do this, since I am looking at a general solution that I can use on a number of different routes. 3. Put an intermediate queue between DBLogger() and DBMessageFilter() This would be an enormous waste of resources and could also become very cumbersome as the number of routes grow. 4) Use DelegateProcessors. This is my favoured solution and the one I would like some comment on. Modify my route lo look like: from(jms:queue:A).intercept(new DBLogger()).process(new DBMessageFilter()).to(jms:queue:B) My DBLogger class would look something like this: public class DBLogger extends DelegateProcessor { public void process(Exchange exchange) throws Exception { // Connection conn = // conn.setAutoCommit(false); // Log message content try { processNext(exchange); catch (SQLException ex) { conn.rollback(); throw ex; // for the benefit of the Routemap finally { conn.commit(); } } Is this a valid approach, or does it have some major flaw that I am missing? Otherwise, is there a better (non-spring) way to do this. I recognise that at some point in the not-too-distant future, I am going to have to look at the Spring Framework, but I just don't have the time at present :(
Re: Newbie Question #2: Transactional Client
Hi Well you gotta get some TX manager in the mix. Otherwise how would you ensure that the JMS and DB participates in the same transaction? Of couse the Camel JMS consumer will be able to rollback if there is an exception thrown, but that does still not ensure that the JMS and DB are managed in the same TX. So if you are able to store in database, but then sending to the next DB queue fails, then the message will be rolled back to the original JMS queue, but the DB is comitted. So I would advice you to learn a bit on the Spring TX stuff and NOT ROLL OUT YOUR OWN, its. harder than you think. The Spring guys have worked hard on this for many years to get it in that stellar quality it is. On Fri, Feb 20, 2009 at 5:37 PM, Tristan Koen tristan.k...@gmail.com wrote: I think I am starting to get the hang of Camel now. I have, however, run into one more problem that I would like some advice on. I have already read through the Transactional Client documentation page before anyone asks. More on that later :) My scenario is very simple. I have the following (simplified) route: from(jms:queue:A).process(new DBLogger()).process(new DBMessageFilter()).to(jms:queue:B) I receive a message and log its contents to a database. I then pass it through to a filter that extracts very specific bits of information from the message body. Finally, the modified message is added to another queue. The problem I have is that an error (such as a SQLException) could occur in DBMessageFilter(). If such an error occurs, I would want to roll-back the insert performed by DBLogger(). The way I see it, I have one of four options: 1. Use the Spring PlatformTransactionManager I would rather avoid this, because I am not (at all) familiar with the Spring Framework and would rather not code things I can't support properly. 2. Combine DBLogger and DBMessageFilter into a single class I don't want to do this, since I am looking at a general solution that I can use on a number of different routes. 3. Put an intermediate queue between DBLogger() and DBMessageFilter() This would be an enormous waste of resources and could also become very cumbersome as the number of routes grow. 4) Use DelegateProcessors. This is my favoured solution and the one I would like some comment on. Modify my route lo look like: from(jms:queue:A).intercept(new DBLogger()).process(new DBMessageFilter()).to(jms:queue:B) My DBLogger class would look something like this: public class DBLogger extends DelegateProcessor { public void process(Exchange exchange) throws Exception { // Connection conn = // conn.setAutoCommit(false); // Log message content try { processNext(exchange); catch (SQLException ex) { conn.rollback(); throw ex; // for the benefit of the Routemap finally { conn.commit(); } } Is this a valid approach, or does it have some major flaw that I am missing? Otherwise, is there a better (non-spring) way to do this. I recognise that at some point in the not-too-distant future, I am going to have to look at the Spring Framework, but I just don't have the time at present :( -- Claus Ibsen Apache Camel Committer Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/
Re: How to close Mina session ?
On Fri, Feb 20, 2009 at 5:12 PM, Nicolas Bouillon nico...@bouil.org wrote: Thank you very much for the patch, and for the velocity ! You are welcome. Thanks for reporting. If you can test it that would be great. See download page how to use 1.6.1-SNAPSHOT version. eg = Apache SNAPSHOT maven repo and all that stuff. http://camel.apache.org/download.html Best regards On Fri, Feb 20, 2009 at 16:12, Claus Ibsen claus.ib...@gmail.com wrote: Ah yeah the UnitOfWork works on the processing of the exchange. So it completes just as MinaConsumer will write the reponse back to the client. I have commited a new feature into the next version in Camel. I am afraid I can not see an easy workaround. You can now set this special header and Camel will close the session afterwards exchange.getOut().setHeader(MinaConsumer.HEADER_CLOSE_SESSION_WHEN_COMPLETE, true); On Fri, Feb 20, 2009 at 1:52 PM, Nicolas Bouillon nico...@bouil.org wrote: Claus, Thanks for the tip. Howerver, it dones't seem to work. I have added the following code at the end of my process method : // add a hook to close the session after the exchange exchange.getUnitOfWork().addSynchronization(new Synchronization() { @Override public void onComplete(Exchange exchange) { MinaExchange minaExchange = (MinaExchange) exchange; System.out.println(Closing session); minaExchange.getSession().close().join(); System.out.println(Session closed); } @Override public void onFailure(Exchange exchange) { } }); But, as i can see as runtime and when debugging step by step in org.apache.camel.component.mina.MinaConsumer, the event onComplete is fired before the write to the the socket. So the problem keep the same. I've tried three ways : adding this to my process. Adding to a processor before mine, and after mine. Each time, the onComplete event is called before the MinaHelper.writeBody(session, body, exchange); Regards. Nicolas. On Fri, Feb 20, 2009 at 12:30, Claus Ibsen claus.ib...@gmail.com wrote: You can use the Synchronization hooks on the UnitOfWork Then you need to route with a processor where you can add the hook from(mina).process(new Processor() { public void process(Exchange exchange) throws Exception { exchange.getUnitOfWork().addSynchronization(new MyMinaMaybeCloseSession()); } }).to(); And in the MyMinaMaybeCloseSession you have callbacks for onComplete, onFailure. Then you can check in the exchange if the body is that special stop command and then access the mina session and close it. -- Claus Ibsen Apache Camel Committer Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ -- Claus Ibsen Apache Camel Committer Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/
Re: Newbie Question #2: Transactional Client
I thought that calling conn.rollback() would sort out the DB side and the thrown SQL exception would sort out the JMS side. I am clearly missing something rather important here, so I will take your advice and spend some time looking into Spring. On Fri, Feb 20, 2009 at 7:26 PM, Claus Ibsen claus.ib...@gmail.com wrote: Hi Well you gotta get some TX manager in the mix. Otherwise how would you ensure that the JMS and DB participates in the same transaction? Of couse the Camel JMS consumer will be able to rollback if there is an exception thrown, but that does still not ensure that the JMS and DB are managed in the same TX. So if you are able to store in database, but then sending to the next DB queue fails, then the message will be rolled back to the original JMS queue, but the DB is comitted. So I would advice you to learn a bit on the Spring TX stuff and NOT ROLL OUT YOUR OWN, its. harder than you think. The Spring guys have worked hard on this for many years to get it in that stellar quality it is. On Fri, Feb 20, 2009 at 5:37 PM, Tristan Koen tristan.k...@gmail.com wrote: I think I am starting to get the hang of Camel now. I have, however, run into one more problem that I would like some advice on. I have already read through the Transactional Client documentation page before anyone asks. More on that later :) My scenario is very simple. I have the following (simplified) route: from(jms:queue:A).process(new DBLogger()).process(new DBMessageFilter()).to(jms:queue:B) I receive a message and log its contents to a database. I then pass it through to a filter that extracts very specific bits of information from the message body. Finally, the modified message is added to another queue. The problem I have is that an error (such as a SQLException) could occur in DBMessageFilter(). If such an error occurs, I would want to roll-back the insert performed by DBLogger(). The way I see it, I have one of four options: 1. Use the Spring PlatformTransactionManager I would rather avoid this, because I am not (at all) familiar with the Spring Framework and would rather not code things I can't support properly. 2. Combine DBLogger and DBMessageFilter into a single class I don't want to do this, since I am looking at a general solution that I can use on a number of different routes. 3. Put an intermediate queue between DBLogger() and DBMessageFilter() This would be an enormous waste of resources and could also become very cumbersome as the number of routes grow. 4) Use DelegateProcessors. This is my favoured solution and the one I would like some comment on. Modify my route lo look like: from(jms:queue:A).intercept(new DBLogger()).process(new DBMessageFilter()).to(jms:queue:B) My DBLogger class would look something like this: public class DBLogger extends DelegateProcessor { public void process(Exchange exchange) throws Exception { // Connection conn = // conn.setAutoCommit(false); // Log message content try { processNext(exchange); catch (SQLException ex) { conn.rollback(); throw ex; // for the benefit of the Routemap finally { conn.commit(); } } Is this a valid approach, or does it have some major flaw that I am missing? Otherwise, is there a better (non-spring) way to do this. I recognise that at some point in the not-too-distant future, I am going to have to look at the Spring Framework, but I just don't have the time at present :( -- Claus Ibsen Apache Camel Committer Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/
CXF endpoint - No service was found issue
I am trying to create a CXF endpoint using Spring DSL. My endpoint and route definitions are as follow: cxf:cxfEndpoint id=serviceEndpoint address=http://localhost:8080/SFServices/services/account; wsdlURL=classpath:accountOutboundMessage.wsdl serviceClass=com.mypackage.service.NotificationPort endpointName=s:Notification serviceName=s:NotificationService xmlns:s=http://soap.sforce.com/2005/09/outbound; / camelContext id=camel xmlns=http://activemq.apache.org/camel/schema/spring; route from uri=cxf:bean:serviceEndpoint / bean ref=testBean method=toCompany/ /route /camelContext The webapp starts up correctly. I can go to the CXF Service list page and see that the service has been correctly initialized. However when I access the WSDL for the published service, I see a 'No service was found' message with the following warning. WARN [13:08:47,515] - org.apache.cxf.transport.servlet.ServletController.invoke(126) | Can't find the request for http://localhost:8080/SFServices/services/account's Observer Can somebody point me to what is wrong in my configuration or how I can go about debugging this issue? Thanks Sriram The debug messages from Tomcat startup where the CXF endpoint is setup is listed below. INFO [13:08:33,218] - org.apache.cxf.endpoint.ServerImpl.initDestination(91) | Setting the server's publish address to be http://localhost:8080/SFServices/services/account DEBUG [13:08:33,250] - org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilder.buildHandlerChainFromClass(72) | building handler chain DEBUG [13:08:33,250] - org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilder.findHandlerChainAnnotation(257) | Checking for HandlerChain annotation on com.mypackage.service.NotificationPort DEBUG [13:08:33,250] - org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilder.buildHandlerChainFromClass(77) | no HandlerChain annotation on interface com.mypackage.service.NotificationPort DEBUG [13:08:33,250] - org.apache.camel.management.DefaultInstrumentationAgent.registerMBeanWithServer(247) | Registered MBean with objectname: org.apache.camel:context=CM-Latitude-E55/camel,type=consumers,name=CxfConsumer(0x91cceb) DEBUG [13:08:33,250] - org.apache.cxf.transport.AbstractObservable.setMessageObserver(45) | registering incoming observer: org.apache.cxf.transport.chaininitiationobser...@1bc6271 DEBUG [13:08:33,250] - org.apache.cxf.endpoint.ServerImpl.start(127) | register the server to serverRegistry DEBUG [13:08:33,250] - org.apache.camel.impl.DefaultComponent.createEndpoint(79) | Creating endpoint uri=[spring-event:default], path=[default], parameters=[{}] DEBUG [13:08:33,265] - org.apache.camel.impl.DefaultCamelContext.getEndpoint(333) | spring-event:default converted to endpoint: Endpoint[spring-event:default] by component: org.apache.camel.component.event.eventcompon...@17f61bb DEBUG [13:08:33,281] - org.apache.camel.management.DefaultInstrumentationAgent.registerMBeanWithServer(247) | Registered MBean with objectname: org.apache.camel:context=CM-Latitude-E55/camel,type=endpoints,name=spring-event:default\?id=0x20a20c46 Feb 20, 2009 1:08:33 PM org.apache.catalina.core.ApplicationContext log INFO: Set web app root system property: 'webapp.root' = [C:\projects\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\SFServices\] Feb 20, 2009 1:08:33 PM org.apache.catalina.core.ApplicationContext log INFO: Initializing log4j from [C:\projects\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\SFServices\WEB-INF\classes\log4j.xml] INFO [13:08:33,453] - org.apache.cxf.transport.servlet.CXFServlet.updateContext(120) | Load the bus with application context INFO [13:08:33,453] - org.springframework.context.support.AbstractApplicationContext.prepareRefresh(411) | Refreshing org.apache.cxf.bus.spring.busapplicationcont...@1026e12: display name [org.apache.cxf.bus.spring.busapplicationcont...@1026e12]; startup date [Fri Feb 20 13:08:33 PST 2009]; parent: org.springframework.web.context.support.xmlwebapplicationcont...@ad5fab INFO [13:08:33,468] - org.apache.cxf.common.logging.LogUtils.doLog(345) | No cxf.xml configuration file detected, relying on defaults. DEBUG [13:08:33,468] - org.apache.cxf.bus.spring.BusApplicationContext.getConfigResources(179) | Creating application context with resources: [] INFO [13:08:33,468] - org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(426) | Bean factory for application context [org.apache.cxf.bus.spring.busapplicationcont...@1026e12]: org.springframework.beans.factory.support.defaultlistablebeanfact...@cebf1c DEBUG [13:08:33,468] - org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(430) | 0 beans defined in org.apache.cxf.bus.spring.busapplicationcont...@1026e12: display name [org.apache.cxf.bus.spring.busapplicationcont...@1026e12]; startup date [Fri Feb 20 13:08:33 PST 2009];