Skip to content

enrichHeaders with advice #2388

Closed
Closed
@byrner75

Description

@byrner75

Bug report

I've been using Spring Integration 4 with Spring Boot 1.5.10 and had the following in a flow

return IntegrationFlows.from(outgoingPayment)
                .enrichHeaders( t ->
                    t.headerFunction(HDR_PEER_ADDRESS,
                        (Function<Message<Maxb.PaymentRequest>, Object>) message ->
                                directoryService.resolvePeerForIBAN(
                                        message.getPayload().getRecipient().getIBAN(),
                                        DirectoryService.Service.PAYMENT).getUri()),
                        e -> e.advice(retryAdvice(outgoingPaymentDeferred))

I just upgraded to Spring Boot 2.0.0 and Spring Integration 5.0.3 and reading the migration notes regarding enrichHeaders I've changed the definition of the flow above to the following

return IntegrationFlows.from(outgoingPayment)
                .enrichHeaders( t -> t
                    .advice(retryAdvice(outgoingPaymentDeferred))
                    .headerFunction(HDR_PEER_ADDRESS,
                        (Function<Message<Maxb.PaymentRequest>, Object>) message ->
                                directoryService.resolvePeerForIBAN(
                                        message.getPayload().getRecipient().getIBAN(),
                                        DirectoryService.Service.PAYMENT).getUri()))

My retryAdvice function looks like

    protected Advice retryAdvice(MessageChannel errorChannel) {
        RequestHandlerRetryAdvice advice = new RequestHandlerRetryAdvice();

        RetryTemplate retryTemplate = new RetryTemplate();
        SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy();
        retryPolicy.setMaxAttempts(nodeProperties.getRetry().getAttempts());
        retryTemplate.setRetryPolicy(retryPolicy);

        ExponentialBackOffPolicy exponentialBackOffPolicy = new ExponentialBackOffPolicy();
        exponentialBackOffPolicy.setInitialInterval(nodeProperties.getRetry().getInitialInterval());
        exponentialBackOffPolicy.setMultiplier(nodeProperties.getRetry().getBackoffMultiplier());
        exponentialBackOffPolicy.setMaxInterval(nodeProperties.getRetry().getMaxInterval());
        retryTemplate.setBackOffPolicy(exponentialBackOffPolicy);

        advice.setRetryTemplate(retryTemplate);
        advice.setRecoveryCallback(new ErrorMessageSendingRecoverer(errorChannel));

        return advice;
    }

What I'm noticing in SI 5.0.3 is that the message handler is not executing inside the scope of my advice where it did in SI 4. Are my two flow definitions semantically equivalent? or am I missing something?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions