How onWhen filter really works?
Hello guys, These days I received the task to implement a redelivery process for one of our camel apps. In summary, our application consumes some REST services and, based on the user's configuration, it must handle the HttpOperationFailedException retries differently, for example: - If the service returns HttpStatus 404 and the business error is "ClientNotFound", our application should retry only 5 times (any other 404 shouldn't be redelivered). - Also, if the service returns HttpStatus 503 and the business error is "ServiceUnavailable", our application should retry only 2 times. - Finally, each error should have its own retry count. With that in mind, I soon found out that I couldn't rely on the maximumRedeliveries, since it's shared between all Exceptions (see https://stackoverflow.com/questions/13684775/camel-retry-control-with-multiple-exceptions), but I managed to accomplish my goal using the onWhen and retryWhile, like so: //For each user configuration, I append this to the route... .onException(HttpOperationFailedException .class) .onWhen(simple("${exchangeProperty[status]} == " +cfg.getHttpStatus() + " && ${exchangeProperty[code]} == '"+cfg.getBusinessCode+"'")) .retryWhile(simple("${exchangeProperty[ClientNotFound]} < "+cfg.getMaxRetries(), Boolean.class)) The issue is that while I was stressing the possible scenarios for this retry process, I reached one that I couldn't understand what was going on inside camel. So, let's say that for the first 3 requests I receive the 404 - ClientNotFound, which are configured to do 5 retries, but after that, I start receiving a 404 - PageNotFound which should not perform any retry. In this case, I noticed that this new exception wasn't being rejected by the onWhen and the message got stuck in the retry loop. I understand that this infinity loop might be caused by the retryWhile condition since the ClientNotFound's counter never became greater than 5 and It could be solved by just adding the business code condition to it as shown below: .retryWhile(simple("${exchangeProperty[ClientNotFound]} < "+cfg.getMaxRetries()+" && ${exchangeProperty[code]} == '"+cfg.getBusinessCode+"'", Boolean.class)) But I can't understand why this infinity loop doesn't happen if I add a "generic" onException(HttpOperationFailedException .class) without any retry policy to my route OR if I raise an exception which is mapped by another onWhen, for example, 503 - ServiceUnavailable. I tried to debug the route execution, but since I'm a Camel newbie, I couldn’t understand what was going on! Could someone help me understand what is really happening behind the curtains or what I'm doing wrong? See below the jUnit scenario for more details: import java.util.concurrent.atomic.AtomicLong; import org.apache.camel.EndpointInject; import org.apache.camel.Exchange; import org.apache.camel.Produce; import org.apache.camel.ProducerTemplate; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Test; public class FooTest extends CamelTestSupport { private static final String DIRECT_DUMMY = "direct:dummy"; @EndpointInject(uri = "mock:result") protected MockEndpoint resultEndpoint; @Produce(uri = "direct:start") protected ProducerTemplate template; @Test public void shouldRedeliverOnErrors() throws Exception { resultEndpoint.expectedBodiesReceived("Body"); template.sendBodyAndHeader(DIRECT_DUMMY, "Body", "Header", "HV"); resultEndpoint.assertIsNotSatisfied(); } protected RouteBuilder createRouteBuilder() { return new RouteBuilder() { @Override public void configure() throws Exception { from(DIRECT_DUMMY) .onException(Exception.class) .onWhen(simple("${exchangeProperty[status]} == 404 && ${exchangeProperty[code]} == 'ClientNotFound'")) .retryWhile(simple("${exchangeProperty[ClientNotFound]} < 5", Boolean.class)) .bean(Processor.class, "maxRetriesReached") .end() .onException(Exception.class) .onWhen(simple("${exchangeProperty[status]} == 503 && ${exchangeProperty[code]} == 'ServiceUnavailable'")) .retryWhile(simple("${exchangeProperty[ServiceUnavailable]} < 2", Boolean.class)) .bean(Processor.class, "maxRetriesReached") .end() //"generic" onException // .onException(Exception.class) // .bean(Processor.class, "noRetries") // .end() .bean(Processor.class, "process") .to(resultEndpoint) .end(); } }; } public static class Processor { private static AtomicLong retryState = new AtomicLong(0L); public void process(Exchange e) throws Exception { long count = retryState.getAndIncrement(); if (count < 3) {
Re: Camel + Spring Boot as a backend?
Thanks, Mark, and everyone. To be clear, I’ve already written a half dozen or so Spring Boot / Camel apps (using Maven archetypes in IntelliJ), and I love it. I just wanted to know if it be advisable to build on what I know to complete a simple, low-throughput, low-availability, Java backend. And if I had read past chapter 5, I would’ve seen that Claus already starts describing in chapter 7something like what I want... Thanks again. Ron -- Original Message -- From: Mark Nuttall To: users@camel.apache.org Sent: April 16, 2019 at 5:52 PM Subject: Re: Camel + Spring Boot as a backend? I use Spring Boot extensively with Camel. It is a perfect pair for what you are asking about. I have i running locally on servers and also in aws in EC2. Works great both ways. Start by going to start.spring.io and pick Camel and JDBC (or JPA,etc), or if you have IntelliJ or STS you can just use those to create a spring boot app. You will want to add "web" and actuator so you can monitor the health of you app. On Tue, Apr 16, 2019 at 11:34 AM Luiz Eduardo Valmontwrote:>I use Spring Boot, Camel and Quartz on a symbiotic-ish application. There's>REST endpoints as well.>>On Tue, 16 Apr 2019, 11:54 Michael Joyner,>wrote:>>>I assume using Spring MVC for the front end. I think that you would be>>fine. Someone else will probably chime in from the project and confirm.On Tue, Apr 16, 2019 at 7:29 AM Ron Cecchini>>wrote:>Hi, all. If/when anyone has any time, I was hoping to get a few quick>>>opinions.>>>(and I do mean be brief; I don't want anyone wasting time on this.)>>*** Could Camel + Spring Boot *alone* be used to implement the Java>>>portion of>>>*** a simple backend for a low-throughput, non-realtime system that>>>doesn't need to scale?>>Backstory: I was thinking about the web site for my sons' little league>>(I>>>didn't create it),>>>and what I might do if I were to redo it totally from scratch without>>>using Wordpress, etc.>>This quickly morphed (away from baseball and) into what it would take>to>>>implement what>>>basically amounts to a simple inventory tracking system of sorts.>>And the picture I had in mind is something like. Imagine you are an>>>online business with:>>- 100 customers or offices (whatever - call them "sites")>>- Each "site" is going to place at most, on average, 1 order a day>>>where an "order" might be to ship goods to another site, request>goods>>>from another site,>>>or order goods from a vendor (whatever - the details of the "order">>>don't matter)>>- Each site now needs to be able to track the progress of its order>>(where>>>its good are)>>Basically, something like a poor man's Amazon or USPS/UPS/FedEx>tracking>>>system.>>Again, the system doesn't need to scale because there will never be>more>>>than 100-200 sites.>>>Sites will spend the majority of their time inactive; i.e. not placing>>>orders.>>>Each order is a simple movement of goods (shipping or>>procuring/receiving).>>>There are no real time demands to know exactly where goods are. (A>daily>>>update would suffice.)>>Since the concurrency needs seem to be negligible, I don't see a need>for>>>a JBoss app server,>>>or a distributed server farm, etc. I feel like Camel will already>handle>>>whatever concurrency>>>issues that may arise, and its ability to seamlessly integrate with so>>>many others means alot of>>>the work is already done for me.>>What are your thoughts on trying to implement the backend of this>simple>>>inventory system with>>>a pretty simple Spring Boot + Camel + RDMS application, hosted on a>beefy>>>server and not running>>>in an app server or Docker?>>Thanks.>>Ron>-->>Sincerely,>>Michael Joyner>>>
Re: Camel + Spring Boot as a backend?
I use Spring Boot extensively with Camel. It is a perfect pair for what you are asking about. I have i running locally on servers and also in aws in EC2. Works great both ways. Start by going to start.spring.io and pick Camel and JDBC (or JPA,etc), or if you have IntelliJ or STS you can just use those to create a spring boot app. You will want to add "web" and actuator so you can monitor the health of you app. On Tue, Apr 16, 2019 at 11:34 AM Luiz Eduardo Valmont < valm...@alis-sol.com.br> wrote: > I use Spring Boot, Camel and Quartz on a symbiotic-ish application. There's > REST endpoints as well. > > On Tue, 16 Apr 2019, 11:54 Michael Joyner, > wrote: > > > I assume using Spring MVC for the front end. I think that you would be > > fine. Someone else will probably chime in from the project and confirm. > > > > On Tue, Apr 16, 2019 at 7:29 AM Ron Cecchini > > wrote: > > > > > Hi, all. If/when anyone has any time, I was hoping to get a few quick > > > opinions. > > > (and I do mean be brief; I don't want anyone wasting time on this.) > > > > > > *** Could Camel + Spring Boot *alone* be used to implement the Java > > > portion of > > > *** a simple backend for a low-throughput, non-realtime system that > > > doesn't need to scale? > > > > > > Backstory: I was thinking about the web site for my sons' little league > > (I > > > didn't create it), > > > and what I might do if I were to redo it totally from scratch without > > > using Wordpress, etc. > > > > > > This quickly morphed (away from baseball and) into what it would take > to > > > implement what > > > basically amounts to a simple inventory tracking system of sorts. > > > > > > And the picture I had in mind is something like. Imagine you are an > > > online business with: > > > > > > - 100 customers or offices (whatever - call them "sites") > > > > > > - Each "site" is going to place at most, on average, 1 order a day > > > where an "order" might be to ship goods to another site, request > goods > > > from another site, > > > or order goods from a vendor (whatever - the details of the "order" > > > don't matter) > > > > > > - Each site now needs to be able to track the progress of its order > > (where > > > its good are) > > > > > > Basically, something like a poor man's Amazon or USPS/UPS/FedEx > tracking > > > system. > > > > > > Again, the system doesn't need to scale because there will never be > more > > > than 100-200 sites. > > > Sites will spend the majority of their time inactive; i.e. not placing > > > orders. > > > Each order is a simple movement of goods (shipping or > > procuring/receiving). > > > There are no real time demands to know exactly where goods are. (A > daily > > > update would suffice.) > > > > > > Since the concurrency needs seem to be negligible, I don't see a need > for > > > a JBoss app server, > > > or a distributed server farm, etc. I feel like Camel will already > handle > > > whatever concurrency > > > issues that may arise, and its ability to seamlessly integrate with so > > > many others means alot of > > > the work is already done for me. > > > > > > What are your thoughts on trying to implement the backend of this > simple > > > inventory system with > > > a pretty simple Spring Boot + Camel + RDMS application, hosted on a > beefy > > > server and not running > > > in an app server or Docker? > > > > > > Thanks. > > > > > > Ron > > > > > > > > > -- > > Sincerely, > > Michael Joyner > > >
Re: Camel + Spring Boot as a backend?
I use Spring Boot, Camel and Quartz on a symbiotic-ish application. There's REST endpoints as well. On Tue, 16 Apr 2019, 11:54 Michael Joyner, wrote: > I assume using Spring MVC for the front end. I think that you would be > fine. Someone else will probably chime in from the project and confirm. > > On Tue, Apr 16, 2019 at 7:29 AM Ron Cecchini > wrote: > > > Hi, all. If/when anyone has any time, I was hoping to get a few quick > > opinions. > > (and I do mean be brief; I don't want anyone wasting time on this.) > > > > *** Could Camel + Spring Boot *alone* be used to implement the Java > > portion of > > *** a simple backend for a low-throughput, non-realtime system that > > doesn't need to scale? > > > > Backstory: I was thinking about the web site for my sons' little league > (I > > didn't create it), > > and what I might do if I were to redo it totally from scratch without > > using Wordpress, etc. > > > > This quickly morphed (away from baseball and) into what it would take to > > implement what > > basically amounts to a simple inventory tracking system of sorts. > > > > And the picture I had in mind is something like. Imagine you are an > > online business with: > > > > - 100 customers or offices (whatever - call them "sites") > > > > - Each "site" is going to place at most, on average, 1 order a day > > where an "order" might be to ship goods to another site, request goods > > from another site, > > or order goods from a vendor (whatever - the details of the "order" > > don't matter) > > > > - Each site now needs to be able to track the progress of its order > (where > > its good are) > > > > Basically, something like a poor man's Amazon or USPS/UPS/FedEx tracking > > system. > > > > Again, the system doesn't need to scale because there will never be more > > than 100-200 sites. > > Sites will spend the majority of their time inactive; i.e. not placing > > orders. > > Each order is a simple movement of goods (shipping or > procuring/receiving). > > There are no real time demands to know exactly where goods are. (A daily > > update would suffice.) > > > > Since the concurrency needs seem to be negligible, I don't see a need for > > a JBoss app server, > > or a distributed server farm, etc. I feel like Camel will already handle > > whatever concurrency > > issues that may arise, and its ability to seamlessly integrate with so > > many others means alot of > > the work is already done for me. > > > > What are your thoughts on trying to implement the backend of this simple > > inventory system with > > a pretty simple Spring Boot + Camel + RDMS application, hosted on a beefy > > server and not running > > in an app server or Docker? > > > > Thanks. > > > > Ron > > > > > -- > Sincerely, > Michael Joyner >
Re: Camel + Spring Boot as a backend?
I assume using Spring MVC for the front end. I think that you would be fine. Someone else will probably chime in from the project and confirm. On Tue, Apr 16, 2019 at 7:29 AM Ron Cecchini wrote: > Hi, all. If/when anyone has any time, I was hoping to get a few quick > opinions. > (and I do mean be brief; I don't want anyone wasting time on this.) > > *** Could Camel + Spring Boot *alone* be used to implement the Java > portion of > *** a simple backend for a low-throughput, non-realtime system that > doesn't need to scale? > > Backstory: I was thinking about the web site for my sons' little league (I > didn't create it), > and what I might do if I were to redo it totally from scratch without > using Wordpress, etc. > > This quickly morphed (away from baseball and) into what it would take to > implement what > basically amounts to a simple inventory tracking system of sorts. > > And the picture I had in mind is something like. Imagine you are an > online business with: > > - 100 customers or offices (whatever - call them "sites") > > - Each "site" is going to place at most, on average, 1 order a day > where an "order" might be to ship goods to another site, request goods > from another site, > or order goods from a vendor (whatever - the details of the "order" > don't matter) > > - Each site now needs to be able to track the progress of its order (where > its good are) > > Basically, something like a poor man's Amazon or USPS/UPS/FedEx tracking > system. > > Again, the system doesn't need to scale because there will never be more > than 100-200 sites. > Sites will spend the majority of their time inactive; i.e. not placing > orders. > Each order is a simple movement of goods (shipping or procuring/receiving). > There are no real time demands to know exactly where goods are. (A daily > update would suffice.) > > Since the concurrency needs seem to be negligible, I don't see a need for > a JBoss app server, > or a distributed server farm, etc. I feel like Camel will already handle > whatever concurrency > issues that may arise, and its ability to seamlessly integrate with so > many others means alot of > the work is already done for me. > > What are your thoughts on trying to implement the backend of this simple > inventory system with > a pretty simple Spring Boot + Camel + RDMS application, hosted on a beefy > server and not running > in an app server or Docker? > > Thanks. > > Ron > -- Sincerely, Michael Joyner
Camel + Spring Boot as a backend?
Hi, all. If/when anyone has any time, I was hoping to get a few quick opinions. (and I do mean be brief; I don't want anyone wasting time on this.) *** Could Camel + Spring Boot *alone* be used to implement the Java portion of *** a simple backend for a low-throughput, non-realtime system that doesn't need to scale? Backstory: I was thinking about the web site for my sons' little league (I didn't create it), and what I might do if I were to redo it totally from scratch without using Wordpress, etc. This quickly morphed (away from baseball and) into what it would take to implement what basically amounts to a simple inventory tracking system of sorts. And the picture I had in mind is something like. Imagine you are an online business with: - 100 customers or offices (whatever - call them "sites") - Each "site" is going to place at most, on average, 1 order a day where an "order" might be to ship goods to another site, request goods from another site, or order goods from a vendor (whatever - the details of the "order" don't matter) - Each site now needs to be able to track the progress of its order (where its good are) Basically, something like a poor man's Amazon or USPS/UPS/FedEx tracking system. Again, the system doesn't need to scale because there will never be more than 100-200 sites. Sites will spend the majority of their time inactive; i.e. not placing orders. Each order is a simple movement of goods (shipping or procuring/receiving). There are no real time demands to know exactly where goods are. (A daily update would suffice.) Since the concurrency needs seem to be negligible, I don't see a need for a JBoss app server, or a distributed server farm, etc. I feel like Camel will already handle whatever concurrency issues that may arise, and its ability to seamlessly integrate with so many others means alot of the work is already done for me. What are your thoughts on trying to implement the backend of this simple inventory system with a pretty simple Spring Boot + Camel + RDMS application, hosted on a beefy server and not running in an app server or Docker? Thanks. Ron
Replace Mule with Apache Camel-cmis
Hi all, I am working on CRM project with alfresco repository. I am trying to replace Mule with Camel-cmis so I can create communication between my application and alfresco repository trough Camel-cmis component. I am trying to create routes for : * new folder * remove folder * move folder * copy folder * new file * delete file * move file * replace file * copy file * check in * check out After creating new folder route, i continued with remove folder route and got stuck. I saw in camel-cmis description that with camel I can add/read files and folders. The other operations like delete,move, copy.. are not mentioned. Is there any chance to achieve my goal with camel-cmis ?
Re: Issue with JMSReplyTo
I'm not sure I understand what your statement is saying, but I think that if you set the exchange to InOnly when it is received, the ReplyTo will not affect it. -Steve On 4/16/19, 7:58 AM, "sagheer ahmed" wrote: Hi Team, Just looking for some help with the below issue. Please do the needful. *Problem statement:* Spring boot service with apache camel consumer on IBM MQ. The route receives the request, does some processing and sends it to another queue. When the client sends a message without *JMSReplyTo* set in the header, the message goes to the 'to' endpoint. If it comes with *JMSReplyTo*, I get the below error: *org.springframework.jms.IllegalStateException: JMSWMQ2007: Failed to send a message to destination ‘TEST.OWL.REQ.01'.; nested exception is com.ibm.msg.client.jms.DetailedIllegalStateException: JMSWMQ2007: Failed to send a message to destination 'TEST.OWL.REQ.01'.* *JMS attempted to perform an MQPUT or MQPUT1; however WebSphere MQ reported an error.* *Use the linked exception to determine the cause of this error.; nested exception is com.ibm.mq.MQException: JMSCMQ0001: WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2027' ('MQRC_MISSING_REPLY_TO_Q').* *Versions: * Springboot - 1.5.1.RELEASE Camel - 2.21.0 IBM MQ - 9.0.x *Analysis:* When msg comes without *JMSReplyTo* - *JMS_IBM_MsgType=8* & with *JMSReplyTo* - *JMS_IBM_MsgType=1. *I understood that the initial value is MQMT_DATAGRAM & with replyTo queue it changes to MQMT_REQUEST If I change this header value to 1, it behaves as expected. How do I do it without touching the headers? I tried disableReplyTo option in 'from' of the route but that doesn't help. Regards, Sagheer
Issue with JMSReplyTo
Hi Team, Just looking for some help with the below issue. Please do the needful. *Problem statement:* Spring boot service with apache camel consumer on IBM MQ. The route receives the request, does some processing and sends it to another queue. When the client sends a message without *JMSReplyTo* set in the header, the message goes to the 'to' endpoint. If it comes with *JMSReplyTo*, I get the below error: *org.springframework.jms.IllegalStateException: JMSWMQ2007: Failed to send a message to destination ‘TEST.OWL.REQ.01'.; nested exception is com.ibm.msg.client.jms.DetailedIllegalStateException: JMSWMQ2007: Failed to send a message to destination 'TEST.OWL.REQ.01'.* *JMS attempted to perform an MQPUT or MQPUT1; however WebSphere MQ reported an error.* *Use the linked exception to determine the cause of this error.; nested exception is com.ibm.mq.MQException: JMSCMQ0001: WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2027' ('MQRC_MISSING_REPLY_TO_Q').* *Versions: * Springboot - 1.5.1.RELEASE Camel - 2.21.0 IBM MQ - 9.0.x *Analysis:* When msg comes without *JMSReplyTo* - *JMS_IBM_MsgType=8* & with *JMSReplyTo* - *JMS_IBM_MsgType=1. *I understood that the initial value is MQMT_DATAGRAM & with replyTo queue it changes to MQMT_REQUEST If I change this header value to 1, it behaves as expected. How do I do it without touching the headers? I tried disableReplyTo option in 'from' of the route but that doesn't help. Regards, Sagheer