-
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
Enable properties which supported in sdk #22676
Changes from 16 commits
ffb59f4
00356c6
f3071b1
7f982bc
ca7d039
f876d85
48c8ccc
922759a
c0f6557
5939585
2380f9f
65d8abf
c276787
4245f00
4ca6492
ec9736b
54e8474
379c430
dc87561
0c45193
5efa9aa
77e91fa
006d4a7
b158580
9a2d7e5
295e448
8313691
a3d52f9
f84bbe7
de0880e
cbec683
4c8688d
d32503d
916160a
58245ed
fd05168
9bc8c6d
9b223dc
c134b56
c8ccb03
6c86b9a
e91660b
efdc850
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,7 +62,11 @@ public ServiceBusQueueClientFactory queueClientFactory( | |
|
||
Assert.notNull(connectionString, "Service Bus connection string must not be null"); | ||
|
||
DefaultServiceBusQueueClientFactory clientFactory = new DefaultServiceBusQueueClientFactory(connectionString, properties.getTransportType()); | ||
DefaultServiceBusQueueClientFactory clientFactory = new DefaultServiceBusQueueClientFactory(connectionString); | ||
|
||
clientFactory.retryOptions(properties.getRetryOptions()); | ||
clientFactory.transportType(properties.getTransportType()); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we delete the empty line here? |
||
clientFactory.setNamespace(properties.getNamespace()); | ||
clientFactory.setServiceBusNamespaceManager(namespaceManager); | ||
clientFactory.setServiceBusQueueManager(queueManager); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,10 @@ public ServiceBusTopicClientFactory topicClientFactory( | |
|
||
Assert.notNull(connectionString, "Service Bus connection string must not be null"); | ||
|
||
DefaultServiceBusTopicClientFactory clientFactory = new DefaultServiceBusTopicClientFactory(connectionString, properties.getTransportType()); | ||
DefaultServiceBusTopicClientFactory clientFactory = new DefaultServiceBusTopicClientFactory(connectionString); | ||
clientFactory.retryOptions(properties.getRetryOptions()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how about using setRetryOptions to keep all function names consistent? |
||
clientFactory.transportType(properties.getTransportType()); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we delete the empty line here? |
||
clientFactory.setNamespace(properties.getNamespace()); | ||
clientFactory.setServiceBusNamespaceManager(namespaceManager); | ||
clientFactory.setServiceBusTopicManager(topicManager); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
package com.azure.spring.cloud.autoconfigure.servicebus; | ||
|
||
import com.azure.core.amqp.AmqpRetryMode; | ||
import com.azure.core.amqp.AmqpTransportType; | ||
import com.azure.messaging.servicebus.ServiceBusReceivedMessage; | ||
import com.azure.resourcemanager.AzureResourceManager; | ||
|
@@ -97,6 +98,23 @@ public void testTransportTypeWithAmqpWebSockets() { | |
}); | ||
} | ||
|
||
@Test | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add UTs in the queue&topic autoconfigurtion to see if the client factory beans are created as the way the properties are configured? |
||
public void testTransportTypeWithRetryOptions() { | ||
this.contextRunner.withPropertyValues(SERVICE_BUS_PROPERTY_PREFIX + "retry-options.maxRetries=5", | ||
SERVICE_BUS_PROPERTY_PREFIX + "retry-options.delay=100S", | ||
SERVICE_BUS_PROPERTY_PREFIX + "retry-options.maxDelay=200S", | ||
SERVICE_BUS_PROPERTY_PREFIX + "retry-options.tryTimeout=300S", | ||
SERVICE_BUS_PROPERTY_PREFIX + "retry-options.Mode=FIXED") | ||
.run(context -> { | ||
assertThat(context.getBean(AzureServiceBusProperties.class).getRetryOptions().getMaxRetries()).isEqualTo(5); | ||
assertThat(context.getBean(AzureServiceBusProperties.class).getRetryOptions().getDelay().getSeconds()).isEqualTo(100L); | ||
assertThat(context.getBean(AzureServiceBusProperties.class).getRetryOptions().getMaxDelay().getSeconds()).isEqualTo(200L); | ||
assertThat(context.getBean(AzureServiceBusProperties.class).getRetryOptions().getTryTimeout().getSeconds()).isEqualTo(300L); | ||
assertThat(context.getBean(AzureServiceBusProperties.class).getRetryOptions().getMode()).isEqualTo(AmqpRetryMode.FIXED); | ||
}); | ||
} | ||
|
||
|
||
@Test | ||
public void testWithAzureResourceManagerProvided() { | ||
this.contextRunner.withUserConfiguration(TestConfigWithAzureResourceManager.class) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
package com.azure.spring.sample.servicebus.binder; | ||
|
||
import com.azure.spring.integration.core.api.Checkpointer; | ||
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.MessageBuilder; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import reactor.core.publisher.Flux; | ||
import reactor.core.publisher.Sinks; | ||
|
||
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 com.azure.spring.integration.core.AzureHeaders.CHECKPOINTER; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@SpringBootTest(classes = { ServiceBusQueueAndTopicBinderWithPropertiesIT.TestQueueConfig.class, | ||
ServiceBusQueueAndTopicBinderWithPropertiesIT.TestTopicConfig.class }) | ||
@ActiveProfiles("properties") | ||
public class ServiceBusQueueAndTopicBinderWithPropertiesIT { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(ServiceBusQueueAndTopicBinderWithPropertiesIT.class); | ||
|
||
private static String message = UUID.randomUUID().toString(); | ||
|
||
private static CountDownLatch latch = new CountDownLatch(2); | ||
private static boolean queueError = false; | ||
|
||
@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(ServiceBusQueueAndTopicBinderWithPropertiesIT.message)) { | ||
latch.countDown(); | ||
} | ||
Checkpointer checkpointer = (Checkpointer) message.getHeaders().get(CHECKPOINTER); | ||
checkpointer.success().handle((r, ex) -> { | ||
if (ex != null) { | ||
queueError = true; | ||
} | ||
return null; | ||
}); | ||
|
||
}; | ||
} | ||
} | ||
|
||
@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(ServiceBusQueueAndTopicBinderWithPropertiesIT.message)) { | ||
latch.countDown(); | ||
} | ||
}; | ||
} | ||
} | ||
|
||
@Test | ||
public void testSingleServiceBusSendAndReceiveMessage() throws InterruptedException { | ||
LOGGER.info("SingleServiceBusQueueAndTopicBinderIT begin."); | ||
|
||
LOGGER.info("Send a message:" + message + " to the queue."); | ||
manyQueue.emitNext(MessageBuilder.withPayload(message).build(), Sinks.EmitFailureHandler.FAIL_FAST); | ||
LOGGER.info("Send a message:" + message + " to the topic."); | ||
manyTopic.emitNext(MessageBuilder.withPayload(message).build(), Sinks.EmitFailureHandler.FAIL_FAST); | ||
|
||
assertThat(ServiceBusQueueAndTopicBinderWithPropertiesIT.latch.await(15, TimeUnit.SECONDS)).isTrue(); | ||
assertThat(queueError).isTrue(); | ||
LOGGER.info("SingleServiceBusQueueAndTopicBinderIT end."); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
spring: | ||
cloud: | ||
stream: | ||
function: | ||
definition: queueConsume;queueSupply;topicConsume;topicSupply; | ||
bindings: | ||
topicConsume-in-0: | ||
destination: topic2 | ||
group: topicSub | ||
topicSupply-out-0: | ||
destination: topic2 | ||
queueConsume-in-0: | ||
binder: servicebus-2 | ||
destination: queue2 | ||
queueSupply-out-0: | ||
binder: servicebus-2 | ||
destination: queue2 | ||
binders: | ||
servicebus-1: | ||
type: servicebus-topic | ||
default-candidate: true | ||
environment: | ||
stliu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
spring: | ||
cloud: | ||
azure: | ||
servicebus: | ||
connection-string: ${SERVICEBUS1_BINDER_TEST_CONNECTION_STRING} | ||
servicebus-2: | ||
type: servicebus-queue | ||
default-candidate: false | ||
environment: | ||
spring: | ||
cloud: | ||
azure: | ||
servicebus: | ||
connection-string: ${SERVICEBUS1_BINDER_TEST_CONNECTION_STRING} | ||
servicebus: | ||
queue: | ||
bindings: | ||
queueConsume-in-0: | ||
consumer: | ||
checkpoint-mode: MANUAL | ||
serviceBusReceiveMode: RECEIVE_AND_DELETE |
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.
Is this default value for servicebus sdk client? If so, seems we don't set it here