-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Update changelog and add test for webSocket in service bus #22778
Closed
zhichengliu12581
wants to merge
5
commits into
Azure:main
from
zhichengliu12581:update-changelog-and-add-test-for-websocket-in-service-bus
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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 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 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
113 changes: 113 additions & 0 deletions
113
...a/com/azure/spring/sample/servicebus/binder/ServiceBusQueueAndTopicWebSocketBinderIT.java
This file contains 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,113 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
package com.azure.spring.sample.servicebus.binder; | ||
|
||
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.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.context.annotation.Bean; | ||
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.net.InetAddress; | ||
import java.net.InetSocketAddress; | ||
import java.net.Socket; | ||
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(classes = { ServiceBusQueueAndTopicWebSocketBinderIT.TestQueueConfig.class, | ||
ServiceBusQueueAndTopicWebSocketBinderIT.TestTopicConfig.class }) | ||
@ActiveProfiles("websocket") | ||
public class ServiceBusQueueAndTopicWebSocketBinderIT { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(ServiceBusQueueAndTopicWebSocketBinderIT.class); | ||
|
||
private static String message = UUID.randomUUID().toString(); | ||
|
||
private static CountDownLatch latch = new CountDownLatch(2); | ||
|
||
@Autowired | ||
private Sinks.Many<Message<String>> manyQueue; | ||
|
||
@Autowired | ||
private Sinks.Many<Message<String>> manyTopic; | ||
|
||
@EnableAutoConfiguration | ||
public static class TestQueueConfig { | ||
|
||
@Bean | ||
public Sinks.Many<Message<String>> manyQueue() { | ||
return Sinks.many().unicast().onBackpressureBuffer(); | ||
} | ||
|
||
@Bean | ||
public Supplier<Flux<Message<String>>> queueSupply(Sinks.Many<Message<String>> manyQueue) { | ||
return () -> manyQueue.asFlux() | ||
.doOnNext(m -> LOGGER.info("Manually sending message {}", m)) | ||
.doOnError(t -> LOGGER.error("Error encountered", t)); | ||
} | ||
|
||
@Bean | ||
public Consumer<Message<String>> queueConsume() { | ||
return message -> { | ||
LOGGER.info("---Test queue new message received: '{}'", message); | ||
if (message.getPayload().equals(ServiceBusQueueAndTopicWebSocketBinderIT.message)) { | ||
latch.countDown(); | ||
} | ||
}; | ||
} | ||
} | ||
|
||
@EnableAutoConfiguration | ||
public static class TestTopicConfig { | ||
|
||
@Bean | ||
public Sinks.Many<Message<String>> manyTopic() { | ||
return Sinks.many().unicast().onBackpressureBuffer(); | ||
} | ||
|
||
@Bean | ||
public Supplier<Flux<Message<String>>> topicSupply(Sinks.Many<Message<String>> manyTopic) { | ||
return () -> manyTopic.asFlux() | ||
.doOnNext(m -> LOGGER.info("Manually sending message {}", m)) | ||
.doOnError(t -> LOGGER.error("Error encountered", t)); | ||
} | ||
|
||
@Bean | ||
public Consumer<Message<String>> topicConsume() { | ||
return message -> { | ||
LOGGER.info("---Test topic new message received: '{}'", message); | ||
if (message.getPayload().equals(ServiceBusQueueAndTopicWebSocketBinderIT.message)) { | ||
latch.countDown(); | ||
} | ||
}; | ||
} | ||
} | ||
|
||
@Test | ||
public void testServiceBusSendAndReceiveMessage() throws InterruptedException { | ||
LOGGER.info("SingleServiceBusQueueAndTopicBinderIT begin."); | ||
GenericMessage<String> genericMessage = new GenericMessage<>(message); | ||
|
||
LOGGER.info("Send a message:" + message + " to the queue."); | ||
manyQueue.emitNext(genericMessage, Sinks.EmitFailureHandler.FAIL_FAST); | ||
LOGGER.info("Send a message:" + message + " to the topic."); | ||
manyTopic.emitNext(genericMessage, Sinks.EmitFailureHandler.FAIL_FAST); | ||
|
||
assertThat(ServiceBusQueueAndTopicWebSocketBinderIT.latch.await(15, TimeUnit.SECONDS)).isTrue(); | ||
LOGGER.info("SingleServiceBusQueueAndTopicBinderIT end."); | ||
} | ||
|
||
|
||
} |
38 changes: 38 additions & 0 deletions
38
...ng/azure-spring-cloud-test-servicebus-binder/src/test/resources/application-websocket.yml
This file contains 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,38 @@ | ||
spring: | ||
cloud: | ||
stream: | ||
function: | ||
definition: queueConsume;queueSupply;topicConsume;topicSupply; | ||
bindings: | ||
topicConsume-in-0: | ||
destination: topic1 | ||
group: topicSub | ||
topicSupply-out-0: | ||
destination: topic1 | ||
queueConsume-in-0: | ||
binder: servicebus-2 | ||
destination: queue1 | ||
queueSupply-out-0: | ||
binder: servicebus-2 | ||
destination: queue1 | ||
binders: | ||
servicebus-1: | ||
type: servicebus-topic | ||
default-candidate: true | ||
environment: | ||
spring: | ||
cloud: | ||
azure: | ||
servicebus: | ||
connection-string: ${SERVICEBUS4_BINDER_TEST_CONNECTION_STRING} | ||
transportType: AMQP_WEB_SOCKETS | ||
servicebus-2: | ||
type: servicebus-queue | ||
default-candidate: false | ||
environment: | ||
spring: | ||
cloud: | ||
azure: | ||
servicebus: | ||
connection-string: ${SERVICEBUS4_BINDER_TEST_CONNECTION_STRING} | ||
transportType: AMQP_WEB_SOCKETS |
This file contains 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add it in README as well