You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "Matthee, Elmar [elmarm@sun.ac.za]" <EL...@sun.ac.za> on 2021/09/15 09:33:39 UTC

Retry/stop of a route on error in .to component

Good day everyone.

I have a quarkus/camel route that picks up a string message from a KAFKA topic and sends it on to a REST service.

It currently looks as follows:

from(kafka(registrationTopicName)
                .brokers(kafkaBroker)
                .clientId(kafkaClientId)
                .groupId(groupId)
                .keyDeserializer(keyDeserializer)
                .valueDeserializer(valueDeserializer)
                .autoOffsetReset(offset))
                .log("Registration Event received: ${body}")
                .to("rest://post:regEvent?host={{fms.registration.restservice.endpoint}}")
                .log("After calling REST service: ${body}");

The scenarios I want to deal with is as follows:

1. The target service is down for some reason. I would like the route to retry every x amount of minutes for a maximum of y number of times. If still failing the route should throw an exception and stop completely until the sysadmins can get the target system back up and running.

2. the target service is up but for some internal reason cannot process the message right now. Behaviour should be exactly the same as with 1 above.

Does anyone have any examples of this kind of scenario in quarkus/camel?

Many thanks.

Elmar


Elmar Matthee
INFORMATION TECHNOLOGY (Institutional Software Solutions)
University of Stellenbosch
South Africa
Tel: +27 21 808 3580 | map
Cel: +27 82 829 8417
Fax: +27 21 808 4102
--
Meddle not in the affairs of dragons puny mortal
for thou art crunchy and taste good with ketchup.




[https://www.sun.ac.za/productionfooter/email/ProductionFooter.jpg]<https://www.sun.ac.za/english/about-us/strategic-documents>

The integrity and confidentiality of this email are governed by these terms. Disclaimer<https://www.sun.ac.za/emaildisclaimer/default.aspx>
Die integriteit en vertroulikheid van hierdie e-pos word deur die volgende bepalings bereël. Vrywaringsklousule<https://www.sun.ac.za/emaildisclaimer/default.aspx>

Re: Retry/stop of a route on error in .to component

Posted by Daniel Langevin <an...@gmail.com>.
Hi, i never made this in quarkus, but there is the way i figure it

1st you have to :
Catch the exception
handled it
use Redeliverypolicy, set maximuRedeliveries and redelivery Delay
after  all the attempt sets
send a JMS Message to another Kafka Queue with header.routeID  and header.action STOP or START
roolback
stop process
delay 5 seconds


A Route read this Kafka Queue with routeID and action STOP or START
and process the action (STOP or START)  the other route
context.stopRoute(header.routeID)
context.startRoute(header.routeID)

try something like that

Hope this help!


Regards.

Daniel





On 2021/09/15 09:33:39, "Matthee, Elmar [elmarm@sun.ac.za]" <EL...@sun.ac.za> wrote: 
> Good day everyone.
> 
> I have a quarkus/camel route that picks up a string message from a KAFKA topic and sends it on to a REST service.
> 
> It currently looks as follows:
> 
> from(kafka(registrationTopicName)
>                 .brokers(kafkaBroker)
>                 .clientId(kafkaClientId)
>                 .groupId(groupId)
>                 .keyDeserializer(keyDeserializer)
>                 .valueDeserializer(valueDeserializer)
>                 .autoOffsetReset(offset))
>                 .log("Registration Event received: ${body}")
>                 .to("rest://post:regEvent?host={{fms.registration.restservice.endpoint}}")
>                 .log("After calling REST service: ${body}");
> 
> The scenarios I want to deal with is as follows:
> 
> 1. The target service is down for some reason. I would like the route to retry every x amount of minutes for a maximum of y number of times. If still failing the route should throw an exception and stop completely until the sysadmins can get the target system back up and running.
> 
> 2. the target service is up but for some internal reason cannot process the message right now. Behaviour should be exactly the same as with 1 above.
> 
> Does anyone have any examples of this kind of scenario in quarkus/camel?
> 
> Many thanks.
> 
> Elmar
> 
> 
> Elmar Matthee
> INFORMATION TECHNOLOGY (Institutional Software Solutions)
> University of Stellenbosch
> South Africa
> Tel: +27 21 808 3580 | map
> Cel: +27 82 829 8417
> Fax: +27 21 808 4102
> --
> Meddle not in the affairs of dragons puny mortal
> for thou art crunchy and taste good with ketchup.
> 
> 
> 
> 
> [https://www.sun.ac.za/productionfooter/email/ProductionFooter.jpg]<https://www.sun.ac.za/english/about-us/strategic-documents>
> 
> The integrity and confidentiality of this email are governed by these terms. Disclaimer<https://www.sun.ac.za/emaildisclaimer/default.aspx>
> Die integriteit en vertroulikheid van hierdie e-pos word deur die volgende bepalings bereël. Vrywaringsklousule<https://www.sun.ac.za/emaildisclaimer/default.aspx>
>