You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by stalbot <st...@ahold.com> on 2017/05/25 15:04:16 UTC

Need to be able to change endpoint for recipientList when call is redelivered

I have a route with a recipientList.  The endpoint passed to the
recipientList comes from a property.  There is a route-specific onException
handler with redelivery for this route.  It is possible that the endpoint
can be invalid, causing the recipientList to fail and onException redelivery
to be triggered.  Since the endpoint is invalid, we don't want the
redelivery to use the same endpoint and fail again.  I have tried to change
the property value in the onRedelivery processor when control flow gets
there, but it appears that the changed property value passed to the
recipientList isn't used on the redelivery attempt.  It uses the original
value passed in, which causes the route to fail again and go to my fail
endpoint.  When I check the property value in the fail endpoint (expecting
that the endpoint property was not changed), it appears to be the changed
endpoint, not the original endpoint.  So it seems like the property is
changed but redelivery doesn't use it.

Is there a way to change the property value prior to its use in the
recipientList redelivery attempt such that it will be used instead of using
the original value?

NOTE: I am using this approach to redeliveries:
http://camel.apache.org/how-do-i-retry-processing-a-message-from-a-certain-point-back-or-an-entire-route.html

Example code below:

from("direct:showList)
     .onException(HttpOperationFailedException.class)
          .handled(true)
          .maximumRedeliveries(MAX_REDELIVERIES)
          .redeliveryDelay(REDELIVERY_DELAY)
          .onRedelivery(e->{
                    e.setProperty(GET_LIST_ENDPOINT,
"http4://correctedEndpoint");
          })
          .to(Endpoint.HANDLE_ERROR_ON_REDELIVERY)
          .end()
     ....
     .to("direct:callGetList")
     ....
.end()

from("direct:callGetList")
     .errorHandler(noErrorHandler())
     .recipientList(exchangeProperty(GET_LIST_ENDPOINT))
.end();



--
View this message in context: http://camel.465427.n5.nabble.com/Need-to-be-able-to-change-endpoint-for-recipientList-when-call-is-redelivered-tp5800698.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Need to be able to change endpoint for recipientList when call is redelivered

Posted by stalbot <st...@ahold.com>.
UPDATE: It turned out that I was not setting all the headers correctly that
were needed by the call to recipientList().  When I set them, the call
succeeded.  So it seems that my suspicion that the error handler/onException
was using the original url input to the recipientList call instead of my
updated url was incorrect.



--
View this message in context: http://camel.465427.n5.nabble.com/Need-to-be-able-to-change-endpoint-for-recipientList-when-call-is-redelivered-tp5800698p5802276.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Need to be able to change endpoint for recipientList when call is redelivered

Posted by stalbot <st...@ahold.com>.
Hello, thank you for the reply and the suggestion.

My goal is not just to avoid the invalid endpoint, but to correct it to be
valid again and then redeliver.

So for some more context on what we are doing: a query parameter in the
endpoint is populated from a database, and over time it can cause the
recipientList call to fail because the value is out of date with the service
it calls.  Our code changes this query parameter so that the call will go
through and the query parameter will not be out of date with the service. 
We would like to use the redelivery feature to do this.

If we go with ".ignoreInvalidEndpoints()", the invalid call will not be
redelivered with the updated query parameter, it will just be avoided
altogether.

I am relatively new to camel and so I am not sure why our code uses
recipientList with a single endpoint but there you go.  If there is another
way to do this I am all ears! :)



--
View this message in context: http://camel.465427.n5.nabble.com/Need-to-be-able-to-change-endpoint-for-recipientList-when-call-is-redelivered-tp5800698p5800701.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Need to be able to change endpoint for recipientList when call is redelivered

Posted by Claus Ibsen <cl...@gmail.com>.
You can turn on an option on recipient list to ignore invalid endpoints

On Thu, May 25, 2017 at 5:04 PM, stalbot <st...@ahold.com> wrote:
> I have a route with a recipientList.  The endpoint passed to the
> recipientList comes from a property.  There is a route-specific onException
> handler with redelivery for this route.  It is possible that the endpoint
> can be invalid, causing the recipientList to fail and onException redelivery
> to be triggered.  Since the endpoint is invalid, we don't want the
> redelivery to use the same endpoint and fail again.  I have tried to change
> the property value in the onRedelivery processor when control flow gets
> there, but it appears that the changed property value passed to the
> recipientList isn't used on the redelivery attempt.  It uses the original
> value passed in, which causes the route to fail again and go to my fail
> endpoint.  When I check the property value in the fail endpoint (expecting
> that the endpoint property was not changed), it appears to be the changed
> endpoint, not the original endpoint.  So it seems like the property is
> changed but redelivery doesn't use it.
>
> Is there a way to change the property value prior to its use in the
> recipientList redelivery attempt such that it will be used instead of using
> the original value?
>
> NOTE: I am using this approach to redeliveries:
> http://camel.apache.org/how-do-i-retry-processing-a-message-from-a-certain-point-back-or-an-entire-route.html
>
> Example code below:
>
> from("direct:showList)
>      .onException(HttpOperationFailedException.class)
>           .handled(true)
>           .maximumRedeliveries(MAX_REDELIVERIES)
>           .redeliveryDelay(REDELIVERY_DELAY)
>           .onRedelivery(e->{
>                     e.setProperty(GET_LIST_ENDPOINT,
> "http4://correctedEndpoint");
>           })
>           .to(Endpoint.HANDLE_ERROR_ON_REDELIVERY)
>           .end()
>      ....
>      .to("direct:callGetList")
>      ....
> .end()
>
> from("direct:callGetList")
>      .errorHandler(noErrorHandler())
>      .recipientList(exchangeProperty(GET_LIST_ENDPOINT))
> .end();
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Need-to-be-able-to-change-endpoint-for-recipientList-when-call-is-redelivered-tp5800698.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2