Description
When no Content-Type is set, PayloadConverter falls back to MediaType::createApplicationXPHP() for $sourceMediaType and tries to find a MediaTypeConverter towards the target format in an KafkaConsumer.
For interoperability with other systems it should be possible to allow to configured Kafka-Consumer in a way that allows to define Source-Media-Type to for example JSON if no Content-Type Header is set in the kafka message headers and this is the defined standard for kafka usage in a team
Example
Having a Consumer like
final class ScheduleMeetingKafkaConsumer
{
#[KafkaConsumer(
'kafka_consumer_schedule_meeting',
'testTopic'
)]
public function handle(ScheduleMeeting $scheduleMeeting): void
{
$this->receivedMeetings[] = $scheduleMeeting;
}
}
with Message on Kafka without headers being processed leads to
Ecotone\Messaging\Support\InvalidArgumentException: Can not call Test\Ecotone\Kafka\Fixture\Calendar\ScheduleMeetingKafkaConsumer::handle. Lack of Media Type Converter for application/x-php:string to application/x-php:Test\Ecotone\Kafka\Fixture\Calendar\ScheduleMeeting
(Note i have also no MediaTypeConverter for JSON, but it didnt look for one, so having one, and a way to define json as default, would probably make that work)
Reproduced in tests via 31c17c8
Description
When no Content-Type is set, PayloadConverter falls back to
MediaType::createApplicationXPHP()for$sourceMediaTypeand tries to find a MediaTypeConverter towards the target format in an KafkaConsumer.For interoperability with other systems it should be possible to allow to configured Kafka-Consumer in a way that allows to define Source-Media-Type to for example
JSONif no Content-Type Header is set in the kafka message headers and this is the defined standard for kafka usage in a teamExample
Having a Consumer like
with Message on Kafka without headers being processed leads to
Ecotone\Messaging\Support\InvalidArgumentException: Can not call Test\Ecotone\Kafka\Fixture\Calendar\ScheduleMeetingKafkaConsumer::handle. Lack of Media Type Converter for application/x-php:string to application/x-php:Test\Ecotone\Kafka\Fixture\Calendar\ScheduleMeeting(Note i have also no MediaTypeConverter for JSON, but it didnt look for one, so having one, and a way to define json as default, would probably make that work)
Reproduced in tests via 31c17c8