|
6 | 6 |
|
7 | 7 | use Ecotone\Kafka\Api\KafkaHeader; |
8 | 8 | use Ecotone\Kafka\Configuration\KafkaBrokerConfiguration; |
| 9 | +use Ecotone\Kafka\Configuration\KafkaConsumerConfiguration; |
9 | 10 | use Ecotone\Kafka\Configuration\KafkaPublisherConfiguration; |
10 | 11 | use Ecotone\Kafka\Configuration\TopicConfiguration; |
11 | 12 | use Ecotone\Kafka\Outbound\MessagePublishingException; |
@@ -325,4 +326,38 @@ public function test_kafka_consumer_with_delayed_retry(): void |
325 | 326 | // 5. This continues until max delayed retries reached or success |
326 | 327 | // 6. If all retries fail, message goes to dead letter channel or is resent to Kafka (based on finalFailureStrategy) |
327 | 328 | } |
| 329 | + |
| 330 | + public function test_sending_and_receiving_with_kafka_consumer_configuration(): void |
| 331 | + { |
| 332 | + $topicName = Uuid::uuid4()->toString(); |
| 333 | + $ecotoneLite = EcotoneLite::bootstrapFlowTesting( |
| 334 | + [ExampleKafkaConsumer::class], |
| 335 | + [ |
| 336 | + KafkaBrokerConfiguration::class => ConnectionTestCase::getConnection(), |
| 337 | + new ExampleKafkaConsumer(), |
| 338 | + ], |
| 339 | + ServiceConfiguration::createWithDefaults() |
| 340 | + ->withSkippedModulePackageNames(ModulePackageList::allPackagesExcept([ModulePackageList::ASYNCHRONOUS_PACKAGE, ModulePackageList::KAFKA_PACKAGE])) |
| 341 | + ->withExtensionObjects([ |
| 342 | + KafkaPublisherConfiguration::createWithDefaults($topicName), |
| 343 | + TopicConfiguration::createWithReferenceName('exampleTopic', $topicName), |
| 344 | + KafkaConsumerConfiguration::createWithDefaults('exampleConsumer'), |
| 345 | + ]), |
| 346 | + licenceKey: LicenceTesting::VALID_LICENCE, |
| 347 | + ); |
| 348 | + |
| 349 | + /** @var MessagePublisher $kafkaPublisher */ |
| 350 | + $kafkaPublisher = $ecotoneLite->getGateway(MessagePublisher::class); |
| 351 | + |
| 352 | + $kafkaPublisher->sendWithMetadata('exampleData', 'application/text', ['key' => 'value']); |
| 353 | + |
| 354 | + $ecotoneLite->run('exampleConsumer', ExecutionPollingMetadata::createWithTestingSetup( |
| 355 | + maxExecutionTimeInMilliseconds: 30000 |
| 356 | + )); |
| 357 | + |
| 358 | + $messages = $ecotoneLite->sendQueryWithRouting('getMessages'); |
| 359 | + |
| 360 | + self::assertCount(1, $messages); |
| 361 | + self::assertEquals('exampleData', $messages[0]['payload']); |
| 362 | + } |
328 | 363 | } |
0 commit comments