-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Modify EventHub IT and make EventDataBatch creation graceful #31165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
744d816
Adding ServiceActivator to receive send failed messages, make EventHu…
fangjian0423 e587cb4
Adding exception catch on EventDataBatch creation and EventHub produc…
fangjian0423 1d3432e
Spring EventHub test case update (#31109)
fangjian0423 c3e967f
Spring EventHub IT modify logs (#31109)
fangjian0423 1c4d123
Spring EventHub IT modify logs (#31109)
fangjian0423 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
.../azure/spring/cloud/integration/tests/eventhubs/binder/EventHubsBinderProduceErrorIT.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
| package com.azure.spring.cloud.integration.tests.eventhubs.binder; | ||
|
|
||
| import org.junit.jupiter.api.Assertions; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.boot.test.context.SpringBootTest; | ||
| import org.springframework.boot.test.context.TestConfiguration; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.integration.annotation.ServiceActivator; | ||
| import org.springframework.messaging.Message; | ||
| import org.springframework.messaging.support.GenericMessage; | ||
| import org.springframework.test.context.ActiveProfiles; | ||
| import reactor.core.publisher.Flux; | ||
| import reactor.core.publisher.Sinks; | ||
|
|
||
| import java.util.List; | ||
| import java.util.UUID; | ||
| import java.util.concurrent.CountDownLatch; | ||
| import java.util.concurrent.TimeUnit; | ||
| import java.util.function.Consumer; | ||
| import java.util.function.Supplier; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) | ||
| @ActiveProfiles(value = { "eventhubs-binder", "produceerror" }) | ||
| class EventHubsBinderProduceErrorIT { | ||
|
|
||
| private static final Logger LOGGER = LoggerFactory.getLogger(EventHubsBinderProduceErrorIT.class); | ||
|
|
||
| private static final String MESSAGE = UUID.randomUUID().toString(); | ||
|
|
||
| private static final CountDownLatch LATCH = new CountDownLatch(1); | ||
|
|
||
| @Autowired | ||
| private Sinks.Many<Message<String>> many; | ||
|
|
||
| @TestConfiguration | ||
| static class TestConfig { | ||
|
|
||
| @Bean | ||
| Sinks.Many<Message<String>> many() { | ||
| return Sinks.many().unicast().onBackpressureBuffer(); | ||
| } | ||
|
|
||
| @Bean | ||
| Supplier<Flux<Message<String>>> supply(Sinks.Many<Message<String>> many) { | ||
| return () -> many.asFlux() | ||
| .doOnNext(m -> LOGGER.info("Manually sending message {}", m.getPayload())) | ||
| .doOnError(t -> LOGGER.error("Error encountered", t)); | ||
| } | ||
|
|
||
| @Bean | ||
| Consumer<Message<List<String>>> consume() { | ||
| return message -> { | ||
| List<String> payload = message.getPayload(); | ||
| LOGGER.info("EventHubsBinderProduceErrorIT: New message received: '{}'", payload); | ||
| Assertions.fail("EventHubsBinderProduceErrorIT: can't be here"); | ||
| }; | ||
| } | ||
|
|
||
| @ServiceActivator(inputChannel = "errorChannel") | ||
| public void processError(Message sendFailedMsg) { | ||
| LOGGER.info("receive error message: '{}'", sendFailedMsg); | ||
| LATCH.countDown(); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| void testSendAndReceiveMessage() throws InterruptedException { | ||
| LOGGER.info("EventHubsBinderProduceErrorIT begin."); | ||
| EventHubsBinderProduceErrorIT.LATCH.await(15, TimeUnit.SECONDS); | ||
| LOGGER.info("Send a message:" + MESSAGE + "."); | ||
| many.emitNext(new GenericMessage<>(MESSAGE), Sinks.EmitFailureHandler.FAIL_FAST); | ||
| assertThat(EventHubsBinderProduceErrorIT.LATCH.await(300, TimeUnit.SECONDS)).isTrue(); | ||
| LOGGER.info("EventHubsBinderProduceErrorIT end."); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.