Skip to content

Default error channel with exception on KafkaConsumer leads to MessageHeaderDoesNotExistsException #659

@tandev

Description

@tandev

Ecotone version(s) affected: 1.309.0

Description
With having an KafkaConsumer and an application wide default error channel configured, when the consumer fails the

https://github.com/ecotoneframework/ecotone-dev/blob/main/packages/Ecotone/src/Messaging/Endpoint/PollingConsumer/PollingConsumerErrorChannelInterceptor.php#L50 will fail when trying to receive $requestMessage->getHeaders()->get(MessageHeaders::POLLED_CHANNEL_NAME) as the header is not set.

Ecotone\Messaging\MessageHeaderDoesNotExistsException: Header with name polledChannelName does not exists

How to reproduce

Can reproduced in test:
f7818df

1) Test\Ecotone\Kafka\Integration\KafkaChannelAdapterTest::test_message_consumer_from_raw_message_with_conversion
Test was run in child process and ended unexpectedly

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
deploy@cbd70f6bd6e8:/data/app$ XDEBUG_MODE=debug XDEBUG_CONFIG="client_host=host.docker.internal client_port=9003 log=/tmp/xdebug.log log_level=10 idekey=PHPSTORM" php -dxdebug.start_with_request=yes vendor/bin/phpunit --no-coverage packages/Kafka/tests/ --filter=test_message_consumer_from_raw_message_with_conversion
PHPUnit 11.5.55 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.5.3
Configuration: /data/app/phpunit.xml.dist

E                                                                   1 / 1 (100%)

Time: 00:13.631, Memory: 12.00 MB

There was 1 error:

1) Test\Ecotone\Kafka\Integration\KafkaChannelAdapterTest::test_message_consumer_from_raw_message_with_conversion
Ecotone\Messaging\MessageHeaderDoesNotExistsException: Header with name polledChannelName does not exists

/data/app/packages/Ecotone/src/Messaging/MessagingException.php:52
/data/app/packages/Ecotone/src/Messaging/MessageHeaders.php:358
/data/app/packages/Ecotone/src/Messaging/Endpoint/PollingConsumer/PollingConsumerErrorChannelInterceptor.php:50
/data/app/packages/Ecotone/src/Messaging/Endpoint/PollingConsumer/PollingConsumerErrorChannelInterceptor.php:29
/data/app/packages/Ecotone/src/Messaging/Handler/Processor/MethodInvoker/AroundMethodInvocation.php:77
/data/app/packages/Ecotone/src/Messaging/Handler/Logger/LoggingInterceptor.php:40
/data/app/packages/Ecotone/src/Messaging/Handler/Processor/MethodInvoker/AroundMethodInvocation.php:77
/data/app/packages/Ecotone/src/Messaging/Endpoint/AcknowledgeConfirmationInterceptor.php:66
/data/app/packages/Ecotone/src/Messaging/Endpoint/AcknowledgeConfirmationInterceptor.php:53
/data/app/packages/Ecotone/src/Messaging/Handler/Processor/MethodInvoker/AroundMethodInvocation.php:77
/data/app/packages/Ecotone/src/Messaging/Handler/Processor/MethodInvoker/AroundMessageProcessor.php:33
/data/app/packages/Ecotone/src/Messaging/Handler/Processor/ChainedMessageProcessor.php:24
/data/app/packages/Ecotone/src/Messaging/Handler/Gateway/Gateway.php:78
/data/app/packages/Ecotone/src/Messaging/Endpoint/PollingConsumer/InterceptedGateway.php:26
/data/app/packages/Ecotone/src/Messaging/Endpoint/PollingConsumer/PollToGatewayTaskExecutor.php:47
/data/app/packages/Ecotone/src/Messaging/Scheduling/SyncTaskScheduler.php:43
/data/app/packages/Ecotone/src/Messaging/Endpoint/PollingConsumer/ScheduledTaskConsumer.php:31
/data/app/packages/Ecotone/src/Messaging/Endpoint/PollingConsumer/InterceptedConsumer.php:64
/data/app/packages/Ecotone/src/Messaging/Endpoint/PollingConsumer/InterceptedConsumerRunner.php:41
/data/app/packages/Ecotone/src/Messaging/Config/MessagingSystemContainer.php:102
/data/app/packages/Ecotone/src/Lite/Test/FlowTestSupport.php:156
/data/app/packages/Kafka/tests/Integration/KafkaChannelAdapterTest.php:340

Possible Solution

Context

  • Not sure if this is a ecotone/kafka issue or a general messaging issue
  • This was nor reproducable with adapting tests like the existing \Test\Ecotone\Kafka\Integration\KafkaChannelAdapterTest::test_defining_error_channel when there is drect producer and consumer relation, probably PollingConsumer is not used in same way then

Metadata

Metadata

Assignees

No one assigned

    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