JMS Transaction rollback with dead letter channel using Apache Camel
I am facing a issue while trying to implement JMS transaction using Camel. Here is the scenario 1. Primary route which read the message from the queue(JMS_IN), pass the same exchange to the two sub route(direct route) 2. First sub route process the message successfully and send to the another queue(JMS_ONE) 3. Second sub route process the message and send to the another queue(JMS_TWO). 4. If any error occurred during the sub route processing all the message should rollback and original message sent to another queue(ERROR) that is dead letter queue. 5. In the example Context I have created throw RuntimeException during second sub route processing. 6. So expected behavior is to move the original message to ERROR queue, same time no message should send to JMS_ONE & JMS_TWO 7. But actual behavior is original message was sent to the ERROR queue, but message sent the JMS_ONE. I am using Apache Camel 2.24.0, Jboss HornetQ and spring transaction manager. Kindly help me on this, I am struck at this for couple of days Camel Context Below org.jboss.naming.remote.client.InitialContextFactory http-remoting://localhost:9089 TESTUSR TESTUSR http://camel.apache.org/schema/spring"; errorHandlerRef="myDeadLetterErrorHandler"> Thanks!!!
Re: Read header value in Camel xpath
Hi What do you mean? Do you mean you need to use a Camel Message header to build your xpath expression, or do you want from the xpath expression to refer to a Camel header. Its a bit unclear from your example. On Wed, Jun 26, 2019 at 8:45 AM Bikash Kaushik wrote: > > Hi, > > I want to know , how to pass header value in Camel xpath , > > headerName="xpathValue">*//*[local-name()='EmployeeDataResult']/text() > > I have to pass header value in between xapth. > > > Regards, > Bikash Kaushik -- Claus Ibsen - http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
Re: JMS Transaction rollback with dead letter channel using Apache Camel
It looks like you need the JTA transaction manager to handle a XA transaction between the JMS_ONE and JMS_TWO. On Wed, Jun 26, 2019 at 3:01 PM sujin sr wrote: > I am facing a issue while trying to implement JMS transaction using Camel. > > Here is the scenario > > 1. Primary route which read the message from the queue(JMS_IN), pass the > same exchange to the two sub route(direct route) > 2. First sub route process the message successfully and send to the another > queue(JMS_ONE) > 3. Second sub route process the message and send to the another > queue(JMS_TWO). > 4. If any error occurred during the sub route processing all the message > should rollback and original message sent to another queue(ERROR) that is > dead letter queue. > 5. In the example Context I have created throw RuntimeException during > second sub route processing. > 6. So expected behavior is to move the original message to ERROR queue, > same time no message should send to JMS_ONE & JMS_TWO > 7. But actual behavior is original message was sent to the ERROR queue, but > message sent the JMS_ONE. > > I am using Apache Camel 2.24.0, Jboss HornetQ and spring transaction > manager. > > Kindly help me on this, I am struck at this for couple of days > > Camel Context Below > > > > > > key="java.naming.factory.initial">org.jboss.naming.remote.client.InitialContextFactory > key="java.naming.provider.url">http-remoting://localhost:9089 > > TESTUSR > TESTUSR > > > > > class="org.springframework.jms.core.JmsTemplate"> > > > > class="org.springframework.jndi.JndiObjectFactoryBean"> > > > > > class="org.springframework.jms.connection.JmsTransactionManager"> > > > > class="org.apache.camel.component.jms.JmsConfiguration"> > > > > > > > > > > > > class="com.test.DeadChannelTestProcessor"/> > > > class="org.apache.camel.builder.DeadLetterChannelBuilder"> > > > > > class="org.apache.camel.processor.RedeliveryPolicy"> > > > > http://camel.apache.org/schema/spring"; > errorHandlerRef="myDeadLetterErrorHandler"> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Thanks!!! >
Re: JMS Transaction rollback with dead letter channel using Apache Camel
Hi Its likely better to use just the brokers error handling with transaction (transacted JMS acknowledge). Then you can configure the broker with redelivery and its dead letter queue. Then you dont need any Camel error handler, and only need to setup JMS component for transacted JMS ack mode. Otherwise in your use case, you cannot both rollback sending to ONE and TWO but send to ERROR as they are all in the same transaction. So in this example you need to setup a 2nd JMS component for ERROR, so the JMS can rollback, and ERROR can commit. Also mind that the incoming endpoint is also JMS and it will also rollback as part of ONE and TWO. So you will get the message redelibered again from the broker. So try instead to just use broker error handling. On Wed, Jun 26, 2019 at 9:01 AM sujin sr wrote: > > I am facing a issue while trying to implement JMS transaction using Camel. > > Here is the scenario > > 1. Primary route which read the message from the queue(JMS_IN), pass the > same exchange to the two sub route(direct route) > 2. First sub route process the message successfully and send to the another > queue(JMS_ONE) > 3. Second sub route process the message and send to the another > queue(JMS_TWO). > 4. If any error occurred during the sub route processing all the message > should rollback and original message sent to another queue(ERROR) that is > dead letter queue. > 5. In the example Context I have created throw RuntimeException during > second sub route processing. > 6. So expected behavior is to move the original message to ERROR queue, > same time no message should send to JMS_ONE & JMS_TWO > 7. But actual behavior is original message was sent to the ERROR queue, but > message sent the JMS_ONE. > > I am using Apache Camel 2.24.0, Jboss HornetQ and spring transaction > manager. > > Kindly help me on this, I am struck at this for couple of days > > Camel Context Below > > > > > key="java.naming.factory.initial">org.jboss.naming.remote.client.InitialContextFactory > key="java.naming.provider.url">http-remoting://localhost:9089 > > TESTUSR > TESTUSR > > > > > > > > > class="org.springframework.jndi.JndiObjectFactoryBean"> > > > > > class="org.springframework.jms.connection.JmsTransactionManager"> > > > > class="org.apache.camel.component.jms.JmsConfiguration"> > > > > > > > > > > > > class="com.test.DeadChannelTestProcessor"/> > > > class="org.apache.camel.builder.DeadLetterChannelBuilder"> > > > > > class="org.apache.camel.processor.RedeliveryPolicy"> > > > > http://camel.apache.org/schema/spring"; > errorHandlerRef="myDeadLetterErrorHandler"> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Thanks!!! -- Claus Ibsen - http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
Re: JMS Transaction rollback with dead letter channel using Apache Camel
On Wed, Jun 26, 2019 at 9:19 AM Zheng Feng wrote: > > It looks like you need the JTA transaction manager to handle a XA > transaction between the JMS_ONE and JMS_TWO. > That is only needed if ONE and TWO are 2 different JMS systems. If they are the same then local JMS transacted ack mode should be fine. Also if you add for example JDBC with database, then yeah you need XA. CiA2 book has a full chapter on transactions, so its a good source to learn and read much more. And try its examples etc. > On Wed, Jun 26, 2019 at 3:01 PM sujin sr wrote: > > > I am facing a issue while trying to implement JMS transaction using Camel. > > > > Here is the scenario > > > > 1. Primary route which read the message from the queue(JMS_IN), pass the > > same exchange to the two sub route(direct route) > > 2. First sub route process the message successfully and send to the another > > queue(JMS_ONE) > > 3. Second sub route process the message and send to the another > > queue(JMS_TWO). > > 4. If any error occurred during the sub route processing all the message > > should rollback and original message sent to another queue(ERROR) that is > > dead letter queue. > > 5. In the example Context I have created throw RuntimeException during > > second sub route processing. > > 6. So expected behavior is to move the original message to ERROR queue, > > same time no message should send to JMS_ONE & JMS_TWO > > 7. But actual behavior is original message was sent to the ERROR queue, but > > message sent the JMS_ONE. > > > > I am using Apache Camel 2.24.0, Jboss HornetQ and spring transaction > > manager. > > > > Kindly help me on this, I am struck at this for couple of days > > > > Camel Context Below > > > > > > > > > > > > > key="java.naming.factory.initial">org.jboss.naming.remote.client.InitialContextFactory > > > key="java.naming.provider.url">http-remoting://localhost:9089 > > > > TESTUSR > > TESTUSR > > > > > > > > > > > class="org.springframework.jms.core.JmsTemplate"> > > > > > > > > > class="org.springframework.jndi.JndiObjectFactoryBean"> > > > > > > > > > > > class="org.springframework.jms.connection.JmsTransactionManager"> > > > > > > > > > class="org.apache.camel.component.jms.JmsConfiguration"> > > > > > > > > > > > > > > > > > > > > > > > > > class="com.test.DeadChannelTestProcessor"/> > > > > > > > class="org.apache.camel.builder.DeadLetterChannelBuilder"> > > > > > > > > > > > class="org.apache.camel.processor.RedeliveryPolicy"> > > > > > > > > http://camel.apache.org/schema/spring"; > > errorHandlerRef="myDeadLetterErrorHandler"> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Thanks!!! > > -- Claus Ibsen - http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
Re: Read header value in Camel xpath
Hi, I want to use header value in xpath to filter message based on header value. On Wed, Jun 26, 2019, 12:46 PM Claus Ibsen wrote: > Hi > > What do you mean? > > Do you mean you need to use a Camel Message header to build your xpath > expression, or do you want from the xpath expression to refer to a > Camel header. Its a bit unclear from your example. > > On Wed, Jun 26, 2019 at 8:45 AM Bikash Kaushik > wrote: > > > > Hi, > > > > I want to know , how to pass header value in Camel xpath , > > > > > > headerName="xpathValue">*//*[local-name()='EmployeeDataResult']/text() > > > > I have to pass header value in between xapth. > > > > > > Regards, > > Bikash Kaushik > > > > -- > Claus Ibsen > - > http://davsclaus.com @davsclaus > Camel in Action 2: https://www.manning.com/ibsen2 >
Re: JMS Transaction rollback with dead letter channel using Apache Camel
Thanks for the Response. Before implementing 'transacted JMS acknowledge' i have tried to create separate JMS component for ERROR. But still, I see the same behaviour as message sent to the JMS_ONE not rollbacked I have added this beans and changed ERROR route like below Where i am missing anything here, kindly advise On Wed, 26 Jun 2019 at 12:51, Claus Ibsen wrote: > Hi > > Its likely better to use just the brokers error handling with > transaction (transacted JMS acknowledge). > Then you can configure the broker with redelivery and its dead letter > queue. > Then you dont need any Camel error handler, and only need to setup JMS > component for transacted JMS ack mode. > > Otherwise in your use case, you cannot both rollback sending to ONE > and TWO but send to ERROR as they are all in the same transaction. > So in this example you need to setup a 2nd JMS component for ERROR, so > the JMS can rollback, and ERROR can commit. Also mind that the > incoming endpoint is also JMS and it will also rollback as part of ONE > and TWO. So you will get the message redelibered again from the > broker. > > So try instead to just use broker error handling. > > > > > On Wed, Jun 26, 2019 at 9:01 AM sujin sr wrote: > > > > I am facing a issue while trying to implement JMS transaction using > Camel. > > > > Here is the scenario > > > > 1. Primary route which read the message from the queue(JMS_IN), pass the > > same exchange to the two sub route(direct route) > > 2. First sub route process the message successfully and send to the > another > > queue(JMS_ONE) > > 3. Second sub route process the message and send to the another > > queue(JMS_TWO). > > 4. If any error occurred during the sub route processing all the message > > should rollback and original message sent to another queue(ERROR) that is > > dead letter queue. > > 5. In the example Context I have created throw RuntimeException during > > second sub route processing. > > 6. So expected behavior is to move the original message to ERROR queue, > > same time no message should send to JMS_ONE & JMS_TWO > > 7. But actual behavior is original message was sent to the ERROR queue, > but > > message sent the JMS_ONE. > > > > I am using Apache Camel 2.24.0, Jboss HornetQ and spring transaction > > manager. > > > > Kindly help me on this, I am struck at this for couple of days > > > > Camel Context Below > > > > > > > > > > > > key="java.naming.factory.initial">org.jboss.naming.remote.client.InitialContextFactory > > > key="java.naming.provider.url">http-remoting://localhost:9089 > > > > TESTUSR > > key="java.naming.security.credentials">TESTUSR > > > > > > > > > > class="org.springframework.jms.core.JmsTemplate"> > > > > > > > > > class="org.springframework.jndi.JndiObjectFactoryBean"> > > > > > > > > > > > class="org.springframework.jms.connection.JmsTransactionManager"> > > > > > > > > > class="org.apache.camel.component.jms.JmsConfiguration"> > > > > > > > > > > > > > > > > > > > > > > > > > class="com.test.DeadChannelTestProcessor"/> > > > > > > > class="org.apache.camel.builder.DeadLetterChannelBuilder"> > > value="direct:dead_letter_channel"/> > > ref="myRedeliveryPolicyConfig"/> > > > > > > > class="org.apache.camel.processor.RedeliveryPolicy"> > > > > > > > > http://camel.apache.org/schema/spring"; > > errorHandlerRef="myDeadLetterErrorHandler"> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Thanks!!! > > > > -- > Claus Ibsen > - > http://davsclaus.com @davsclaus > Camel in Action 2: https://www.manning.com/ibsen2 >
Re: JMS Transaction rollback with dead letter channel using Apache Camel
Hi You are using dead letter channel as Camel's error handler which will mark the message as succesfull. Just use a regular error handler On Wed, Jun 26, 2019 at 9:50 AM sujin sr wrote: > > Thanks for the Response. > > Before implementing 'transacted JMS acknowledge' i have tried to create > separate JMS component for ERROR. But still, I see the same behaviour as > message sent to the JMS_ONE not rollbacked > > I have added this beans and changed ERROR route like below > > class="org.apache.camel.component.jms.JmsConfiguration"> > > > > > > > > > > > > > > > > Where i am missing anything here, kindly advise > > > > On Wed, 26 Jun 2019 at 12:51, Claus Ibsen wrote: > > > Hi > > > > Its likely better to use just the brokers error handling with > > transaction (transacted JMS acknowledge). > > Then you can configure the broker with redelivery and its dead letter > > queue. > > Then you dont need any Camel error handler, and only need to setup JMS > > component for transacted JMS ack mode. > > > > Otherwise in your use case, you cannot both rollback sending to ONE > > and TWO but send to ERROR as they are all in the same transaction. > > So in this example you need to setup a 2nd JMS component for ERROR, so > > the JMS can rollback, and ERROR can commit. Also mind that the > > incoming endpoint is also JMS and it will also rollback as part of ONE > > and TWO. So you will get the message redelibered again from the > > broker. > > > > So try instead to just use broker error handling. > > > > > > > > > > On Wed, Jun 26, 2019 at 9:01 AM sujin sr wrote: > > > > > > I am facing a issue while trying to implement JMS transaction using > > Camel. > > > > > > Here is the scenario > > > > > > 1. Primary route which read the message from the queue(JMS_IN), pass the > > > same exchange to the two sub route(direct route) > > > 2. First sub route process the message successfully and send to the > > another > > > queue(JMS_ONE) > > > 3. Second sub route process the message and send to the another > > > queue(JMS_TWO). > > > 4. If any error occurred during the sub route processing all the message > > > should rollback and original message sent to another queue(ERROR) that is > > > dead letter queue. > > > 5. In the example Context I have created throw RuntimeException during > > > second sub route processing. > > > 6. So expected behavior is to move the original message to ERROR queue, > > > same time no message should send to JMS_ONE & JMS_TWO > > > 7. But actual behavior is original message was sent to the ERROR queue, > > but > > > message sent the JMS_ONE. > > > > > > I am using Apache Camel 2.24.0, Jboss HornetQ and spring transaction > > > manager. > > > > > > Kindly help me on this, I am struck at this for couple of days > > > > > > Camel Context Below > > > > > > > > > > > > > > > > > > > key="java.naming.factory.initial">org.jboss.naming.remote.client.InitialContextFactory > > > > > key="java.naming.provider.url">http-remoting://localhost:9089 > > > > > > TESTUSR > > > > key="java.naming.security.credentials">TESTUSR > > > > > > > > > > > > > > > > class="org.springframework.jms.core.JmsTemplate"> > > > > > > > > > > > > > > class="org.springframework.jndi.JndiObjectFactoryBean"> > > > > > > > > > > > > > > > > > class="org.springframework.jms.connection.JmsTransactionManager"> > > > > > > > > > > > > > > class="org.apache.camel.component.jms.JmsConfiguration"> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > class="com.test.DeadChannelTestProcessor"/> > > > > > > > > > > > class="org.apache.camel.builder.DeadLetterChannelBuilder"> > > > > value="direct:dead_letter_channel"/> > > > > ref="myRedeliveryPolicyConfig"/> > > > > > > > > > > > class="org.apache.camel.processor.RedeliveryPolicy"> > > > > > > > > > > > > http://camel.apache.org/schema/spring"; > > > errorHandlerRef="myDeadLetterErrorHandler"> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Thanks!!! > > > > > > > > -- > > Claus Ibsen > > - > > http://davsclaus.com @davsclaus > > Camel in Action 2: https://www.manning.com/ibsen2 > > -- Claus Ibsen - http://davsclaus.com @davsclaus Camel in
Re: Read header value in Camel xpath
If I get it correctly, you may be interested in the "in:header" xpath function: https://github.com/apache/camel/blob/master/components/camel-xpath/src/main/docs/xpath-language.adoc https://github.com/apache/camel/blob/camel-2.24.x/camel-core/src/test/java/org/apache/camel/language/XPathFunctionTest.java Hope that help, Alex On Wed, Jun 26, 2019 at 9:42 AM Bikash Kaushik wrote: > Hi, > > I want to use header value in xpath to filter message based on header > value. > > On Wed, Jun 26, 2019, 12:46 PM Claus Ibsen wrote: > > > Hi > > > > What do you mean? > > > > Do you mean you need to use a Camel Message header to build your xpath > > expression, or do you want from the xpath expression to refer to a > > Camel header. Its a bit unclear from your example. > > > > On Wed, Jun 26, 2019 at 8:45 AM Bikash Kaushik > > wrote: > > > > > > Hi, > > > > > > I want to know , how to pass header value in Camel xpath , > > > > > > > > > > > headerName="xpathValue">*//*[local-name()='EmployeeDataResult']/text() > > > > > > I have to pass header value in between xapth. > > > > > > > > > Regards, > > > Bikash Kaushik > > > > > > > > -- > > Claus Ibsen > > - > > http://davsclaus.com @davsclaus > > Camel in Action 2: https://www.manning.com/ibsen2 > > >
Re: Read header value in Camel xpath
Yes , thanks. On Wed, Jun 26, 2019, 1:37 PM Alex Dettinger wrote: > If I get it correctly, you may be interested in the "in:header" xpath > function: > > https://github.com/apache/camel/blob/master/components/camel-xpath/src/main/docs/xpath-language.adoc > > https://github.com/apache/camel/blob/camel-2.24.x/camel-core/src/test/java/org/apache/camel/language/XPathFunctionTest.java > > Hope that help, > Alex > > On Wed, Jun 26, 2019 at 9:42 AM Bikash Kaushik > wrote: > > > Hi, > > > > I want to use header value in xpath to filter message based on header > > value. > > > > On Wed, Jun 26, 2019, 12:46 PM Claus Ibsen > wrote: > > > > > Hi > > > > > > What do you mean? > > > > > > Do you mean you need to use a Camel Message header to build your xpath > > > expression, or do you want from the xpath expression to refer to a > > > Camel header. Its a bit unclear from your example. > > > > > > On Wed, Jun 26, 2019 at 8:45 AM Bikash Kaushik > > > wrote: > > > > > > > > Hi, > > > > > > > > I want to know , how to pass header value in Camel xpath , > > > > > > > > > > > > > > > > > headerName="xpathValue">*//*[local-name()='EmployeeDataResult']/text() > > > > > > > > I have to pass header value in between xapth. > > > > > > > > > > > > Regards, > > > > Bikash Kaushik > > > > > > > > > > > > -- > > > Claus Ibsen > > > - > > > http://davsclaus.com @davsclaus > > > Camel in Action 2: https://www.manning.com/ibsen2 > > > > > >
Re: JMS Transaction rollback with dead letter channel using Apache Camel
Hi, I have tried with OnException and doTry/doCatch error handler still I am getting the same behaviour as message sends to JMS_ONE. error handler java.lang.RuntimeException java.lang.IllegalArgumentException true I have tried with adding rollback in error handler, in that case message not written to JMS_ONE queue, it has redelivered message to source queue JMS_IN for some count but finally, it has not sent the message to ERROR. Kindly advise if I miss anything!!! On Wed, 26 Jun 2019 at 13:25, Claus Ibsen wrote: > Hi > > You are using dead letter channel as Camel's error handler which will > mark the message as succesfull. > Just use a regular error handler > > On Wed, Jun 26, 2019 at 9:50 AM sujin sr wrote: > > > > Thanks for the Response. > > > > Before implementing 'transacted JMS acknowledge' i have tried to create > > separate JMS component for ERROR. But still, I see the same behaviour as > > message sent to the JMS_ONE not rollbacked > > > > I have added this beans and changed ERROR route like below > > > > > class="org.apache.camel.component.jms.JmsConfiguration"> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Where i am missing anything here, kindly advise > > > > > > > > On Wed, 26 Jun 2019 at 12:51, Claus Ibsen wrote: > > > > > Hi > > > > > > Its likely better to use just the brokers error handling with > > > transaction (transacted JMS acknowledge). > > > Then you can configure the broker with redelivery and its dead letter > > > queue. > > > Then you dont need any Camel error handler, and only need to setup JMS > > > component for transacted JMS ack mode. > > > > > > Otherwise in your use case, you cannot both rollback sending to ONE > > > and TWO but send to ERROR as they are all in the same transaction. > > > So in this example you need to setup a 2nd JMS component for ERROR, so > > > the JMS can rollback, and ERROR can commit. Also mind that the > > > incoming endpoint is also JMS and it will also rollback as part of ONE > > > and TWO. So you will get the message redelibered again from the > > > broker. > > > > > > So try instead to just use broker error handling. > > > > > > > > > > > > > > > On Wed, Jun 26, 2019 at 9:01 AM sujin sr wrote: > > > > > > > > I am facing a issue while trying to implement JMS transaction using > > > Camel. > > > > > > > > Here is the scenario > > > > > > > > 1. Primary route which read the message from the queue(JMS_IN), pass > the > > > > same exchange to the two sub route(direct route) > > > > 2. First sub route process the message successfully and send to the > > > another > > > > queue(JMS_ONE) > > > > 3. Second sub route process the message and send to the another > > > > queue(JMS_TWO). > > > > 4. If any error occurred during the sub route processing all the > message > > > > should rollback and original message sent to another queue(ERROR) > that is > > > > dead letter queue. > > > > 5. In the example Context I have created throw RuntimeException > during > > > > second sub route processing. > > > > 6. So expected behavior is to move the original message to ERROR > queue, > > > > same time no message should send to JMS_ONE & JMS_TWO > > > > 7. But actual behavior is original message was sent to the ERROR > queue, > > > but > > > > message sent the JMS_ONE. > > > > > > > > I am using Apache Camel 2.24.0, Jboss HornetQ and spring transaction > > > > manager. > > > > > > > > Kindly help me on this, I am struck at this for couple of days > > > > > > > > Camel Context Below > > > > > > > > class="org.springframework.jndi.JndiTemplate"> > > > > > > > > > > > > > > > > > > > key="java.naming.factory.initial">org.jboss.naming.remote.client.InitialContextFactory > > > > > > > key="java.naming.provider.url">http-remoting://localhost:9089 > > > > > > > > key="java.naming.security.principal">TESTUSR > > > > > > key="java.naming.security.credentials">TESTUSR > > > > > > > > > > > > > > > > > > > > > > class="org.springframework.jms.core.JmsTemplate"> > > > > ref="jmsConnectionFactory"/> > > > > > > > > > > > > > > > class="org.springframework.jndi.JndiObjectFactoryBean"> > > > > > > > > value="jms/RemoteConnectionFactory"/> > > > > > > > > > > > > > > > class="org.springframework.jms.connection.JmsTransactionManager"> > > > > ref="jmsConnectionFactory"/> > > > > > > > > > > > > > > > class="org.apache.camel.component.jms.JmsConfiguration"> > > > > ref="jmsConnectionFactory"/> > > > > ref="jmsTransactionManager"/> > > > > > > > > > > > > > >
RE: How to set client or clientFactory in the FhirConfiguration object?
I still have problem setting my custom client in the FhirConfiguration. I have implemented a custom client TestClient implementing the IGenericClient interface and I annotated the class with @Component. I also implemented a route where I try to set my custom client using the following strategy .setHeader(Exchange.HTTP_QUERY, simple("client=#testClient")) When I debug a test that activates the route I break in the first line of the createEndpoint method of the FhirComponent and inspect the client variable of the endpoint it is null. I am running this in a Spring configuration. Paw B Sørensen paw.b.soren...@systematic.com -Original Message- From: Claus Ibsen Sent: 25. juni 2019 07:42 To: users@camel.apache.org Subject: Re: How to set client or clientFactory in the FhirConfiguration object? Hi I have fixed this for master, eg Camel 3 On Fri, Jun 21, 2019 at 2:20 PM Claus Ibsen wrote: > > And btw you should still be able to configure them as query > parameters, as those @UriParam etc are for documentation purposes. > > On Fri, Jun 21, 2019 at 2:19 PM Claus Ibsen wrote: > > > > Hi > > > > Ah those 2 are wrong they should be @UriParam also. You are welcome > > to log a JIRA and provide a PR > > > > On Fri, Jun 21, 2019 at 10:10 AM Paw B Sørensen > > wrote: > > > > > > The camel fhir component supports setting several query > > > parameters. In the implementation of FhirConfiguration all of these > > > parameters are annotated with @UriParam. Also in the implementation of > > > FhirConfiguration I find the client and clientFactory variables but they > > > are annotated with @Metadata. Can I make my own custom implementation of > > > the client to intercept whenever a response code 4xx is received? And is > > > it possible to set these Metadata values in my camel route? > > > > > > > > > -- > > Claus Ibsen > > - > > http://davsclaus.com @davsclaus > > Camel in Action 2: https://www.manning.com/ibsen2 > > > > -- > Claus Ibsen > - > http://davsclaus.com @davsclaus > Camel in Action 2: https://www.manning.com/ibsen2 -- Claus Ibsen - http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
Re: How to set client or clientFactory in the FhirConfiguration object?
Hi Paw, I'm not sure why you're trying to set the custom IGenericClient through the Camel header; I'd need more info on your requirements. If you can link to a github project or whatnot that'd be great. As stated, you can set the custom client in your route URI directly [1] referencing your bean in your spring registry e.g .to('fhir://create/resource?client=#customClientBeanName') You can also set it directly on the component level if you want to use it in multiple URIs [2] HTH, John. [1] https://github.com/apache/camel/blob/b9a3117f19dd19abd2ea8b789c42c3e86fe4c488/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/FhirCustomClientConfigurationIT.java#L67 [2] https://github.com/apache/camel/blob/b9a3117f19dd19abd2ea8b789c42c3e86fe4c488/components/camel-fhir/camel-fhir-component/src/main/java/org/apache/camel/component/fhir/FhirComponent.java#L79 On Wed, Jun 26, 2019 at 12:43 PM Paw B Sørensen < paw.b.soren...@systematic.com> wrote: > I still have problem setting my custom client in the FhirConfiguration. I > have implemented a custom client TestClient implementing the IGenericClient > interface and I annotated the class with @Component. I also implemented a > route where I try to set my custom client using the following strategy > > .setHeader(Exchange.HTTP_QUERY, simple("client=#testClient")) > > When I debug a test that activates the route I break in the first line of > the createEndpoint method of the FhirComponent and inspect the client > variable of the endpoint it is null. > > I am running this in a Spring configuration. > > Paw B Sørensen > paw.b.soren...@systematic.com > > > -Original Message- > From: Claus Ibsen > Sent: 25. juni 2019 07:42 > To: users@camel.apache.org > Subject: Re: How to set client or clientFactory in the FhirConfiguration > object? > > Hi > > I have fixed this for master, eg Camel 3 > > On Fri, Jun 21, 2019 at 2:20 PM Claus Ibsen wrote: > > > > And btw you should still be able to configure them as query > > parameters, as those @UriParam etc are for documentation purposes. > > > > On Fri, Jun 21, 2019 at 2:19 PM Claus Ibsen > wrote: > > > > > > Hi > > > > > > Ah those 2 are wrong they should be @UriParam also. You are welcome > > > to log a JIRA and provide a PR > > > > > > On Fri, Jun 21, 2019 at 10:10 AM Paw B Sørensen > > > wrote: > > > > > > > > The camel fhir component supports setting several query > > > > parameters. In the implementation of FhirConfiguration all of these > parameters are annotated with @UriParam. Also in the implementation of > FhirConfiguration I find the client and clientFactory variables but they > are annotated with @Metadata. Can I make my own custom implementation of > the client to intercept whenever a response code 4xx is received? And is it > possible to set these Metadata values in my camel route? > > > > > > > > > > > > > -- > > > Claus Ibsen > > > - > > > http://davsclaus.com @davsclaus > > > Camel in Action 2: https://www.manning.com/ibsen2 > > > > > > > > -- > > Claus Ibsen > > - > > http://davsclaus.com @davsclaus > > Camel in Action 2: https://www.manning.com/ibsen2 > > > > -- > Claus Ibsen > - > http://davsclaus.com @davsclaus > Camel in Action 2: https://www.manning.com/ibsen2 >
Re: How to unmarshal when you don't know what you're unmarshalling?
Hi, Claus. Thanks for the response. Actually, I always do the following in my Route.configure(): getContext().setStreamCaching(true); (I do it by default now. I can't even remember when I *wouldn't* want to do it...) Anyway, even with stream caching on, the body is getting nulled out in this simple route if I use xpath(). (So that's 2 things that were nulling the body: xpath() and unmarshal().) At any rate, it works fine using "simple" and doing a string op. Maybe at some point I'll revisit trying to figure out what's going on with xpath()... Thanks again. Ron > On June 25, 2019 at 11:24 PM Claus Ibsen wrote: > > > Hi > > For null body, see this FAQ > http://camel.apache.org/why-is-my-message-body-empty.html > > On Tue, Jun 25, 2019 at 10:24 PM Ron Cecchini wrote: > > > > > > Sweet Baby Jesus, I got it, guys! Thank you so much. > > > > I hadn't used xpath() before, so I started reading and playing with it. > > > > The messages I have to parse are pretty simple, with unique root tags: > > "StatusMessage" or "DataMessage". > > > > So I tried the following and started having success with it: > > > > .choice() > > .when().xpath("name(/*) = 'StatusMessage'") > > .to("direct:StatusMessage") > > .when().xpath("name(/*) = 'DataMessage'") > > .to("direct:DataMessage") > > .otherwise() > > .log("* ERROR! Got an unknown message > > type!\n${body}"); > > > > But then I quickly saw that the body was *again* null when entering the 2 > > "direct" routes. > > > > I decided not to waste too much time trying to figure out the xpath > > idiosyncracies and instead thought about our old friend "simple" and > > working with the original message as a string (i.e. no unmarshalling). > > > > It worked like a charm! > > > > Ultimately I went with the following: > > > > from("netty4:udp://[blahblah]") > > .choice() > > .when(simple("${bodyAs(String)} contains > > 'StatusMessage'")) > > .to("direct:StatusMessage") > > .when(simple("${bodyAs(String)} contains > > 'DataMessage'")) > > .to("direct:DataMessage") > > .otherwise() > > .log("* ERROR! Got an unknown message > > type!\n${body}"); > > > > from("direct:StatusMessage") > > .doTry() > > .unmarshal(statusMessageFormat) > > .process(new StatusMessageProcessor()) > > .doCatch(Exception.class) > > .log("*** ERROR: handling Status Message - exception: > > ${exception.message}"); > > > > > On June 25, 2019 at 12:52 PM "Hart, James W." wrote: > > > > > > > > > You can unmarshal well formed xml without the type and then use an xpath > > > and choice to decide what to do with the different XMLs. This might mean > > > some extra steps, but it should work. The error handling method could be > > > a little messy. > > > > > > Another lower level way would be to inspect what's in the body in a > > > processor and setting a header or property of the type. Then you can use > > > a choice to basically route to the correct unmarshal code. You can use > > > String find, or regex if you want to do this and keep the body intact, > > > then you can unmarshal the way you do below. > > > > > > > > > -Original Message- > > > From: Ron Cecchini [mailto:roncecch...@comcast.net] > > > Sent: Tuesday, June 25, 2019 12:10 PM > > > To: users@camel.apache.org > > > Subject: Re: How to unmarshal when you don't know what you're > > > unmarshalling? > > > > > > [[ SEI WARNING *** This email was sent from an external source. Do not > > > open attachments or click on links from unknown or suspicious senders. > > > *** ]] > > > > > > > > > Unfortunately, I can't. > > > > > > The device I'm listening to sends a mix of "Status" and "Data" messages > > > over the same UDP port. > > > > > > I've been trying to implement the strategy I alluded to, using > > > doTry/doCatch to try unmarshalling as one message type, and then the > > > other ... but things have gotten gnarly: > > > > > > I first solved the problem having to do with the Camel Java DSL not > > > handling nested doTry blocks very well. (I broke up the route, used some > > > "direct" routes, etc.) > > > > > > Ok, fine. > > > > > > The problem I've been banging my head on *now*, though, is the fact that > > > it *seems* that trying to do the first unmarshal() blows away any > > > properties I set on the exchange! What the heck... > > > > > > In other words: > > > > > > When I first get something off the wire (the message over UDP), I save a > > > copy of the body: > > > > > > .setProperty("bodyCopy", body()) > > > > > > Here's the first bit of processing. I've added a bunch of logging
Re: splitResults option shows unknown in google-sheets-stream component
In, Camel google sheet, maxResult option didn't work. And when I start my route, it continuosly do polling and do not stop after getting sheet body. Regards, Bikash Kaushik On Wed, Jun 26, 2019 at 8:53 AM Claus Ibsen wrote: > Hi > > Again make sure to align and use the same Camel version. You have mixed. > And use the Fuse Camel version as suggested by Christoph. > > [INFO] | \- > org.apache.camel:camel-core-osgi:jar:2.21.0.fuse-740025:compile > [INFO] +- org.apache.camel:camel-google-sheets:jar:2.24.1:compile > > And you can ask Red Hat for help/support as its their product. Here we > only support upstream and vanilla Apache Camel. > > On Wed, Jun 26, 2019 at 3:26 AM Bikash Kaushik > wrote: > > > > Hi, > > > > Please find updated mvn dependency tree, as suggested by you to update > > version, still I'm not getting *splitResults * option in google > spreadsheet. > > > > [INFO] +- org.apache.camel:camel-core:jar:2.23.2.fuse-740002:compile > > [INFO] | +- com.sun.xml.bind:jaxb-core:jar:2.3.0:compile > > [INFO] | \- com.sun.xml.bind:jaxb-impl:jar:2.3.0:compile > > [INFO] +- org.apache.camel:camel-blueprint:jar:2.23.2.fuse-740002:compile > > [INFO] | +- > org.apache.camel:camel-core-xml:jar:2.21.0.fuse-740025:compile > > [INFO] | \- > org.apache.camel:camel-core-osgi:jar:2.21.0.fuse-740025:compile > > [INFO] +- org.apache.camel:camel-google-sheets:jar:2.24.1:compile > > [INFO] | +- com.google.api-client:google-api-client:jar:1.22.0:compile > > [INFO] | | \- com.google.guava:guava-jdk5:jar:17.0:compile > > [INFO] | +- > com.google.oauth-client:google-oauth-client:jar:1.22.0:compile > > [INFO] | | +- > com.google.http-client:google-http-client:jar:1.22.0:compile > > [INFO] | | | \- org.apache.httpcomponents:httpclient:jar:4.5.5:compile > > [INFO] | | | +- > org.apache.httpcomponents:httpcore:jar:4.4.9:compile > > [INFO] | | | \- commons-codec:commons-codec:jar:1.11:compile > > [INFO] | | \- com.google.code.findbugs:jsr305:jar:1.3.9:compile > > [INFO] | +- > > com.google.http-client:google-http-client-jackson2:jar:1.22.0:compile > > [INFO] | | \- > com.fasterxml.jackson.core:jackson-core:jar:2.8.11:compile > > [INFO] | \- > > com.google.apis:google-api-services-sheets:jar:v4-rev551-1.22.0:compile > > [INFO] +- org.slf4j:slf4j-api:jar:1.7.10:compile > > [INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.10:compile > > [INFO] +- log4j:log4j:jar:1.2.17:compile > > [INFO] \- > > > org.apache.camel:camel-test-blueprint:jar:2.21.0.fuse-730078-redhat-1:test > > [INFO]+- org.apache.camel:camel-test:jar:2.21.0.fuse-740025:test > > [INFO]+- > > org.apache.aries.proxy:org.apache.aries.proxy.api:jar:1.1.0:test > > [INFO]+- org.apache.aries.proxy:org.apache.aries.proxy:jar:1.1.4:test > > [INFO]+- > > org.apache.aries.blueprint:org.apache.aries.blueprint.api:jar:1.0.1:test > > [INFO]+- > > > org.apache.aries.blueprint:org.apache.aries.blueprint.core:jar:1.10.1:test > > [INFO]| \- > > org.apache.aries.quiesce:org.apache.aries.quiesce.api:jar:1.0.0:test > > [INFO]+- org.apache.aries.blueprint:org.apache.aries.blueprint.cm: > > jar:1.3.1:test > > [INFO]+- org.apache.aries:org.apache.aries.util:jar:1.1.3:test > > [INFO]+- org.apache.felix:org.apache.felix.connect:jar:0.2.0:test > > [INFO]+- > org.ops4j.pax.swissbox:pax-swissbox-tinybundles:jar:1.3.2:test > > [INFO]| +- org.ops4j.base:ops4j-base-lang:jar:1.5.0:test > > [INFO]| +- org.ops4j.base:ops4j-base-io:jar:1.5.0:test > > [INFO]| | \- org.ops4j.base:ops4j-base-monitors:jar:1.5.0:test > > [INFO]| +- org.ops4j.base:ops4j-base-store:jar:1.5.0:test > > [INFO]| \- org.ops4j.pax.swissbox:pax-swissbox-bnd:jar:1.8.3:test > > [INFO]| \- biz.aQute.bnd:bndlib:jar:2.4.0:test > > [INFO]+- commons-logging:commons-logging:jar:1.2:compile > > [INFO]+- junit:junit:jar:4.12:test > > [INFO]| \- org.hamcrest:hamcrest-core:jar:1.3:test > > [INFO]\- > org.apache.felix:org.apache.felix.configadmin:jar:1.9.14:test > > > > On Tue, Jun 25, 2019 at 11:30 PM Christoph Deppisch < > cdeppi...@redhat.com> > > wrote: > > > > > try to use 2.21.0.fuse-740028 or a later version. This should work as > it > > > has the google-sheets component with splitResults support. > > > > > > On Tue, Jun 25, 2019 at 6:39 PM Claus Ibsen > wrote: > > > > > > > Hi > > > > > > > > Okay you are using Camel 2.21, so you should look at the docs for > that > > > > version. > > > > > > > > Also you are using Red Hat Fuse, and they also have docs for the > > > > components that matches the Camel version they ship in their product. > > > > > > > > On Tue, Jun 25, 2019 at 5:30 PM Bikash Kaushik > > > > wrote: > > > > > > > > > > Hi, > > > > > > > > > > Thanks for reply , > > > > > > > > > > *Please find gooogle-sheets-stream endpoint URI :* > > > > > > > > > > > > > > > > > > > > > > uri="google-sheets-stream://spreadsheets?accessToken=ya29.GlsxB7BpSyCqPcOJnINvy_MzbD4_zn_wVzc8Ndtpxj1-q_0tO3RfFNOO4y9-HWt4qiHY2X_
Process single file if destination location is empty
Hi, I am trying to write a process that will use a file endpoint to drop a single file to a directory. The file should be dropped when destination directory is empty otherwise endpoint will wait until destination directory gets empty. -- *Regards,* *Bikash Kaushik,* *NIT Jamshedpur*
How to use simple expression in properties file?
Is it possible to put a simple() expression in a properties string and have Camel evaluate it at run time? Here's what I'm trying to do: - Set a message header ID with a value I want to use later - Use .toD("{{event.sink}}") application.properties can then have something like: event.sink = simple("file://.?fileName=status-${header.ID}.txt") The goal being to have a message body written to a file whose name includes the ID header value. When I try to run this I get an exception: Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'header.ID' in value "simple("file://.?fileName=status-${header.ID}.txt")" Thanks, -Steve
Re: How to use simple expression in properties file?
On Wed, Jun 26, 2019 at 11:49 PM Steve Huston wrote: > > Is it possible to put a simple() expression in a properties string and have > Camel evaluate it at run time? > > Here's what I'm trying to do: > - Set a message header ID with a value I want to use later > - Use .toD("{{event.sink}}") > > application.properties can then have something like: > > event.sink = simple("file://.?fileName=status-${header.ID}.txt") > toD using a string is simple language already, so just use event.sink = file://.?fileName=status-${header.ID}.txt > The goal being to have a message body written to a file whose name includes > the ID header value. > > When I try to run this I get an exception: > > Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder > 'header.ID' in value "simple("file://.?fileName=status-${header.ID}.txt")" > And you can use $simple{xxx} syntax for the fileName value > Thanks, > -Steve -- Claus Ibsen - http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2