From 5729c2701b40ecf1e2c396c2a732d351f5398dcd Mon Sep 17 00:00:00 2001 From: yiliu6 Date: Sun, 26 Sep 2021 14:42:42 +0800 Subject: [PATCH 1/7] drop rxjava and completableFuture api --- .../eventhubs/core/EventHubOperation.java | 4 +- .../eventhubs/core/EventHubProcessor.java | 4 +- .../core/EventHubProcessorSupport.java | 4 +- .../eventhubs/core/EventHubRxOperation.java | 18 -- .../eventhubs/core/EventHubRxTemplate.java | 62 ----- .../support/RxEventHubTestOperation.java | 61 ----- .../EventHubOperationSendSubscribeTest.java | 4 +- .../EventHubRxOperationSendSubscribeTest.java | 96 ------- .../core/EventHubTemplateSendTest.java | 2 +- .../handler/DefaultMessageHandler.java | 125 +++++---- .../reactor/DefaultMessageHandler.java | 250 ------------------ .../handler/reactor/package-info.java | 7 - .../handler/MessageHandlerTest.java | 132 ++++----- .../handler/reactor/MessageHandlerTest.java | 130 --------- .../outbound/EventHubMessageHandlerTest.java | 4 +- .../ServiceBusMessageHandlerTest.java | 5 +- .../checkpoint/AzureCheckpointer.java | 17 +- .../messaging/checkpoint/Checkpointer.java | 15 +- .../checkpoint/reactor/AzureCheckpointer.java | 41 --- .../checkpoint/reactor/Checkpointer.java | 26 -- .../checkpoint/reactor/package-info.java | 7 - .../messaging/core/BatchSendOperation.java | 22 +- .../core/{reactor => }/ReceiveOperation.java | 2 +- .../messaging/core/RxSendOperation.java | 37 --- .../core/RxSubscribeByGroupOperation.java | 26 -- .../messaging/core/RxSubscribeOperation.java | 26 -- .../spring/messaging/core/SendOperation.java | 17 +- .../core/reactor/BatchSendOperation.java | 41 --- .../messaging/core/reactor/SendOperation.java | 38 --- .../messaging/core/reactor/package-info.java | 7 - .../messaging/core/SendOperationTest.java | 113 ++------ .../SendSubscribeByGroupOperationTest.java | 3 +- .../core/SendSubscribeOperationTest.java | 98 +++---- .../core/reactor/SendOperationTest.java | 106 -------- .../reactor/SendSubscribeOperationTest.java | 142 ---------- .../RxSendSubscribeByGroupOperationTest.java | 35 --- .../core/rx/RxSendSubscribeOperationTest.java | 117 -------- .../DefaultServiceBusMessageProcessor.java | 38 +-- .../servicebus/core/ServiceBusTemplate.java | 10 +- .../core/queue/ServiceBusQueueTemplate.java | 12 +- .../core/topic/ServiceBusTopicTemplate.java | 14 +- .../core/ServiceBusTemplateSendTest.java | 82 +++++- .../support/ServiceBusQueueTestOperation.java | 6 +- .../support/ServiceBusTopicTestOperation.java | 6 +- .../queue/core/StorageQueueOperation.java | 4 +- .../queue/core/StorageQueueTemplate.java | 4 +- .../core/StorageQueueTemplateReceiveTest.java | 2 +- .../core/StorageQueueTemplateSendTest.java | 2 +- .../EventHubMessageChannelBinder.java | 2 +- .../EventHubBinderConsumeErrorIT.java | 2 +- .../eventhubs/EventHubBinderManualModeIT.java | 2 +- .../EventHubMessageChannelBinderTest.java | 2 +- .../support/ServiceBusQueueTestOperation.java | 6 +- .../support/ServiceBusTopicTestOperation.java | 6 +- 54 files changed, 391 insertions(+), 1653 deletions(-) delete mode 100644 sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/core/EventHubRxOperation.java delete mode 100644 sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/core/EventHubRxTemplate.java delete mode 100644 sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/support/RxEventHubTestOperation.java delete mode 100644 sdk/spring/azure-spring-eventhubs/src/test/java/com/azure/spring/eventhubs/core/EventHubRxOperationSendSubscribeTest.java delete mode 100644 sdk/spring/azure-spring-integration-core/src/main/java/com/azure/spring/integration/handler/reactor/DefaultMessageHandler.java delete mode 100644 sdk/spring/azure-spring-integration-core/src/main/java/com/azure/spring/integration/handler/reactor/package-info.java delete mode 100644 sdk/spring/azure-spring-integration-core/src/test/java/com/azure/spring/integration/handler/reactor/MessageHandlerTest.java delete mode 100644 sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/checkpoint/reactor/AzureCheckpointer.java delete mode 100644 sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/checkpoint/reactor/Checkpointer.java delete mode 100644 sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/checkpoint/reactor/package-info.java rename sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/{reactor => }/ReceiveOperation.java (95%) delete mode 100644 sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/RxSendOperation.java delete mode 100644 sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/RxSubscribeByGroupOperation.java delete mode 100644 sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/RxSubscribeOperation.java delete mode 100644 sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/reactor/BatchSendOperation.java delete mode 100644 sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/reactor/SendOperation.java delete mode 100644 sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/reactor/package-info.java rename sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/{reactor => }/SendSubscribeByGroupOperationTest.java (87%) delete mode 100644 sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/reactor/SendOperationTest.java delete mode 100644 sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/reactor/SendSubscribeOperationTest.java delete mode 100644 sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/rx/RxSendSubscribeByGroupOperationTest.java delete mode 100644 sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/rx/RxSendSubscribeOperationTest.java diff --git a/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/core/EventHubOperation.java b/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/core/EventHubOperation.java index a8fee4b60f0ad..4392cb40a433f 100644 --- a/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/core/EventHubOperation.java +++ b/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/core/EventHubOperation.java @@ -5,8 +5,8 @@ import com.azure.spring.eventhubs.support.StartPosition; import com.azure.spring.messaging.core.SubscribeByGroupOperation; -import com.azure.spring.messaging.core.reactor.BatchSendOperation; -import com.azure.spring.messaging.core.reactor.SendOperation; +import com.azure.spring.messaging.core.BatchSendOperation; +import com.azure.spring.messaging.core.SendOperation; /** * Azure event hub operation to support send data asynchronously and subscribe diff --git a/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/core/EventHubProcessor.java b/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/core/EventHubProcessor.java index f67cc0a6a925e..ee7d50fcfead0 100644 --- a/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/core/EventHubProcessor.java +++ b/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/core/EventHubProcessor.java @@ -13,8 +13,8 @@ import com.azure.spring.messaging.AzureHeaders; import com.azure.spring.messaging.checkpoint.CheckpointConfig; import com.azure.spring.messaging.checkpoint.CheckpointMode; -import com.azure.spring.messaging.checkpoint.reactor.AzureCheckpointer; -import com.azure.spring.messaging.checkpoint.reactor.Checkpointer; +import com.azure.spring.messaging.checkpoint.AzureCheckpointer; +import com.azure.spring.messaging.checkpoint.Checkpointer; import com.azure.spring.eventhubs.checkpoint.CheckpointManager; import com.azure.spring.eventhubs.support.converter.EventHubMessageConverter; import org.slf4j.Logger; diff --git a/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/core/EventHubProcessorSupport.java b/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/core/EventHubProcessorSupport.java index fc9f93eae2bbf..efd0584d6cee1 100644 --- a/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/core/EventHubProcessorSupport.java +++ b/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/core/EventHubProcessorSupport.java @@ -9,8 +9,8 @@ import com.azure.spring.messaging.AzureHeaders; import com.azure.spring.messaging.checkpoint.CheckpointConfig; import com.azure.spring.messaging.checkpoint.CheckpointMode; -import com.azure.spring.messaging.checkpoint.reactor.AzureCheckpointer; -import com.azure.spring.messaging.checkpoint.reactor.Checkpointer; +import com.azure.spring.messaging.checkpoint.AzureCheckpointer; +import com.azure.spring.messaging.checkpoint.Checkpointer; import com.azure.spring.eventhubs.support.converter.EventHubMessageConverter; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHeaders; diff --git a/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/core/EventHubRxOperation.java b/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/core/EventHubRxOperation.java deleted file mode 100644 index 94c70be470561..0000000000000 --- a/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/core/EventHubRxOperation.java +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.spring.eventhubs.core; - -import com.azure.spring.eventhubs.support.StartPosition; -import com.azure.spring.messaging.core.RxSendOperation; -import com.azure.spring.messaging.core.RxSubscribeByGroupOperation; - -/** - * Azure event hub operation to support send and subscribe in a reactive way - * - * @author Warren Zhu - */ -public interface EventHubRxOperation extends RxSendOperation, RxSubscribeByGroupOperation { - - void setStartPosition(StartPosition startPosition); -} diff --git a/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/core/EventHubRxTemplate.java b/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/core/EventHubRxTemplate.java deleted file mode 100644 index 8eca22b1534e0..0000000000000 --- a/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/core/EventHubRxTemplate.java +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.spring.eventhubs.core; - -import com.azure.spring.core.util.Tuple; -import com.azure.spring.messaging.PartitionSupplier; -import org.springframework.messaging.Message; -import reactor.core.publisher.Mono; -import rx.Observable; -import rx.subscriptions.Subscriptions; - -import java.util.concurrent.ConcurrentHashMap; - -/** - * Default implementation of {@link EventHubRxOperation}. - * - * @author Warren Zhu - * @author Xiaolu Dai - */ -public class EventHubRxTemplate extends AbstractEventHubTemplate implements EventHubRxOperation { - - private final ConcurrentHashMap, Observable>> subjectByNameAndGroup = - new ConcurrentHashMap<>(); - - public EventHubRxTemplate(EventHubClientFactory clientFactory) { - super(clientFactory); - } - - private static Observable toObservable(Mono mono) { - return Observable.create(subscriber -> mono.toFuture().whenComplete((result, error) -> { - if (error != null) { - subscriber.onError(error); - } else { - subscriber.onNext(result); - subscriber.onCompleted(); - } - })); - } - - @Override - public Observable sendRx(String destination, Message message, PartitionSupplier partitionSupplier) { - return toObservable(sendAsync(destination, message, partitionSupplier)); - } - - - @Override - public Observable> subscribe(String destination, String consumerGroup, Class messagePayloadType) { - Tuple nameAndConsumerGroup = Tuple.of(destination, consumerGroup); - - subjectByNameAndGroup.computeIfAbsent(nameAndConsumerGroup, k -> Observable.>create(subscriber -> { - final EventHubProcessor eventHubProcessor = new EventHubProcessor(subscriber::onNext, messagePayloadType, - getCheckpointConfig(), getMessageConverter()); - this.createEventProcessorClient(destination, consumerGroup, eventHubProcessor); - this.startEventProcessorClient(destination, consumerGroup); - subscriber.add(Subscriptions.create(() -> this.stopEventProcessorClient(destination, consumerGroup))); - }).share()); - - return subjectByNameAndGroup.get(nameAndConsumerGroup); - } - -} diff --git a/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/support/RxEventHubTestOperation.java b/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/support/RxEventHubTestOperation.java deleted file mode 100644 index f74f15d00b8f8..0000000000000 --- a/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/support/RxEventHubTestOperation.java +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.spring.eventhubs.support; - -import com.azure.messaging.eventhubs.models.EventContext; -import com.azure.spring.core.util.Tuple; -import com.azure.spring.messaging.PartitionSupplier; -import com.azure.spring.eventhubs.core.EventHubClientFactory; -import com.azure.spring.eventhubs.core.EventHubRxOperation; -import com.azure.spring.eventhubs.core.EventHubProcessor; -import org.springframework.messaging.Message; -import reactor.core.publisher.Mono; -import rx.Observable; -import rx.subscriptions.Subscriptions; - -import java.util.concurrent.ConcurrentHashMap; -import java.util.function.Supplier; - -/** - * Rx implementation for {@link EventHubTestOperation}. - */ -public class RxEventHubTestOperation extends EventHubTestOperation implements EventHubRxOperation { - private final ConcurrentHashMap, Observable>> subjectByNameAndGroup = - new ConcurrentHashMap<>(); - - public RxEventHubTestOperation(EventHubClientFactory clientFactory, Supplier eventContextSupplier) { - super(clientFactory, eventContextSupplier); - } - - private static Observable toObservable(Mono mono) { - return Observable.create(subscriber -> mono.toFuture().whenComplete((result, error) -> { - if (error != null) { - subscriber.onError(error); - } else { - subscriber.onNext(result); - subscriber.onCompleted(); - } - })); - } - - @Override - public Observable sendRx(String destination, Message message, PartitionSupplier partitionSupplier) { - return toObservable(sendAsync(destination, message, partitionSupplier)); - } - - @Override - public Observable> subscribe(String destination, String consumerGroup, Class messagePayloadType) { - Tuple nameAndConsumerGroup = Tuple.of(destination, consumerGroup); - - subjectByNameAndGroup.computeIfAbsent(nameAndConsumerGroup, k -> Observable.>create(subscriber -> { - final EventHubProcessor eventHubProcessor = createEventProcessor(subscriber::onNext, messagePayloadType); - this.createEventProcessorClient(destination, consumerGroup, eventHubProcessor); - this.startEventProcessorClient(destination, consumerGroup); - subscriber.add(Subscriptions.create(() -> this.stopEventProcessorClient(destination, consumerGroup))); - }).share()); - - return subjectByNameAndGroup.get(nameAndConsumerGroup); - } -} - diff --git a/sdk/spring/azure-spring-eventhubs/src/test/java/com/azure/spring/eventhubs/core/EventHubOperationSendSubscribeTest.java b/sdk/spring/azure-spring-eventhubs/src/test/java/com/azure/spring/eventhubs/core/EventHubOperationSendSubscribeTest.java index 3f0bda7f7bfee..d39b1a4be9420 100644 --- a/sdk/spring/azure-spring-eventhubs/src/test/java/com/azure/spring/eventhubs/core/EventHubOperationSendSubscribeTest.java +++ b/sdk/spring/azure-spring-eventhubs/src/test/java/com/azure/spring/eventhubs/core/EventHubOperationSendSubscribeTest.java @@ -10,8 +10,8 @@ import com.azure.spring.messaging.AzureHeaders; import com.azure.spring.messaging.checkpoint.CheckpointConfig; import com.azure.spring.messaging.checkpoint.CheckpointMode; -import com.azure.spring.messaging.checkpoint.reactor.Checkpointer; -import com.azure.spring.messaging.core.reactor.SendSubscribeByGroupOperationTest; +import com.azure.spring.messaging.checkpoint.Checkpointer; +import com.azure.spring.messaging.core.SendSubscribeByGroupOperationTest; import com.azure.spring.messaging.support.pojo.User; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; diff --git a/sdk/spring/azure-spring-eventhubs/src/test/java/com/azure/spring/eventhubs/core/EventHubRxOperationSendSubscribeTest.java b/sdk/spring/azure-spring-eventhubs/src/test/java/com/azure/spring/eventhubs/core/EventHubRxOperationSendSubscribeTest.java deleted file mode 100644 index b8d7dbd0401ea..0000000000000 --- a/sdk/spring/azure-spring-eventhubs/src/test/java/com/azure/spring/eventhubs/core/EventHubRxOperationSendSubscribeTest.java +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.spring.eventhubs.core; - -import com.azure.messaging.eventhubs.models.EventContext; -import com.azure.messaging.eventhubs.models.PartitionContext; -import com.azure.spring.messaging.checkpoint.CheckpointConfig; -import com.azure.spring.messaging.checkpoint.CheckpointMode; -import com.azure.spring.messaging.support.pojo.User; -import com.azure.spring.messaging.core.rx.RxSendSubscribeByGroupOperationTest; -import com.azure.spring.eventhubs.support.StartPosition; -import com.azure.spring.eventhubs.support.RxEventHubTestOperation; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import reactor.core.publisher.Mono; - -import java.util.Arrays; - -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -public class EventHubRxOperationSendSubscribeTest extends RxSendSubscribeByGroupOperationTest { - - @Mock - EventContext eventContext; - - @Mock - PartitionContext partitionContext; - - private AutoCloseable closeable; - - @BeforeEach - @Override - public void setUp() { - this.closeable = MockitoAnnotations.openMocks(this); - when(this.eventContext.updateCheckpointAsync()).thenReturn(Mono.empty()); - when(this.eventContext.getPartitionContext()).thenReturn(this.partitionContext); - when(this.partitionContext.getPartitionId()).thenReturn(this.partitionId); - - this.sendSubscribeOperation = new RxEventHubTestOperation(null, () -> eventContext); - } - - @AfterEach - public void close() throws Exception { - closeable.close(); - } - - @Override - protected void verifyCheckpointSuccessCalled(int times) { - verify(this.eventContext, times(times)).updateCheckpointAsync(); - } - - @Override - protected void verifyCheckpointBatchSuccessCalled(int times) { - - } - - @Test - @SuppressWarnings("unchecked") - public void testSendReceiveWithBatchCheckpointMode() { - sendSubscribeOperation - .setCheckpointConfig(CheckpointConfig.builder() - .checkpointMode(CheckpointMode.BATCH).build()); - sendSubscribeOperation.setStartPosition(StartPosition.EARLIEST); - Arrays.stream(messages).forEach(m -> sendSubscribeOperation.sendRx(destination, m)); - sendSubscribeOperation.subscribe(destination, consumerGroup, User.class).test() - .assertValueCount(messages.length).assertNoErrors(); - verifyCheckpointBatchSuccessCalled(1); - } - - @Test - @SuppressWarnings("unchecked") - public void testSendReceiveWithPartitionCountCheckpointMode() { - sendSubscribeOperation - .setCheckpointConfig(CheckpointConfig.builder() - .checkpointMode(CheckpointMode.PARTITION_COUNT) - .checkpointCount(1).build()); - sendSubscribeOperation.setStartPosition(StartPosition.EARLIEST); - Arrays.stream(messages).forEach(m -> sendSubscribeOperation.sendRx(destination, m)); - sendSubscribeOperation.subscribe(destination, consumerGroup, User.class).test() - .assertValueCount(messages.length).assertNoErrors(); - verifyCheckpointSuccessCalled(messages.length); - } - - @Test - public void testHasPartitionIdHeader() { - sendSubscribeOperation.subscribe(destination, consumerGroup, User.class); - sendSubscribeOperation.sendRx(destination, userMessage); - } - -} diff --git a/sdk/spring/azure-spring-eventhubs/src/test/java/com/azure/spring/eventhubs/core/EventHubTemplateSendTest.java b/sdk/spring/azure-spring-eventhubs/src/test/java/com/azure/spring/eventhubs/core/EventHubTemplateSendTest.java index 61ba52f47486d..992ddff8d88b2 100644 --- a/sdk/spring/azure-spring-eventhubs/src/test/java/com/azure/spring/eventhubs/core/EventHubTemplateSendTest.java +++ b/sdk/spring/azure-spring-eventhubs/src/test/java/com/azure/spring/eventhubs/core/EventHubTemplateSendTest.java @@ -7,7 +7,7 @@ import com.azure.messaging.eventhubs.EventDataBatch; import com.azure.messaging.eventhubs.EventHubProducerAsyncClient; import com.azure.messaging.eventhubs.models.CreateBatchOptions; -import com.azure.spring.messaging.core.reactor.SendOperationTest; +import com.azure.spring.messaging.core.SendOperationTest; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.mockito.Mock; diff --git a/sdk/spring/azure-spring-integration-core/src/main/java/com/azure/spring/integration/handler/DefaultMessageHandler.java b/sdk/spring/azure-spring-integration-core/src/main/java/com/azure/spring/integration/handler/DefaultMessageHandler.java index 4d13809c81b9a..5f00ca4ce911d 100644 --- a/sdk/spring/azure-spring-integration-core/src/main/java/com/azure/spring/integration/handler/DefaultMessageHandler.java +++ b/sdk/spring/azure-spring-integration-core/src/main/java/com/azure/spring/integration/handler/DefaultMessageHandler.java @@ -5,8 +5,8 @@ import com.azure.spring.messaging.AzureHeaders; import com.azure.spring.messaging.AzureSendFailureException; -import com.azure.spring.messaging.core.SendOperation; import com.azure.spring.messaging.PartitionSupplier; +import com.azure.spring.messaging.core.SendOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.expression.EvaluationContext; @@ -22,14 +22,16 @@ import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; import org.springframework.messaging.MessageDeliveryException; +import org.springframework.messaging.MessageHeaders; import org.springframework.util.Assert; import org.springframework.util.StringUtils; import org.springframework.util.concurrent.ListenableFutureCallback; +import reactor.core.publisher.Mono; +import java.time.Duration; +import java.time.temporal.ChronoUnit; import java.util.HashMap; import java.util.Map; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; /** @@ -39,9 +41,10 @@ * It delegates real operation to {@link SendOperation} which supports synchronous and asynchronous sending. * * @author Warren Zhu + * @author Xiaolu */ public class DefaultMessageHandler extends AbstractMessageProducingHandler { - private static final Logger LOG = LoggerFactory.getLogger(DefaultMessageHandler.class); + private static final Logger LOGGER = LoggerFactory.getLogger(DefaultMessageHandler.class); private static final long DEFAULT_SEND_TIMEOUT = 10000; private final String destination; private final SendOperation sendOperation; @@ -51,6 +54,7 @@ public class DefaultMessageHandler extends AbstractMessageProducingHandler { private Expression sendTimeoutExpression = new ValueExpression<>(DEFAULT_SEND_TIMEOUT); private ErrorMessageStrategy errorMessageStrategy = new DefaultErrorMessageStrategy(); private Expression partitionKeyExpression; + private Expression partitionIdExpression; private MessageChannel sendFailureChannel; private String sendFailureChannelName; @@ -64,79 +68,74 @@ public DefaultMessageHandler(String destination, @NonNull SendOperation sendOper protected void onInit() { super.onInit(); this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory()); - LOG.info("Started DefaultMessageHandler with properties: {}", buildPropertiesMap()); + LOGGER.info("Started DefaultMessageHandler with properties: {}", buildPropertiesMap()); } @Override - @SuppressWarnings("unchecked") protected void handleMessageInternal(Message message) { - PartitionSupplier partitionSupplier = toPartitionSupplier(message); String destination = toDestination(message); - CompletableFuture future = this.sendOperation.sendAsync(destination, message, partitionSupplier); + final Mono mono = this.sendOperation.sendAsync(destination, message, partitionSupplier); if (this.sync) { - waitingSendResponse(future, message); - return; + waitingSendResponse(mono, message); + } else { + handleSendResponseAsync(mono, message); } - handleSendResponseAsync(message, future); } - private void handleSendResponseAsync(Message message, CompletableFuture future) { - future.handle((t, ex) -> { - if (ex != null) { - if (LOG.isWarnEnabled()) { - LOG.warn("{} sent failed in async mode due to {}", message, ex.getMessage()); - } - if (this.sendCallback != null) { - this.sendCallback.onFailure(ex); - } - - if (getSendFailureChannel() != null) { - this.messagingTemplate.send(getSendFailureChannel(), - getErrorMessageStrategy() - .buildErrorMessage(new AzureSendFailureException(message, ex), null)); - } - - } else { - if (LOG.isDebugEnabled()) { - LOG.debug("{} sent successfully in async mode", message); - } - if (this.sendCallback != null) { - this.sendCallback.onSuccess((Void) t); - } + private void handleSendResponseAsync(Mono mono, Message message) { + mono.doOnError(ex -> { + if (LOGGER.isWarnEnabled()) { + LOGGER.warn("{} sent failed in async mode due to {}", message, ex.getMessage()); + } + if (this.sendCallback != null) { + this.sendCallback.onFailure(ex); } - return null; - }); + if (getSendFailureChannel() != null) { + this.messagingTemplate.send(getSendFailureChannel(), getErrorMessageStrategy() + .buildErrorMessage(new AzureSendFailureException(message, ex), null)); + } + }).doOnSuccess(t -> { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("{} sent successfully in async mode", message); + } + if (this.sendCallback != null) { + this.sendCallback.onSuccess((Void) t); + } + }).subscribe(); } - private void waitingSendResponse(CompletableFuture future, Message message) { + private void waitingSendResponse(Mono mono, Message message) { Long sendTimeout = this.sendTimeoutExpression.getValue(this.evaluationContext, message, Long.class); + if (sendTimeout == null || sendTimeout < 0) { try { - future.get(); + mono.block(); } catch (Exception e) { throw new MessageDeliveryException(e.getMessage()); } } else { try { - future.get(sendTimeout, TimeUnit.MILLISECONDS); - if (LOG.isDebugEnabled()) { - LOG.debug("{} sent successfully in sync mode", message); + mono.block(Duration.of(sendTimeout, ChronoUnit.MILLIS)); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("{} sent successfully in sync mode", message); } - } catch (TimeoutException e) { - throw new MessageTimeoutException(message, "Timeout waiting for send event hub response", e); } catch (Exception e) { + if (e.getCause() instanceof TimeoutException) { + throw new MessageTimeoutException(message, "Timeout waiting for send event hub response"); + } throw new MessageDeliveryException(e.getMessage()); } + } } public void setSync(boolean sync) { this.sync = sync; - LOG.info("DefaultMessageHandler sync becomes: {}", sync); + LOGGER.info("DefaultMessageHandler sync becomes: {}", sync); } public void setSendTimeout(long sendTimeout) { @@ -151,6 +150,10 @@ public void setPartitionKeyExpression(Expression partitionKeyExpression) { this.partitionKeyExpression = partitionKeyExpression; } + public void setPartitionIdExpression(Expression partitionIdExpression) { + this.partitionIdExpression = partitionIdExpression; + } + public void setPartitionKeyExpressionString(String partitionKeyExpression) { setPartitionKeyExpression(EXPRESSION_PARSER.parseExpression(partitionKeyExpression)); } @@ -165,28 +168,46 @@ private String toDestination(Message message) { private PartitionSupplier toPartitionSupplier(Message message) { PartitionSupplier partitionSupplier = new PartitionSupplier(); - String partitionKey = message.getHeaders().get(AzureHeaders.PARTITION_KEY, String.class); + // Priority setting partitionId + String partitionId = getHeaderValue(message.getHeaders(), AzureHeaders.PARTITION_ID); + if (!StringUtils.hasText(partitionId) && this.partitionIdExpression != null) { + partitionId = this.partitionIdExpression.getValue(this.evaluationContext, message, String.class); + } + if (StringUtils.hasText(partitionId)) { + partitionSupplier.setPartitionId(partitionId); + } + + String partitionKey = getHeaderValue(message.getHeaders(), AzureHeaders.PARTITION_KEY); + // The default key expression is the hash code of the payload. if (!StringUtils.hasText(partitionKey) && this.partitionKeyExpression != null) { partitionKey = this.partitionKeyExpression.getValue(this.evaluationContext, message, String.class); } - if (StringUtils.hasText(partitionKey)) { partitionSupplier.setPartitionKey(partitionKey); } - if (message.getHeaders().containsKey(AzureHeaders.PARTITION_ID)) { - partitionSupplier - .setPartitionId(message.getHeaders().get(AzureHeaders.PARTITION_ID, String.class)); - } return partitionSupplier; } + /** + * Get header value from MessageHeaders + * @param headers MessageHeaders + * @param keyName Key name + * @return String header value + */ + private String getHeaderValue(MessageHeaders headers, String keyName) { + return headers.keySet().stream() + .filter(header -> keyName.equals(header)) + .map(key -> String.valueOf(headers.get(key))) + .findAny() + .orElse(null); + } + private Map buildPropertiesMap() { Map properties = new HashMap<>(); properties.put("sync", sync); properties.put("sendTimeout", sendTimeoutExpression); properties.put("destination", destination); - return properties; } @@ -201,7 +222,7 @@ public Expression getSendTimeoutExpression() { public void setSendTimeoutExpression(Expression sendTimeoutExpression) { Assert.notNull(sendTimeoutExpression, "'sendTimeoutExpression' must not be null"); this.sendTimeoutExpression = sendTimeoutExpression; - LOG.info("DefaultMessageHandler syncTimeout becomes: {}", sendTimeoutExpression); + LOGGER.info("DefaultMessageHandler syncTimeout becomes: {}", sendTimeoutExpression); } protected MessageChannel getSendFailureChannel() { diff --git a/sdk/spring/azure-spring-integration-core/src/main/java/com/azure/spring/integration/handler/reactor/DefaultMessageHandler.java b/sdk/spring/azure-spring-integration-core/src/main/java/com/azure/spring/integration/handler/reactor/DefaultMessageHandler.java deleted file mode 100644 index b0edd6304b0af..0000000000000 --- a/sdk/spring/azure-spring-integration-core/src/main/java/com/azure/spring/integration/handler/reactor/DefaultMessageHandler.java +++ /dev/null @@ -1,250 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.spring.integration.handler.reactor; - -import com.azure.spring.messaging.AzureHeaders; -import com.azure.spring.messaging.AzureSendFailureException; -import com.azure.spring.messaging.PartitionSupplier; -import com.azure.spring.messaging.core.reactor.SendOperation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.expression.EvaluationContext; -import org.springframework.expression.Expression; -import org.springframework.expression.common.LiteralExpression; -import org.springframework.integration.MessageTimeoutException; -import org.springframework.integration.expression.ExpressionUtils; -import org.springframework.integration.expression.ValueExpression; -import org.springframework.integration.handler.AbstractMessageProducingHandler; -import org.springframework.integration.support.DefaultErrorMessageStrategy; -import org.springframework.integration.support.ErrorMessageStrategy; -import org.springframework.lang.NonNull; -import org.springframework.messaging.Message; -import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.MessageDeliveryException; -import org.springframework.messaging.MessageHeaders; -import org.springframework.util.Assert; -import org.springframework.util.StringUtils; -import org.springframework.util.concurrent.ListenableFutureCallback; -import reactor.core.publisher.Mono; - -import java.time.Duration; -import java.time.temporal.ChronoUnit; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.TimeoutException; - -/** - * Base class of outbound adapter to publish to azure backed messaging service - * - *

- * It delegates real operation to {@link SendOperation} which supports synchronous and asynchronous sending. - * - * @author Warren Zhu - * @author Xiaolu - */ -public class DefaultMessageHandler extends AbstractMessageProducingHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(DefaultMessageHandler.class); - private static final long DEFAULT_SEND_TIMEOUT = 10000; - private final String destination; - private final SendOperation sendOperation; - private boolean sync = false; - private ListenableFutureCallback sendCallback; - private EvaluationContext evaluationContext; - private Expression sendTimeoutExpression = new ValueExpression<>(DEFAULT_SEND_TIMEOUT); - private ErrorMessageStrategy errorMessageStrategy = new DefaultErrorMessageStrategy(); - private Expression partitionKeyExpression; - private Expression partitionIdExpression; - private MessageChannel sendFailureChannel; - private String sendFailureChannelName; - - public DefaultMessageHandler(String destination, @NonNull SendOperation sendOperation) { - Assert.hasText(destination, "destination can't be null or empty"); - this.destination = destination; - this.sendOperation = sendOperation; - } - - @Override - protected void onInit() { - super.onInit(); - this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory()); - LOGGER.info("Started DefaultMessageHandler with properties: {}", buildPropertiesMap()); - } - - @Override - protected void handleMessageInternal(Message message) { - PartitionSupplier partitionSupplier = toPartitionSupplier(message); - String destination = toDestination(message); - final Mono mono = this.sendOperation.sendAsync(destination, message, partitionSupplier); - - if (this.sync) { - waitingSendResponse(mono, message); - } else { - handleSendResponseAsync(mono, message); - } - - } - - private void handleSendResponseAsync(Mono mono, Message message) { - mono.doOnError(ex -> { - if (LOGGER.isWarnEnabled()) { - LOGGER.warn("{} sent failed in async mode due to {}", message, ex.getMessage()); - } - if (this.sendCallback != null) { - this.sendCallback.onFailure(ex); - } - - if (getSendFailureChannel() != null) { - this.messagingTemplate.send(getSendFailureChannel(), getErrorMessageStrategy() - .buildErrorMessage(new AzureSendFailureException(message, ex), null)); - } - }).doOnSuccess(t -> { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("{} sent successfully in async mode", message); - } - if (this.sendCallback != null) { - this.sendCallback.onSuccess((Void) t); - } - }).subscribe(); - } - - private void waitingSendResponse(Mono mono, Message message) { - Long sendTimeout = this.sendTimeoutExpression.getValue(this.evaluationContext, message, Long.class); - - if (sendTimeout == null || sendTimeout < 0) { - try { - mono.block(); - } catch (Exception e) { - throw new MessageDeliveryException(e.getMessage()); - } - } else { - try { - mono.block(Duration.of(sendTimeout, ChronoUnit.MILLIS)); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("{} sent successfully in sync mode", message); - } - } catch (Exception e) { - if (e.getCause() instanceof TimeoutException) { - throw new MessageTimeoutException(message, "Timeout waiting for send event hub response"); - } - throw new MessageDeliveryException(e.getMessage()); - } - - } - } - - public void setSync(boolean sync) { - this.sync = sync; - LOGGER.info("DefaultMessageHandler sync becomes: {}", sync); - } - - public void setSendTimeout(long sendTimeout) { - setSendTimeoutExpression(new ValueExpression<>(sendTimeout)); - } - - public void setPartitionKey(String partitionKey) { - setPartitionKeyExpression(new LiteralExpression(partitionKey)); - } - - public void setPartitionKeyExpression(Expression partitionKeyExpression) { - this.partitionKeyExpression = partitionKeyExpression; - } - - public void setPartitionIdExpression(Expression partitionIdExpression) { - this.partitionIdExpression = partitionIdExpression; - } - - private String toDestination(Message message) { - if (message.getHeaders().containsKey(AzureHeaders.NAME)) { - return message.getHeaders().get(AzureHeaders.NAME, String.class); - } - - return this.destination; - } - - private PartitionSupplier toPartitionSupplier(Message message) { - PartitionSupplier partitionSupplier = new PartitionSupplier(); - // Priority setting partitionId - String partitionId = getHeaderValue(message.getHeaders(), AzureHeaders.PARTITION_ID); - if (!StringUtils.hasText(partitionId) && this.partitionIdExpression != null) { - partitionId = this.partitionIdExpression.getValue(this.evaluationContext, message, String.class); - } - if (StringUtils.hasText(partitionId)) { - partitionSupplier.setPartitionId(partitionId); - } else { - String partitionKey = getHeaderValue(message.getHeaders(), AzureHeaders.PARTITION_KEY); - // The default key expression is the hash code of the payload. - if (!StringUtils.hasText(partitionKey) && this.partitionKeyExpression != null) { - partitionKey = this.partitionKeyExpression.getValue(this.evaluationContext, message, String.class); - } - if (StringUtils.hasText(partitionKey)) { - partitionSupplier.setPartitionKey(partitionKey); - } - } - return partitionSupplier; - } - - /** - * Get header value from MessageHeaders - * @param headers MessageHeaders - * @param keyName Key name - * @return String header value - */ - private String getHeaderValue(MessageHeaders headers, String keyName) { - return headers.keySet().stream() - .filter(header -> keyName.equals(header)) - .map(key -> String.valueOf(headers.get(key))) - .findAny() - .orElse(null); - } - - private Map buildPropertiesMap() { - Map properties = new HashMap<>(); - properties.put("sync", sync); - properties.put("sendTimeout", sendTimeoutExpression); - properties.put("destination", destination); - return properties; - } - - public void setSendCallback(ListenableFutureCallback callback) { - this.sendCallback = callback; - } - - public Expression getSendTimeoutExpression() { - return sendTimeoutExpression; - } - - public void setSendTimeoutExpression(Expression sendTimeoutExpression) { - Assert.notNull(sendTimeoutExpression, "'sendTimeoutExpression' must not be null"); - this.sendTimeoutExpression = sendTimeoutExpression; - LOGGER.info("DefaultMessageHandler syncTimeout becomes: {}", sendTimeoutExpression); - } - - protected MessageChannel getSendFailureChannel() { - if (this.sendFailureChannel != null) { - return this.sendFailureChannel; - } else if (this.sendFailureChannelName != null) { - this.sendFailureChannel = getChannelResolver().resolveDestination(this.sendFailureChannelName); - return this.sendFailureChannel; - } - - return null; - } - - public void setSendFailureChannel(MessageChannel sendFailureChannel) { - this.sendFailureChannel = sendFailureChannel; - } - - public void setSendFailureChannelName(String sendFailureChannelName) { - this.sendFailureChannelName = sendFailureChannelName; - } - - protected ErrorMessageStrategy getErrorMessageStrategy() { - return this.errorMessageStrategy; - } - - public void setErrorMessageStrategy(ErrorMessageStrategy errorMessageStrategy) { - Assert.notNull(errorMessageStrategy, "'errorMessageStrategy' must not be null"); - this.errorMessageStrategy = errorMessageStrategy; - } -} diff --git a/sdk/spring/azure-spring-integration-core/src/main/java/com/azure/spring/integration/handler/reactor/package-info.java b/sdk/spring/azure-spring-integration-core/src/main/java/com/azure/spring/integration/handler/reactor/package-info.java deleted file mode 100644 index 0d184bb2f6422..0000000000000 --- a/sdk/spring/azure-spring-integration-core/src/main/java/com/azure/spring/integration/handler/reactor/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -/** - * Package com.azure.spring.integration.handler.reactor; - */ -package com.azure.spring.integration.handler.reactor; diff --git a/sdk/spring/azure-spring-integration-core/src/test/java/com/azure/spring/integration/handler/MessageHandlerTest.java b/sdk/spring/azure-spring-integration-core/src/test/java/com/azure/spring/integration/handler/MessageHandlerTest.java index 084aad7b065c4..ea17204695e7b 100644 --- a/sdk/spring/azure-spring-integration-core/src/test/java/com/azure/spring/integration/handler/MessageHandlerTest.java +++ b/sdk/spring/azure-spring-integration-core/src/test/java/com/azure/spring/integration/handler/MessageHandlerTest.java @@ -6,105 +6,80 @@ import com.azure.spring.messaging.AzureHeaders; import com.azure.spring.messaging.PartitionSupplier; import com.azure.spring.messaging.core.SendOperation; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.springframework.expression.Expression; import org.springframework.integration.MessageTimeoutException; import org.springframework.messaging.Message; import org.springframework.messaging.support.GenericMessage; import org.springframework.util.concurrent.ListenableFutureCallback; +import reactor.core.publisher.Mono; import java.util.HashMap; import java.util.Map; -import java.util.concurrent.CompletableFuture; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; +import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import static org.mockito.Mockito.spy; +import static org.junit.jupiter.api.Assertions.assertThrows; public abstract class MessageHandlerTest { - @SuppressWarnings("unchecked") - protected O sendOperation = null; - - protected DefaultMessageHandler handler = null; protected String destination = "dest"; protected String dynamicDestination = "dynamicName"; - - @SuppressWarnings("unchecked") - protected CompletableFuture future = new CompletableFuture<>(); + protected DefaultMessageHandler handler; + protected Mono mono = Mono.empty(); + protected O sendOperation; private Message message; private String payload = "payload"; - public abstract void setUp(); - protected O getSendOperation() { - return sendOperation; - } - - protected void setSendOperation(O sendOperation) { - this.sendOperation = sendOperation; - } - - protected DefaultMessageHandler getHandler() { - return handler; - } - - protected void setHandler(DefaultMessageHandler handler) { - this.handler = handler; + public MessageHandlerTest() { + Map valueMap = new HashMap<>(2); + valueMap.put("key1", "value1"); + valueMap.put("key2", "value2"); + message = new GenericMessage<>("testPayload", valueMap); } + public abstract void setUp(); - protected String getDestination() { - return destination; + @Test + @SuppressWarnings("unchecked") + public void testSend() { + this.handler.handleMessage(this.message); + verify(this.sendOperation, times(1)).sendAsync(eq(destination), isA(Message.class), + isA(PartitionSupplier.class)); } - protected void setDestination(String destination) { - this.destination = destination; - } + @Test + public void testSendCallback() { + ListenableFutureCallback callbackSpy = spy(new ListenableFutureCallback() { + @Override + public void onFailure(Throwable ex) { + } - protected String getDynamicDestination() { - return dynamicDestination; - } + @Override + public void onSuccess(Void v) { + } + }); - protected void setDynamicDestination(String dynamicDestination) { - this.dynamicDestination = dynamicDestination; - } + this.handler.setSendCallback(callbackSpy); - protected CompletableFuture getFuture() { - return future; - } + this.handler.handleMessage(this.message); - protected void setFuture(CompletableFuture future) { - this.future = future; + verify(callbackSpy, times(1)).onSuccess(eq(null)); } - - public MessageHandlerTest() { - Map valueMap = new HashMap<>(2); - valueMap.put("key1", "value1"); - valueMap.put("key2", "value2"); - message = new GenericMessage<>("testPayload", valueMap); } - - @SuppressWarnings("unchecked") @Test - public void testSend() { - this.handler.handleMessage(this.message); - verify(this.sendOperation, times(1)) - .sendAsync(eq(destination), isA(Message.class), isA(PartitionSupplier.class)); - } - @SuppressWarnings("unchecked") - @Test public void testSendDynamicTopic() { Map headers = new HashMap<>(1); headers.put(AzureHeaders.NAME, dynamicDestination); Message dynamicMessage = new GenericMessage<>(payload, headers); this.handler.handleMessage(dynamicMessage); - verify(this.sendOperation, times(1)) - .sendAsync(eq(dynamicDestination), isA(Message.class), isA(PartitionSupplier.class)); + verify(this.sendOperation, times(1)).sendAsync(eq(dynamicDestination), isA(Message.class), + isA(PartitionSupplier.class)); } @Test @@ -117,34 +92,39 @@ public void testSendSync() { verify(timeout, times(1)).getValue(eq(null), eq(this.message), eq(Long.class)); } - @SuppressWarnings("unchecked") @Test + @SuppressWarnings("unchecked") public void testSendTimeout() { - when(this.sendOperation.sendAsync(eq(this.destination), isA(Message.class), isA(PartitionSupplier.class))) - .thenReturn(new CompletableFuture<>()); + when(this.sendOperation.sendAsync(eq(this.destination), isA(Message.class), + isA(PartitionSupplier.class))).thenReturn(Mono.empty().timeout(Mono.empty())); this.handler.setSync(true); this.handler.setSendTimeout(1); - Assertions.assertThrows(MessageTimeoutException.class, () -> this.handler.handleMessage(this.message)); - } - @Test - public void testSendCallback() { - ListenableFutureCallback callbackSpy = spy(new ListenableFutureCallback() { - @Override - public void onFailure(Throwable ex) { + assertThrows(MessageTimeoutException.class, () -> this.handler.handleMessage(this.message)); + } - } + public Mono getMono() { + return mono; + } - @Override - public void onSuccess(Void v) { + public void setMono(Mono mono) { + this.mono = mono; + } - } - }); + public DefaultMessageHandler getHandler() { + return handler; + } - this.handler.setSendCallback(callbackSpy); + public void setHandler(DefaultMessageHandler handler) { + this.handler = handler; + } - this.handler.handleMessage(this.message); + public O getSendOperation() { + return sendOperation; + } - verify(callbackSpy, times(1)).onSuccess(eq(null)); + public void setSendOperation(O sendOperation) { + this.sendOperation = sendOperation; } + } diff --git a/sdk/spring/azure-spring-integration-core/src/test/java/com/azure/spring/integration/handler/reactor/MessageHandlerTest.java b/sdk/spring/azure-spring-integration-core/src/test/java/com/azure/spring/integration/handler/reactor/MessageHandlerTest.java deleted file mode 100644 index 77bf3f0a7453f..0000000000000 --- a/sdk/spring/azure-spring-integration-core/src/test/java/com/azure/spring/integration/handler/reactor/MessageHandlerTest.java +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.spring.integration.handler.reactor; - -import com.azure.spring.messaging.AzureHeaders; -import com.azure.spring.messaging.PartitionSupplier; -import com.azure.spring.messaging.core.reactor.SendOperation; -import org.junit.jupiter.api.Test; -import org.springframework.expression.Expression; -import org.springframework.integration.MessageTimeoutException; -import org.springframework.messaging.Message; -import org.springframework.messaging.support.GenericMessage; -import org.springframework.util.concurrent.ListenableFutureCallback; -import reactor.core.publisher.Mono; - -import java.util.HashMap; -import java.util.Map; - -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.ArgumentMatchers.isA; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.junit.jupiter.api.Assertions.assertThrows; - -public abstract class MessageHandlerTest { - - protected String destination = "dest"; - protected String dynamicDestination = "dynamicName"; - protected DefaultMessageHandler handler; - protected Mono mono = Mono.empty(); - protected O sendOperation; - private Message message; - private String payload = "payload"; - - - public MessageHandlerTest() { - Map valueMap = new HashMap<>(2); - valueMap.put("key1", "value1"); - valueMap.put("key2", "value2"); - message = new GenericMessage<>("testPayload", valueMap); - } - public abstract void setUp(); - - @Test - @SuppressWarnings("unchecked") - public void testSend() { - this.handler.handleMessage(this.message); - verify(this.sendOperation, times(1)).sendAsync(eq(destination), isA(Message.class), - isA(PartitionSupplier.class)); - } - - @Test - public void testSendCallback() { - ListenableFutureCallback callbackSpy = spy(new ListenableFutureCallback() { - @Override - public void onFailure(Throwable ex) { - } - - @Override - public void onSuccess(Void v) { - } - }); - - this.handler.setSendCallback(callbackSpy); - - this.handler.handleMessage(this.message); - - verify(callbackSpy, times(1)).onSuccess(eq(null)); - } - - @Test - @SuppressWarnings("unchecked") - public void testSendDynamicTopic() { - Map headers = new HashMap<>(1); - headers.put(AzureHeaders.NAME, dynamicDestination); - Message dynamicMessage = new GenericMessage<>(payload, headers); - this.handler.handleMessage(dynamicMessage); - verify(this.sendOperation, times(1)).sendAsync(eq(dynamicDestination), isA(Message.class), - isA(PartitionSupplier.class)); - } - - @Test - public void testSendSync() { - this.handler.setSync(true); - Expression timeout = spy(this.handler.getSendTimeoutExpression()); - this.handler.setSendTimeoutExpression(timeout); - - this.handler.handleMessage(this.message); - verify(timeout, times(1)).getValue(eq(null), eq(this.message), eq(Long.class)); - } - - @Test - @SuppressWarnings("unchecked") - public void testSendTimeout() { - when(this.sendOperation.sendAsync(eq(this.destination), isA(Message.class), - isA(PartitionSupplier.class))).thenReturn(Mono.empty().timeout(Mono.empty())); - this.handler.setSync(true); - this.handler.setSendTimeout(1); - - assertThrows(MessageTimeoutException.class, () -> this.handler.handleMessage(this.message)); - } - - public Mono getMono() { - return mono; - } - - public void setMono(Mono mono) { - this.mono = mono; - } - - public DefaultMessageHandler getHandler() { - return handler; - } - - public void setHandler(DefaultMessageHandler handler) { - this.handler = handler; - } - - public O getSendOperation() { - return sendOperation; - } - - public void setSendOperation(O sendOperation) { - this.sendOperation = sendOperation; - } - -} diff --git a/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhubs/outbound/EventHubMessageHandlerTest.java b/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhubs/outbound/EventHubMessageHandlerTest.java index 941ba6e7c73a8..b42f2dea7dc3e 100644 --- a/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhubs/outbound/EventHubMessageHandlerTest.java +++ b/sdk/spring/azure-spring-integration-eventhubs/src/test/java/com/azure/spring/integration/eventhubs/outbound/EventHubMessageHandlerTest.java @@ -5,9 +5,9 @@ import com.azure.spring.messaging.AzureHeaders; import com.azure.spring.messaging.PartitionSupplier; -import com.azure.spring.integration.handler.reactor.DefaultMessageHandler; +import com.azure.spring.integration.handler.DefaultMessageHandler; import com.azure.spring.eventhubs.core.EventHubOperation; -import com.azure.spring.integration.handler.reactor.MessageHandlerTest; +import com.azure.spring.integration.handler.MessageHandlerTest; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/outbound/ServiceBusMessageHandlerTest.java b/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/outbound/ServiceBusMessageHandlerTest.java index afcd8ed49edc9..8a0412008998d 100644 --- a/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/outbound/ServiceBusMessageHandlerTest.java +++ b/sdk/spring/azure-spring-integration-servicebus/src/test/java/com/azure/spring/integration/servicebus/outbound/ServiceBusMessageHandlerTest.java @@ -28,13 +28,12 @@ public class ServiceBusMessageHandlerTest extends MessageHandlerTest> success; - private final Supplier> fail; - public AzureCheckpointer(@NonNull Supplier> success) { + private final Supplier> success; + private final Supplier> fail; + + public AzureCheckpointer(@NonNull Supplier> success) { this(success, null); } - public AzureCheckpointer(@NonNull Supplier> success, - Supplier> fail) { + public AzureCheckpointer(@NonNull Supplier> success, + Supplier> fail) { this.success = success; this.fail = fail; } @Override - public CompletableFuture success() { + public Mono success() { return this.success.get(); } @Override - public CompletableFuture failure() { + public Mono failure() { if (this.fail == null) { throw new UnsupportedOperationException("Fail current message unsupported"); } diff --git a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/checkpoint/Checkpointer.java b/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/checkpoint/Checkpointer.java index f902346828312..299c81a0ddbaa 100644 --- a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/checkpoint/Checkpointer.java +++ b/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/checkpoint/Checkpointer.java @@ -3,27 +3,24 @@ package com.azure.spring.messaging.checkpoint; -import java.util.concurrent.CompletableFuture; +import reactor.core.publisher.Mono; /** * A callback to perform checkpoint. * - * @author Warren Zhu + * @author Xiaolu Dai */ public interface Checkpointer { /** * Acknowledge success of current message. Please check result to detect failure - * @return completable future instance + * @return Mono Void */ - CompletableFuture success(); + Mono success(); /** * Fail current message. Please check result to detect failure - * @return completable future instance + * @return Mono Void */ - CompletableFuture failure(); - - - + Mono failure(); } diff --git a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/checkpoint/reactor/AzureCheckpointer.java b/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/checkpoint/reactor/AzureCheckpointer.java deleted file mode 100644 index 61bb8291171f1..0000000000000 --- a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/checkpoint/reactor/AzureCheckpointer.java +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.spring.messaging.checkpoint.reactor; - -import org.springframework.lang.NonNull; -import reactor.core.publisher.Mono; - -import java.util.function.Supplier; - -/** - * Azure implementation for check point callback. - */ -public class AzureCheckpointer implements Checkpointer { - - private final Supplier> success; - private final Supplier> fail; - - public AzureCheckpointer(@NonNull Supplier> success) { - this(success, null); - } - - public AzureCheckpointer(@NonNull Supplier> success, - Supplier> fail) { - this.success = success; - this.fail = fail; - } - - @Override - public Mono success() { - return this.success.get(); - } - - @Override - public Mono failure() { - if (this.fail == null) { - throw new UnsupportedOperationException("Fail current message unsupported"); - } - return this.fail.get(); - } -} diff --git a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/checkpoint/reactor/Checkpointer.java b/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/checkpoint/reactor/Checkpointer.java deleted file mode 100644 index 85339e3c4ff14..0000000000000 --- a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/checkpoint/reactor/Checkpointer.java +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.spring.messaging.checkpoint.reactor; - -import reactor.core.publisher.Mono; - -/** - * A callback to perform checkpoint. - * - * @author Xiaolu Dai - */ -public interface Checkpointer { - - /** - * Acknowledge success of current message. Please check result to detect failure - * @return Mono Void - */ - Mono success(); - - /** - * Fail current message. Please check result to detect failure - * @return Mono Void - */ - Mono failure(); -} diff --git a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/checkpoint/reactor/package-info.java b/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/checkpoint/reactor/package-info.java deleted file mode 100644 index f97093f706673..0000000000000 --- a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/checkpoint/reactor/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -/** - * Package com.azure.spring.messaging.checkpoint.reactor; - */ -package com.azure.spring.messaging.checkpoint.reactor; diff --git a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/BatchSendOperation.java b/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/BatchSendOperation.java index 70df72f113c6f..f4336dc4fb1a7 100644 --- a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/BatchSendOperation.java +++ b/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/BatchSendOperation.java @@ -5,37 +5,37 @@ import com.azure.spring.messaging.PartitionSupplier; import org.springframework.messaging.Message; +import reactor.core.publisher.Mono; import java.util.Collection; -import java.util.concurrent.CompletableFuture; /** * Operations for sending {@link Collection}<{@link Message}> to a destination. * - * @author Warren Zhu + * @author Xiaolu Dai */ public interface BatchSendOperation { /** * Send a {@link Collection}<{@link Message}> to the given destination with a given partition supplier. * @param destination destination - * @param messages message + * @param messages message set * @param partitionSupplier partition supplier - * @param payload class type in message - * @return Future instance + * @param payload type in message + * @return Mono Void */ - CompletableFuture sendAsync(String destination, Collection> messages, - PartitionSupplier partitionSupplier); + Mono sendAsync(String destination, Collection> messages, + PartitionSupplier partitionSupplier); /** * Send a {@link Collection}<{@link Message}> to the given destination. * @param destination destination - * @param messages messages - * @param payload class type in message - * @return Future instance + * @param messages message set + * @param payload type in message + * @return Mono Void */ - default CompletableFuture sendAsync(String destination, Collection> messages) { + default Mono sendAsync(String destination, Collection> messages) { return sendAsync(destination, messages, null); } } diff --git a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/reactor/ReceiveOperation.java b/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/ReceiveOperation.java similarity index 95% rename from sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/reactor/ReceiveOperation.java rename to sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/ReceiveOperation.java index b3236092618ce..d6c0c1fe79fc3 100644 --- a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/reactor/ReceiveOperation.java +++ b/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/ReceiveOperation.java @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.spring.messaging.core.reactor; +package com.azure.spring.messaging.core; import com.azure.spring.messaging.checkpoint.CheckpointMode; import org.springframework.messaging.Message; diff --git a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/RxSendOperation.java b/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/RxSendOperation.java deleted file mode 100644 index c507c67a1e01d..0000000000000 --- a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/RxSendOperation.java +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.spring.messaging.core; - -import com.azure.spring.messaging.PartitionSupplier; -import org.springframework.messaging.Message; -import rx.Observable; - -/** - * Operations for sending {@link Message} to a destination in a reactive way. - * - * @author Warren Zhu - */ -public interface RxSendOperation { - - /** - * Send a {@link Message} to the given destination with a given partition supplier. - * @param destination destination - * @param message message - * @param partitionSupplier partition supplier - * @param payload type in message - * @return observable instance - */ - Observable sendRx(String destination, Message message, PartitionSupplier partitionSupplier); - - /** - * Send a {@link Message} to the given destination. - * @param destination destination - * @param message message - * @param payload type in message - * @return observable instance - */ - default Observable sendRx(String destination, Message message) { - return sendRx(destination, message, null); - } -} diff --git a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/RxSubscribeByGroupOperation.java b/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/RxSubscribeByGroupOperation.java deleted file mode 100644 index 74825132ea80d..0000000000000 --- a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/RxSubscribeByGroupOperation.java +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.spring.messaging.core; - -import com.azure.spring.messaging.checkpoint.Checkpointable; -import org.springframework.messaging.Message; -import rx.Observable; - -/** - * Operations for subscribing to a destination with a consumer group in a reactive way. - * - * @author Warren Zhu - */ -public interface RxSubscribeByGroupOperation extends Checkpointable { - - /** - * Register a message consumer to a given destination with a given consumer group. - * @param destination destination - * @param consumerGroup consumer group - * @param messagePayloadType message payload type - * @return {@code Observable>} - */ - Observable> subscribe(String destination, String consumerGroup, - Class messagePayloadType); -} diff --git a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/RxSubscribeOperation.java b/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/RxSubscribeOperation.java deleted file mode 100644 index 0ba4075782e8e..0000000000000 --- a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/RxSubscribeOperation.java +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.spring.messaging.core; - -import com.azure.spring.messaging.checkpoint.CheckpointMode; -import org.springframework.messaging.Message; -import rx.Observable; - -/** - * Operations for subscribing to a destination in reactive way. - * - * @author Warren Zhu - */ -public interface RxSubscribeOperation { - - /** - * Register a message consumer to a given destination. - * @param destination destination - * @param messagePayloadType message payload type - * @return {@code Observable>} - */ - Observable> subscribe(String destination, Class messagePayloadType); - - void setCheckpointMode(CheckpointMode checkpointMode); -} diff --git a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/SendOperation.java b/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/SendOperation.java index 484b71030354d..b7b692df15572 100644 --- a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/SendOperation.java +++ b/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/SendOperation.java @@ -5,14 +5,13 @@ import com.azure.spring.messaging.PartitionSupplier; import org.springframework.messaging.Message; - -import java.util.concurrent.CompletableFuture; +import reactor.core.publisher.Mono; /** * Operations for sending {@link Message} to a destination. * - * @author Warren Zhu + * @author Xiaolu Dai */ public interface SendOperation { @@ -21,19 +20,19 @@ public interface SendOperation { * @param destination destination * @param message message * @param partitionSupplier partition supplier - * @param payload type in message - * @return future instance + * @param payload class in message + * @return Mono Void */ - CompletableFuture sendAsync(String destination, Message message, PartitionSupplier partitionSupplier); + Mono sendAsync(String destination, Message message, PartitionSupplier partitionSupplier); /** * Send a {@link Message} to the given destination. * @param destination destination * @param message message - * @param payload type in message - * @return future instance + * @param payload class in message + * @return Mono Void */ - default CompletableFuture sendAsync(String destination, Message message) { + default Mono sendAsync(String destination, Message message) { return sendAsync(destination, message, null); } } diff --git a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/reactor/BatchSendOperation.java b/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/reactor/BatchSendOperation.java deleted file mode 100644 index ec0d9052951ff..0000000000000 --- a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/reactor/BatchSendOperation.java +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.spring.messaging.core.reactor; - -import com.azure.spring.messaging.PartitionSupplier; -import org.springframework.messaging.Message; -import reactor.core.publisher.Mono; - -import java.util.Collection; - - -/** - * Operations for sending {@link Collection}<{@link Message}> to a destination. - * - * @author Xiaolu Dai - */ -public interface BatchSendOperation { - - /** - * Send a {@link Collection}<{@link Message}> to the given destination with a given partition supplier. - * @param destination destination - * @param messages message set - * @param partitionSupplier partition supplier - * @param payload type in message - * @return Mono Void - */ - Mono sendAsync(String destination, Collection> messages, - PartitionSupplier partitionSupplier); - - /** - * Send a {@link Collection}<{@link Message}> to the given destination. - * @param destination destination - * @param messages message set - * @param payload type in message - * @return Mono Void - */ - default Mono sendAsync(String destination, Collection> messages) { - return sendAsync(destination, messages, null); - } -} diff --git a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/reactor/SendOperation.java b/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/reactor/SendOperation.java deleted file mode 100644 index 4a1325f3c555b..0000000000000 --- a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/reactor/SendOperation.java +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.spring.messaging.core.reactor; - -import com.azure.spring.messaging.PartitionSupplier; -import org.springframework.messaging.Message; -import reactor.core.publisher.Mono; - - -/** - * Operations for sending {@link Message} to a destination. - * - * @author Xiaolu Dai - */ -public interface SendOperation { - - /** - * Send a {@link Message} to the given destination with a given partition supplier. - * @param destination destination - * @param message message - * @param partitionSupplier partition supplier - * @param payload class in message - * @return Mono Void - */ - Mono sendAsync(String destination, Message message, PartitionSupplier partitionSupplier); - - /** - * Send a {@link Message} to the given destination. - * @param destination destination - * @param message message - * @param payload class in message - * @return Mono Void - */ - default Mono sendAsync(String destination, Message message) { - return sendAsync(destination, message, null); - } -} diff --git a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/reactor/package-info.java b/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/reactor/package-info.java deleted file mode 100644 index bc4f603d38464..0000000000000 --- a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/reactor/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -/** - * Package com.azure.spring.messaging.core.reactor; - */ -package com.azure.spring.messaging.core.reactor; diff --git a/sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/SendOperationTest.java b/sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/SendOperationTest.java index 399dfd4c473fd..c17d8c08d7252 100644 --- a/sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/SendOperationTest.java +++ b/sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/SendOperationTest.java @@ -3,8 +3,6 @@ package com.azure.spring.messaging.core; -import com.azure.spring.messaging.PartitionSupplier; -import org.assertj.core.api.Fail; import org.junit.jupiter.api.Test; import org.springframework.core.NestedRuntimeException; import org.springframework.messaging.Message; @@ -13,22 +11,20 @@ import java.util.HashMap; import java.util.Map; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; +import static org.assertj.core.api.Fail.fail; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; public abstract class SendOperationTest { + protected String consumerGroup = "consumer-group"; protected String destination = "event-hub"; protected Message message; protected Mono mono = Mono.empty(); - protected String partitionKey = "key"; protected String payload = "payload"; - protected O sendOperation = null; - private String partitionId = "1"; + protected O sendOperation; public SendOperationTest() { Map valueMap = new HashMap<>(2); @@ -39,105 +35,50 @@ public SendOperationTest() { protected abstract void setupError(String errorMessage); - @Test - public void testSendCreateSenderFailure() throws Throwable { - whenSendWithException(); - - assertThrows(NestedRuntimeException.class, - () -> this.sendOperation.sendAsync(destination, this.message, null).get()); - } @Test - public void testSendFailure() { - setupError("future failed."); - CompletableFuture future = this.sendOperation.sendAsync(destination, this.message, null); - - try { - future.get(); - Fail.fail("Test should fail."); - } catch (InterruptedException ie) { - Fail.fail("get() should fail with an ExecutionException."); - } catch (ExecutionException ee) { - assertEquals("future failed.", ee.getCause().getMessage()); - } - } - - @Test - public void testSendWithPartitionId() throws ExecutionException, InterruptedException { - PartitionSupplier partitionSupplier = new PartitionSupplier(); - partitionSupplier.setPartitionId(partitionId); - CompletableFuture future = this.sendOperation.sendAsync(destination, message, partitionSupplier); - - assertNull(future.get()); - verifySendWithPartitionId(1); - verifyPartitionSenderCalled(1); - } - - @Test - public void testSendWithPartitionKey() throws ExecutionException, InterruptedException { - PartitionSupplier partitionSupplier = new PartitionSupplier(); - partitionSupplier.setPartitionKey(partitionKey); - CompletableFuture future = this.sendOperation.sendAsync(destination, message, partitionSupplier); - - assertNull(future.get()); - verifySendWithPartitionKey(1); - verifyGetClientCreator(1); - } - - @Test - public void testSendWithSessionId() throws ExecutionException, InterruptedException { - Map valueMap = new HashMap<>(); - valueMap.put("key1", "value1"); - valueMap.put("key2", "value2"); - valueMap.put("azure_service_bus_session_id", "TestSessionId"); - Message messageWithSeesionId = new GenericMessage<>("testPayload", valueMap); - CompletableFuture future = this.sendOperation.sendAsync(destination, messageWithSeesionId); + public void testSend() { + final Mono mono = this.sendOperation.sendAsync(destination, message, null); - assertNull(future.get()); + assertNull(mono.block()); verifySendCalled(1); } @Test - public void testSendWithSessionIdAndPartitionKeyDifferent() throws ExecutionException, InterruptedException { - Map valueMap = new HashMap<>(); - valueMap.put("key1", "value1"); - valueMap.put("key2", "value2"); - valueMap.put("azure_service_bus_session_id", "TestSessionId"); - valueMap.put("azure_service_bus_partition_key", "TestPartitionKey"); - Message messageWithSeesionIdAndPartitionKey = new GenericMessage<>("testPayload", valueMap); - CompletableFuture future = this.sendOperation.sendAsync(destination, messageWithSeesionIdAndPartitionKey); - - assertNull(future.get()); - verifySendCalled(1); - } - - @Test - public void testSendWithoutPartition() throws ExecutionException, InterruptedException { - CompletableFuture future = this.sendOperation.sendAsync(destination, message, new PartitionSupplier()); + public void testSendCreateSenderFailure() { + whenSendWithException(); - assertNull(future.get()); - verifySendCalled(1); + assertThrows(NestedRuntimeException.class, () -> this.sendOperation.sendAsync(destination, this.message, + null).block()); } @Test - public void testSendWithoutPartitionSupplier() throws ExecutionException, InterruptedException { - CompletableFuture future = this.sendOperation.sendAsync(destination, message, null); + public void testSendFailure() { + String errorMessage = "Send failed."; + setupError(errorMessage); + Mono mono = this.sendOperation.sendAsync(destination, this.message, null); - assertNull(future.get()); - verifySendCalled(1); + try { + mono.block(); + fail("Test should fail."); + } catch (Exception e) { + assertEquals(errorMessage, e.getMessage()); + } } protected abstract void verifyGetClientCreator(int times); - protected abstract void verifyPartitionSenderCalled(int times); - protected abstract void verifySendCalled(int times); - protected abstract void verifySendWithPartitionId(int times); + protected abstract void whenSendWithException(); - protected abstract void verifySendWithPartitionKey(int times); + public String getConsumerGroup() { + return consumerGroup; + } - protected abstract void whenSendWithException(); + public void setConsumerGroup(String consumerGroup) { + this.consumerGroup = consumerGroup; + } public Mono getMono() { return mono; diff --git a/sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/reactor/SendSubscribeByGroupOperationTest.java b/sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/SendSubscribeByGroupOperationTest.java similarity index 87% rename from sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/reactor/SendSubscribeByGroupOperationTest.java rename to sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/SendSubscribeByGroupOperationTest.java index d11ab8e93699c..23d22a95a33ca 100644 --- a/sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/reactor/SendSubscribeByGroupOperationTest.java +++ b/sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/SendSubscribeByGroupOperationTest.java @@ -1,10 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.spring.messaging.core.reactor; +package com.azure.spring.messaging.core; import com.azure.spring.messaging.checkpoint.CheckpointConfig; -import com.azure.spring.messaging.core.SubscribeByGroupOperation; import org.springframework.messaging.Message; import java.util.function.Consumer; diff --git a/sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/SendSubscribeOperationTest.java b/sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/SendSubscribeOperationTest.java index 2787b3f39187e..f68dcc2168edd 100644 --- a/sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/SendSubscribeOperationTest.java +++ b/sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/SendSubscribeOperationTest.java @@ -25,33 +25,30 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; -public abstract class SendSubscribeOperationTest { - protected T sendSubscribeOperation; +public abstract class SendSubscribeOperationTest { - protected String partitionId = "1"; protected String destination = "test"; - protected String payload = "payload"; - protected User user = new User(payload); - protected Map headers = new HashMap<>(); - protected Message userMessage = new GenericMessage<>(user, headers); - + protected String partitionId = "1"; + protected T sendSubscribeOperation; + private Map headers = new HashMap<>(); protected List> messages = IntStream.range(1, 5) .mapToObj(String::valueOf) .map(User::new) .map(u -> new GenericMessage<>(u, headers)) .collect(Collectors.toList()); - private final Message stringMessage = new GenericMessage<>(payload, headers); - private final Message byteMessage = new GenericMessage<>(payload.getBytes(StandardCharsets.UTF_8), headers); + private String payload = "payload"; + private Message byteMessage = new GenericMessage<>(payload.getBytes(StandardCharsets.UTF_8), headers); + private Message stringMessage = new GenericMessage<>(payload, headers); + protected User user = new User(payload); + protected Message userMessage = new GenericMessage<>(user, headers); + + protected abstract void setCheckpointConfig(CheckpointConfig checkpointConfig); @BeforeEach public abstract void setUp() throws Exception; - @Test - public void testSendString() { - subscribe(destination, this::stringHandler, String.class); - sendSubscribeOperation.sendAsync(destination, stringMessage); - } + protected abstract void subscribe(String destination, Consumer> consumer, Class payloadType); @Test public void testSendByte() { @@ -59,12 +56,6 @@ public void testSendByte() { sendSubscribeOperation.sendAsync(destination, byteMessage); } - @Test - public void testSendUser() { - subscribe(destination, this::userHandler, User.class); - sendSubscribeOperation.sendAsync(destination, userMessage); - } - @Test public void testSendReceiveWithManualCheckpointMode() { setCheckpointConfig(CheckpointConfig.builder().checkpointMode(CheckpointMode.MANUAL).build()); @@ -80,6 +71,39 @@ public void testSendReceiveWithRecordCheckpointMode() { verifyCheckpointSuccessCalled(messages.size()); } + @Test + public void testSendString() { + subscribe(destination, this::stringHandler, String.class); + sendSubscribeOperation.sendAsync(destination, stringMessage); + } + + @Test + public void testSendUser() { + subscribe(destination, this::userHandler, User.class); + sendSubscribeOperation.sendAsync(destination, userMessage); + } + + @Deprecated + protected abstract void verifyCheckpointBatchSuccessCalled(int times); + + protected void verifyCheckpointFailure(Checkpointer checkpointer) { + checkpointer.failure(); + verifyCheckpointFailureCalled(1); + } + + protected abstract void verifyCheckpointFailureCalled(int times); + + protected void verifyCheckpointSuccess(Checkpointer checkpointer) { + checkpointer.success(); + verifyCheckpointSuccessCalled(1); + } + + protected abstract void verifyCheckpointSuccessCalled(int times); + + private void byteHandler(Message message) { + assertEquals(payload, new String((byte[]) message.getPayload(), StandardCharsets.UTF_8)); + } + protected void manualCheckpointHandler(Message message) { assertTrue(message.getHeaders().containsKey(AzureHeaders.CHECKPOINTER)); Checkpointer checkpointer = message.getHeaders().get(AzureHeaders.CHECKPOINTER, Checkpointer.class); @@ -96,32 +120,16 @@ private void stringHandler(Message message) { assertEquals(payload, message.getPayload()); } - private void byteHandler(Message message) { - assertEquals(payload, new String((byte[]) message.getPayload(), StandardCharsets.UTF_8)); - } - private void userHandler(Message message) { assertEquals(user, message.getPayload()); } - protected abstract void verifyCheckpointSuccessCalled(int times); - - protected abstract void verifyCheckpointBatchSuccessCalled(int times); - - protected abstract void verifyCheckpointFailureCalled(int times); - - protected abstract void subscribe(String destination, Consumer> consumer, Class payloadType); - - protected abstract void setCheckpointConfig(CheckpointConfig checkpointConfig); - - protected void verifyCheckpointSuccess(Checkpointer checkpointer) { - checkpointer.success(); - verifyCheckpointSuccessCalled(1); + public T getSendSubscribeOperation() { + return sendSubscribeOperation; } - protected void verifyCheckpointFailure(Checkpointer checkpointer) { - checkpointer.failure(); - verifyCheckpointFailureCalled(1); + public void setSendSubscribeOperation(T sendSubscribeOperation) { + this.sendSubscribeOperation = sendSubscribeOperation; } public String getPartitionId() { @@ -132,14 +140,6 @@ public void setPartitionId(String partitionId) { this.partitionId = partitionId; } - public T getSendSubscribeOperation() { - return sendSubscribeOperation; - } - - public void setSendSubscribeOperation(T sendSubscribeOperation) { - this.sendSubscribeOperation = sendSubscribeOperation; - } - protected void waitMillis(long millis) { if (millis <= 0) { millis = 30; diff --git a/sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/reactor/SendOperationTest.java b/sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/reactor/SendOperationTest.java deleted file mode 100644 index ba9439791226c..0000000000000 --- a/sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/reactor/SendOperationTest.java +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.spring.messaging.core.reactor; - -import org.junit.jupiter.api.Test; -import org.springframework.core.NestedRuntimeException; -import org.springframework.messaging.Message; -import org.springframework.messaging.support.GenericMessage; -import reactor.core.publisher.Mono; - -import java.util.HashMap; -import java.util.Map; - -import static org.assertj.core.api.Fail.fail; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertThrows; - -public abstract class SendOperationTest { - - protected String consumerGroup = "consumer-group"; - protected String destination = "event-hub"; - protected Message message; - protected Mono mono = Mono.empty(); - protected String payload = "payload"; - protected O sendOperation; - - public SendOperationTest() { - Map valueMap = new HashMap<>(2); - valueMap.put("key1", "value1"); - valueMap.put("key2", "value2"); - message = new GenericMessage<>("testPayload", valueMap); - } - - protected abstract void setupError(String errorMessage); - - - @Test - public void testSend() { - final Mono mono = this.sendOperation.sendAsync(destination, message, null); - - assertNull(mono.block()); - verifySendCalled(1); - } - - @Test - public void testSendCreateSenderFailure() { - whenSendWithException(); - - assertThrows(NestedRuntimeException.class, () -> this.sendOperation.sendAsync(destination, this.message, - null).block()); - } - - @Test - public void testSendFailure() { - String errorMessage = "Send failed."; - setupError(errorMessage); - Mono mono = this.sendOperation.sendAsync(destination, this.message, null); - - try { - mono.block(); - fail("Test should fail."); - } catch (Exception e) { - assertEquals(errorMessage, e.getMessage()); - } - } - - protected abstract void verifyGetClientCreator(int times); - - protected abstract void verifySendCalled(int times); - - protected abstract void whenSendWithException(); - - public String getConsumerGroup() { - return consumerGroup; - } - - public void setConsumerGroup(String consumerGroup) { - this.consumerGroup = consumerGroup; - } - - public Mono getMono() { - return mono; - } - - public void setMono(Mono mono) { - this.mono = mono; - } - - public String getPayload() { - return payload; - } - - public void setPayload(String payload) { - this.payload = payload; - } - - public O getSendOperation() { - return sendOperation; - } - - public void setSendOperation(O sendOperation) { - this.sendOperation = sendOperation; - } -} diff --git a/sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/reactor/SendSubscribeOperationTest.java b/sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/reactor/SendSubscribeOperationTest.java deleted file mode 100644 index 3078c9f30d5c5..0000000000000 --- a/sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/reactor/SendSubscribeOperationTest.java +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.spring.messaging.core.reactor; - -import com.azure.spring.messaging.AzureHeaders; -import com.azure.spring.messaging.checkpoint.CheckpointConfig; -import com.azure.spring.messaging.checkpoint.CheckpointMode; -import com.azure.spring.messaging.checkpoint.reactor.Checkpointer; -import com.azure.spring.messaging.support.pojo.User; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.springframework.messaging.Message; -import org.springframework.messaging.support.GenericMessage; - -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Consumer; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - - -public abstract class SendSubscribeOperationTest { - - protected String destination = "test"; - protected String partitionId = "1"; - protected T sendSubscribeOperation; - private Map headers = new HashMap<>(); - protected List> messages = IntStream.range(1, 5) - .mapToObj(String::valueOf) - .map(User::new) - .map(u -> new GenericMessage<>(u, headers)) - .collect(Collectors.toList()); - private String payload = "payload"; - private Message byteMessage = new GenericMessage<>(payload.getBytes(StandardCharsets.UTF_8), headers); - private Message stringMessage = new GenericMessage<>(payload, headers); - private User user = new User(payload); - protected Message userMessage = new GenericMessage<>(user, headers); - - protected abstract void setCheckpointConfig(CheckpointConfig checkpointConfig); - - @BeforeEach - public abstract void setUp(); - - protected abstract void subscribe(String destination, Consumer> consumer, Class payloadType); - - @Test - public void testSendByte() { - subscribe(destination, this::byteHandler, byte[].class); - sendSubscribeOperation.sendAsync(destination, byteMessage); - } - - @Test - public void testSendReceiveWithManualCheckpointMode() { - setCheckpointConfig(CheckpointConfig.builder().checkpointMode(CheckpointMode.MANUAL).build()); - subscribe(destination, this::manualCheckpointHandler, User.class); - sendSubscribeOperation.sendAsync(destination, userMessage); - } - - @Test - public void testSendReceiveWithRecordCheckpointMode() { - setCheckpointConfig(CheckpointConfig.builder().checkpointMode(CheckpointMode.RECORD).build()); - subscribe(destination, this::recordCheckpointHandler, User.class); - messages.forEach(m -> sendSubscribeOperation.sendAsync(destination, m)); - verifyCheckpointSuccessCalled(messages.size()); - } - - @Test - public void testSendString() { - subscribe(destination, this::stringHandler, String.class); - sendSubscribeOperation.sendAsync(destination, stringMessage); - } - - @Test - public void testSendUser() { - subscribe(destination, this::userHandler, User.class); - sendSubscribeOperation.sendAsync(destination, userMessage); - } - - @Deprecated - protected abstract void verifyCheckpointBatchSuccessCalled(int times); - - protected void verifyCheckpointFailure(Checkpointer checkpointer) { - checkpointer.failure(); - verifyCheckpointFailureCalled(1); - } - - protected abstract void verifyCheckpointFailureCalled(int times); - - protected void verifyCheckpointSuccess(Checkpointer checkpointer) { - checkpointer.success(); - verifyCheckpointSuccessCalled(1); - } - - protected abstract void verifyCheckpointSuccessCalled(int times); - - private void byteHandler(Message message) { - assertEquals(payload, new String((byte[]) message.getPayload(), StandardCharsets.UTF_8)); - } - - private void manualCheckpointHandler(Message message) { - assertTrue(message.getHeaders().containsKey(AzureHeaders.CHECKPOINTER)); - Checkpointer checkpointer = message.getHeaders().get(AzureHeaders.CHECKPOINTER, Checkpointer.class); - assertNotNull(checkpointer); - verifyCheckpointSuccess(checkpointer); - verifyCheckpointFailure(checkpointer); - } - - private void recordCheckpointHandler(Message message) { - // - } - - private void stringHandler(Message message) { - assertEquals(payload, message.getPayload()); - } - - private void userHandler(Message message) { - assertEquals(user, message.getPayload()); - } - - public T getSendSubscribeOperation() { - return sendSubscribeOperation; - } - - public void setSendSubscribeOperation(T sendSubscribeOperation) { - this.sendSubscribeOperation = sendSubscribeOperation; - } - - public String getPartitionId() { - return partitionId; - } - - public void setPartitionId(String partitionId) { - this.partitionId = partitionId; - } -} diff --git a/sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/rx/RxSendSubscribeByGroupOperationTest.java b/sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/rx/RxSendSubscribeByGroupOperationTest.java deleted file mode 100644 index fe0eb21a33acd..0000000000000 --- a/sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/rx/RxSendSubscribeByGroupOperationTest.java +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.spring.messaging.core.rx; - -import com.azure.spring.messaging.checkpoint.CheckpointConfig; -import com.azure.spring.messaging.core.RxSendOperation; -import com.azure.spring.messaging.core.RxSubscribeByGroupOperation; -import org.springframework.messaging.Message; -import rx.Observable; - -public abstract class RxSendSubscribeByGroupOperationTest - extends RxSendSubscribeOperationTest { - - protected String consumerGroup = "group1"; - - @Override - protected Observable> subscribe(String destination, Class payloadType) { - return sendSubscribeOperation.subscribe(destination, consumerGroup, payloadType); - } - - @Override - protected void setCheckpointConfig(CheckpointConfig checkpointConfig) { - sendSubscribeOperation.setCheckpointConfig(checkpointConfig); - } - - public String getConsumerGroup() { - return consumerGroup; - } - - public void setConsumerGroup(String consumerGroup) { - this.consumerGroup = consumerGroup; - } - -} diff --git a/sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/rx/RxSendSubscribeOperationTest.java b/sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/rx/RxSendSubscribeOperationTest.java deleted file mode 100644 index d41d1d18daf95..0000000000000 --- a/sdk/spring/azure-spring-messaging/src/test/java/com/azure/spring/messaging/core/rx/RxSendSubscribeOperationTest.java +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.spring.messaging.core.rx; - -import com.azure.spring.messaging.checkpoint.CheckpointConfig; -import com.azure.spring.messaging.checkpoint.CheckpointMode; -import com.azure.spring.messaging.core.RxSendOperation; -import com.azure.spring.messaging.support.pojo.User; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.springframework.messaging.Message; -import org.springframework.messaging.support.GenericMessage; -import rx.Observable; -import rx.observers.AssertableSubscriber; - -import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.stream.IntStream; - -public abstract class RxSendSubscribeOperationTest { - - protected String destination = "test"; - protected String partitionId = "1"; - protected T sendSubscribeOperation; - private Map headers = new HashMap<>(); - @SuppressWarnings("unchecked") - protected Message[] messages = IntStream.range(1, 5) - .mapToObj(String::valueOf) - .map(User::new) - .map(u -> new GenericMessage<>(u, headers)) - .toArray(Message[]::new); - private String payload = "payload"; - private Message byteMessage = new GenericMessage<>(payload.getBytes(StandardCharsets.UTF_8), headers); - private Message stringMessage = new GenericMessage<>(payload, headers); - private User user = new User(payload); - protected Message userMessage = new GenericMessage<>(user, headers); - - protected abstract void setCheckpointConfig(CheckpointConfig checkpointConfig); - - @BeforeEach - public abstract void setUp(); - - protected abstract Observable> subscribe(String destination, Class payloadType); - - @Test - public void testSendByte() { - AssertableSubscriber subscriber = subscribe(destination, byte[].class).map(Message::getPayload) - .cast(byte[].class) - .map(String::new) - .test(); - sendSubscribeOperation.sendRx(destination, byteMessage); - subscriber.assertValue(payload).assertNoErrors(); - } - - @Test - public void testSendReceiveWithManualCheckpointMode() { - setCheckpointConfig(CheckpointConfig.builder().checkpointMode(CheckpointMode.MANUAL).build()); - - Observable> observable = subscribe(destination, User.class); - AssertableSubscriber userSubscriber = observable.map(Message::getPayload).cast(User.class).test(); - sendSubscribeOperation.sendRx(destination, userMessage); - userSubscriber.assertValue(user).assertNoErrors(); - verifyCheckpointSuccessCalled(0); - } - - @Test - public void testSendReceiveWithRecordCheckpointMode() { - setCheckpointConfig(CheckpointConfig.builder().checkpointMode(CheckpointMode.RECORD).build()); - AssertableSubscriber subscriber = subscribe(destination, User.class).map(Message::getPayload) - .cast(User.class) - .test(); - Arrays.stream(messages).forEach(m -> sendSubscribeOperation.sendRx(destination, m)); - subscriber.assertValueCount(messages.length).assertNoErrors(); - verifyCheckpointSuccessCalled(messages.length); - } - - @Test - public void testSendString() { - AssertableSubscriber subscriber = subscribe(destination, String.class).map(Message::getPayload) - .cast(String.class) - .test(); - sendSubscribeOperation.sendRx(destination, stringMessage); - subscriber.assertValue(payload).assertNoErrors(); - } - - @Test - public void testSendUser() { - AssertableSubscriber subscriber = subscribe(destination, User.class).map(Message::getPayload) - .cast(User.class) - .test(); - sendSubscribeOperation.sendRx(destination, userMessage); - subscriber.assertValue(user).assertNoErrors(); - } - - protected abstract void verifyCheckpointBatchSuccessCalled(int times); - - protected abstract void verifyCheckpointSuccessCalled(int times); - - public String getPartitionId() { - return partitionId; - } - - public void setPartitionId(String partitionId) { - this.partitionId = partitionId; - } - - public T getSendSubscribeOperation() { - return sendSubscribeOperation; - } - - public void setSendSubscribeOperation(T sendSubscribeOperation) { - this.sendSubscribeOperation = sendSubscribeOperation; - } -} diff --git a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/DefaultServiceBusMessageProcessor.java b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/DefaultServiceBusMessageProcessor.java index 18109f5df0a6a..0d0ae82898512 100644 --- a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/DefaultServiceBusMessageProcessor.java +++ b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/DefaultServiceBusMessageProcessor.java @@ -17,10 +17,10 @@ import org.slf4j.LoggerFactory; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHeaders; +import reactor.core.publisher.Mono; import java.util.HashMap; import java.util.Map; -import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; /** @@ -57,7 +57,8 @@ public Consumer processMessage() { return context -> { Map headers = new HashMap<>(); - Checkpointer checkpointer = new AzureCheckpointer(() -> success(context), () -> fail(context)); + Checkpointer checkpointer = new AzureCheckpointer(() -> Mono.fromRunnable(context::complete), + () -> Mono.fromRunnable(context::abandon)); headers.put(ServiceBusMessageHeaders.RECEIVED_MESSAGE_CONTEXT, context); if (this.checkpointConfig.getCheckpointMode() == CheckpointMode.MANUAL) { @@ -69,35 +70,24 @@ public Consumer processMessage() { consumer.accept(message); if (this.checkpointConfig.getCheckpointMode() == CheckpointMode.RECORD) { - checkpointer.success().whenComplete((v, t) -> checkpointHandler(message, t)); + checkpointer.success() + .doOnSuccess(t -> buildCheckpointSuccessMessage(message)) + .doOnError(t -> buildCheckpointFailMessage(message, t)) + .subscribe(); } }; } - private CompletableFuture success(ServiceBusReceivedMessageContext context) { - return CompletableFuture.runAsync(context::complete); - } - - private CompletableFuture fail(ServiceBusReceivedMessageContext context) { - return CompletableFuture.runAsync(context::abandon); - } - - private void checkpointHandler(Message message, Throwable t) { - if (t != null) { - if (LOGGER.isWarnEnabled()) { - LOGGER.warn(buildCheckpointFailMessage(message), t); - } - } else if (LOGGER.isDebugEnabled()) { - LOGGER.debug(buildCheckpointSuccessMessage(message)); + protected void buildCheckpointFailMessage(Message message, Throwable t) { + if (LOGGER.isWarnEnabled()) { + LOGGER.warn(String.format(MSG_FAIL_CHECKPOINT, message), t); } } - protected String buildCheckpointFailMessage(Message message) { - return String.format(MSG_FAIL_CHECKPOINT, message); - } - - protected String buildCheckpointSuccessMessage(Message message) { - return String.format(MSG_SUCCESS_CHECKPOINT, message, this.checkpointConfig.getCheckpointMode()); + protected void buildCheckpointSuccessMessage(Message message) { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug(String.format(MSG_SUCCESS_CHECKPOINT, message, this.checkpointConfig.getCheckpointMode())); + } } } diff --git a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/ServiceBusTemplate.java b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/ServiceBusTemplate.java index bff9e5205c857..4625595d84b9a 100644 --- a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/ServiceBusTemplate.java +++ b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/ServiceBusTemplate.java @@ -20,9 +20,9 @@ import org.springframework.messaging.Message; import org.springframework.util.Assert; import org.springframework.util.StringUtils; +import reactor.core.publisher.Mono; import java.util.Objects; -import java.util.concurrent.CompletableFuture; import static com.azure.spring.messaging.checkpoint.CheckpointMode.MANUAL; import static com.azure.spring.messaging.checkpoint.CheckpointMode.RECORD; @@ -55,9 +55,9 @@ public ServiceBusTemplate(@NonNull T senderFactory, @NonNull ServiceBusMessageCo } @Override - public CompletableFuture sendAsync(String destination, - Message message, - PartitionSupplier partitionSupplier) { + public Mono sendAsync(String destination, + Message message, + PartitionSupplier partitionSupplier) { Assert.hasText(destination, "destination can't be null or empty"); ServiceBusSenderAsyncClient senderAsyncClient = null; ServiceBusMessage serviceBusMessage = messageConverter.fromMessage(message, ServiceBusMessage.class); @@ -77,7 +77,7 @@ public CompletableFuture sendAsync(String destination, throw new ServiceBusRuntimeException("ServiceBus send client startup failed, Caused by " + e.getMessage(), e); } - return senderAsyncClient.sendMessage(serviceBusMessage).toFuture(); + return senderAsyncClient.sendMessage(serviceBusMessage); } public InstrumentationManager getInstrumentationManager() { diff --git a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/queue/ServiceBusQueueTemplate.java b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/queue/ServiceBusQueueTemplate.java index cbd886f15d2cd..d410387e5e4e5 100644 --- a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/queue/ServiceBusQueueTemplate.java +++ b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/queue/ServiceBusQueueTemplate.java @@ -60,13 +60,17 @@ protected void internalSubscribe(String name, Consumer> consumer, Cla this.checkpointConfig, payloadType, consumer, this.messageConverter) { @Override - protected String buildCheckpointFailMessage(Message message) { - return String.format(MSG_FAIL_CHECKPOINT, message, name); + protected void buildCheckpointFailMessage(Message message, Throwable t) { + if (LOGGER.isWarnEnabled()) { + LOGGER.warn(String.format(MSG_FAIL_CHECKPOINT, message, name), t); + } } @Override - protected String buildCheckpointSuccessMessage(Message message) { - return String.format(MSG_SUCCESS_CHECKPOINT, message, name, getCheckpointConfig().getCheckpointMode()); + protected void buildCheckpointSuccessMessage(Message message) { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug(String.format(MSG_SUCCESS_CHECKPOINT, message, name, getCheckpointConfig().getCheckpointMode())); + } } }; Instrumentation instrumentation = new Instrumentation(name, Instrumentation.Type.CONSUME); diff --git a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/topic/ServiceBusTopicTemplate.java b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/topic/ServiceBusTopicTemplate.java index 2d98ad6eff59d..c72054d16cc70 100644 --- a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/topic/ServiceBusTopicTemplate.java +++ b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/topic/ServiceBusTopicTemplate.java @@ -98,14 +98,18 @@ protected void internalSubscribe(String name, final DefaultServiceBusMessageProcessor messageProcessor = new DefaultServiceBusMessageProcessor( this.checkpointConfig, payloadType, consumer, this.messageConverter) { @Override - protected String buildCheckpointFailMessage(Message message) { - return String.format(MSG_FAIL_CHECKPOINT, consumer, name, message); + protected void buildCheckpointFailMessage(Message message, Throwable t) { + if (LOGGER.isWarnEnabled()) { + LOGGER.warn(String.format(MSG_FAIL_CHECKPOINT, consumer, name, message), t); + } } @Override - protected String buildCheckpointSuccessMessage(Message message) { - return String.format(MSG_SUCCESS_CHECKPOINT, consumer, name, message, - getCheckpointConfig().getCheckpointMode()); + protected void buildCheckpointSuccessMessage(Message message) { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug(String.format(MSG_SUCCESS_CHECKPOINT, consumer, name, message, + getCheckpointConfig().getCheckpointMode())); + } } }; Instrumentation instrumentation = new Instrumentation(name + consumerGroup, Instrumentation.Type.CONSUME); diff --git a/sdk/spring/azure-spring-servicebus/src/test/java/com/azure/spring/servicebus/core/ServiceBusTemplateSendTest.java b/sdk/spring/azure-spring-servicebus/src/test/java/com/azure/spring/servicebus/core/ServiceBusTemplateSendTest.java index 71ed40e98d490..0fe887197e2aa 100644 --- a/sdk/spring/azure-spring-servicebus/src/test/java/com/azure/spring/servicebus/core/ServiceBusTemplateSendTest.java +++ b/sdk/spring/azure-spring-servicebus/src/test/java/com/azure/spring/servicebus/core/ServiceBusTemplateSendTest.java @@ -5,12 +5,21 @@ import com.azure.messaging.servicebus.ServiceBusMessage; import com.azure.messaging.servicebus.ServiceBusSenderAsyncClient; +import com.azure.spring.messaging.PartitionSupplier; import com.azure.spring.messaging.core.SendOperation; import com.azure.spring.servicebus.support.ServiceBusRuntimeException; import com.azure.spring.messaging.core.SendOperationTest; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.messaging.Message; +import org.springframework.messaging.support.GenericMessage; import reactor.core.publisher.Mono; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ExecutionException; + +import static org.junit.jupiter.api.Assertions.assertNull; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.times; @@ -27,6 +36,11 @@ public abstract class ServiceBusTemplateSendTest extends SendOperationTest { + protected String destination = "event-hub"; + protected Mono mono = Mono.empty(); + protected String partitionKey = "key"; + protected String payload = "payload"; + private String partitionId = "1"; protected C mockClient; protected T mockClientFactory; @@ -44,7 +58,71 @@ protected void verifySendCalled(int times) { verify(this.mockClient, times(times)).sendMessage(isA(ServiceBusMessage.class)); } - @Override + @Test + public void testSendWithPartitionId() throws ExecutionException, InterruptedException { + PartitionSupplier partitionSupplier = new PartitionSupplier(); + partitionSupplier.setPartitionId(partitionId); + Mono mono = this.sendOperation.sendAsync(destination, message, partitionSupplier); + + assertNull(mono.block()); + verifySendWithPartitionId(1); + verifyPartitionSenderCalled(1); + } + + @Test + public void testSendWithPartitionKey() throws ExecutionException, InterruptedException { + PartitionSupplier partitionSupplier = new PartitionSupplier(); + partitionSupplier.setPartitionKey(partitionKey); + Mono mono = this.sendOperation.sendAsync(destination, message, partitionSupplier); + + assertNull(mono.block()); + verifySendWithPartitionKey(1); + verifyGetClientCreator(1); + } + + @Test + public void testSendWithSessionId() throws ExecutionException, InterruptedException { + Map valueMap = new HashMap<>(); + valueMap.put("key1", "value1"); + valueMap.put("key2", "value2"); + valueMap.put("azure_service_bus_session_id", "TestSessionId"); + Message messageWithSeesionId = new GenericMessage<>("testPayload", valueMap); + Mono mono = this.sendOperation.sendAsync(destination, messageWithSeesionId); + + assertNull(mono.block()); + verifySendCalled(1); + } + + @Test + public void testSendWithSessionIdAndPartitionKeyDifferent() throws ExecutionException, InterruptedException { + Map valueMap = new HashMap<>(); + valueMap.put("key1", "value1"); + valueMap.put("key2", "value2"); + valueMap.put("azure_service_bus_session_id", "TestSessionId"); + valueMap.put("azure_service_bus_partition_key", "TestPartitionKey"); + Message messageWithSeesionIdAndPartitionKey = new GenericMessage<>("testPayload", valueMap); + Mono mono = this.sendOperation.sendAsync(destination, messageWithSeesionIdAndPartitionKey); + + assertNull(mono.block()); + verifySendCalled(1); + } + + @Test + public void testSendWithoutPartition() throws ExecutionException, InterruptedException { + Mono mono = this.sendOperation.sendAsync(destination, message, new PartitionSupplier()); + + assertNull(mono.block()); + verifySendCalled(1); + } + + @Test + public void testSendWithoutPartitionSupplier() throws ExecutionException, InterruptedException { + Mono mono = this.sendOperation.sendAsync(destination, message, null); + + assertNull(mono.block()); + verifySendCalled(1); + } + protected void verifyPartitionSenderCalled(int times) { verifySendCalled(times); } @@ -59,12 +137,10 @@ protected void verifyGetClientCreator(int times) { verify(this.mockClientFactory, times(times)).getOrCreateSender(anyString()); } - @Override protected void verifySendWithPartitionKey(int times) { verifySendCalled(times); } - @Override protected void verifySendWithPartitionId(int times) { verifySendCalled(times); } diff --git a/sdk/spring/azure-spring-servicebus/src/test/java/com/azure/spring/servicebus/support/ServiceBusQueueTestOperation.java b/sdk/spring/azure-spring-servicebus/src/test/java/com/azure/spring/servicebus/support/ServiceBusQueueTestOperation.java index 3278601fda806..3407674d5e11c 100644 --- a/sdk/spring/azure-spring-servicebus/src/test/java/com/azure/spring/servicebus/support/ServiceBusQueueTestOperation.java +++ b/sdk/spring/azure-spring-servicebus/src/test/java/com/azure/spring/servicebus/support/ServiceBusQueueTestOperation.java @@ -12,6 +12,7 @@ import com.azure.spring.servicebus.core.queue.ServiceBusQueueTemplate; import org.springframework.lang.NonNull; import org.springframework.messaging.Message; +import reactor.core.publisher.Mono; import java.util.ArrayList; import java.util.Arrays; @@ -21,7 +22,6 @@ import java.util.Map; import java.util.Optional; import java.util.Random; -import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; @@ -48,7 +48,7 @@ public ServiceBusQueueTestOperation(ServiceBusQueueClientFactory clientFactory) } @Override - public CompletableFuture sendAsync(String name, Message message, PartitionSupplier partitionSupplier) { + public Mono sendAsync(String name, Message message, PartitionSupplier partitionSupplier) { ServiceBusMessage azureMessage = getMessageConverter().fromMessage(message, ServiceBusMessage.class); final ServiceBusReceivedMessageContext receivedMessageContext = mockReceivedMessageContext(azureMessage); @@ -60,7 +60,7 @@ public CompletableFuture sendAsync(String name, Message message, Pa getRandom(processorsByQueue.get(name)).ifPresent(c -> c.processMessage().accept(receivedMessageContext)); - return CompletableFuture.completedFuture(null); + return Mono.empty(); } @Override diff --git a/sdk/spring/azure-spring-servicebus/src/test/java/com/azure/spring/servicebus/support/ServiceBusTopicTestOperation.java b/sdk/spring/azure-spring-servicebus/src/test/java/com/azure/spring/servicebus/support/ServiceBusTopicTestOperation.java index 15522da88e80c..2fc85970e5cdd 100644 --- a/sdk/spring/azure-spring-servicebus/src/test/java/com/azure/spring/servicebus/support/ServiceBusTopicTestOperation.java +++ b/sdk/spring/azure-spring-servicebus/src/test/java/com/azure/spring/servicebus/support/ServiceBusTopicTestOperation.java @@ -12,13 +12,13 @@ import com.azure.spring.servicebus.core.topic.ServiceBusTopicTemplate; import org.springframework.lang.NonNull; import org.springframework.messaging.Message; +import reactor.core.publisher.Mono; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; @@ -43,7 +43,7 @@ public ServiceBusTopicTestOperation(ServiceBusTopicClientFactory clientFactory) } @Override - public CompletableFuture sendAsync(String name, Message message, PartitionSupplier partitionSupplier) { + public Mono sendAsync(String name, Message message, PartitionSupplier partitionSupplier) { ServiceBusMessage azureMessage = getMessageConverter().fromMessage(message, ServiceBusMessage.class); @@ -55,7 +55,7 @@ public CompletableFuture sendAsync(String name, Message message, Pa } processorsByTopicAndSub.get(name).values().forEach(c -> c.processMessage().accept(receivedMessageContext)); - return CompletableFuture.completedFuture(null); + return Mono.empty(); } @Override diff --git a/sdk/spring/azure-spring-storage-queue/src/main/java/com/azure/spring/storage/queue/core/StorageQueueOperation.java b/sdk/spring/azure-spring-storage-queue/src/main/java/com/azure/spring/storage/queue/core/StorageQueueOperation.java index 04fe2c0e4cdf0..59abf2eb7b6fe 100644 --- a/sdk/spring/azure-spring-storage-queue/src/main/java/com/azure/spring/storage/queue/core/StorageQueueOperation.java +++ b/sdk/spring/azure-spring-storage-queue/src/main/java/com/azure/spring/storage/queue/core/StorageQueueOperation.java @@ -3,8 +3,8 @@ package com.azure.spring.storage.queue.core; -import com.azure.spring.messaging.core.reactor.ReceiveOperation; -import com.azure.spring.messaging.core.reactor.SendOperation; +import com.azure.spring.messaging.core.ReceiveOperation; +import com.azure.spring.messaging.core.SendOperation; /** * Azure storage queue operation to support send and receive diff --git a/sdk/spring/azure-spring-storage-queue/src/main/java/com/azure/spring/storage/queue/core/StorageQueueTemplate.java b/sdk/spring/azure-spring-storage-queue/src/main/java/com/azure/spring/storage/queue/core/StorageQueueTemplate.java index 73a754f23d176..263b488ca5bb4 100644 --- a/sdk/spring/azure-spring-storage-queue/src/main/java/com/azure/spring/storage/queue/core/StorageQueueTemplate.java +++ b/sdk/spring/azure-spring-storage-queue/src/main/java/com/azure/spring/storage/queue/core/StorageQueueTemplate.java @@ -9,8 +9,8 @@ import com.azure.spring.messaging.AzureHeaders; import com.azure.spring.messaging.checkpoint.CheckpointMode; import com.azure.spring.messaging.PartitionSupplier; -import com.azure.spring.messaging.checkpoint.reactor.AzureCheckpointer; -import com.azure.spring.messaging.checkpoint.reactor.Checkpointer; +import com.azure.spring.messaging.checkpoint.AzureCheckpointer; +import com.azure.spring.messaging.checkpoint.Checkpointer; import com.azure.spring.storage.queue.support.converter.StorageQueueMessageConverter; import com.azure.spring.storage.queue.support.StorageQueueHelper; import org.slf4j.Logger; diff --git a/sdk/spring/azure-spring-storage-queue/src/test/java/com/azure/spring/storage/queue/core/StorageQueueTemplateReceiveTest.java b/sdk/spring/azure-spring-storage-queue/src/test/java/com/azure/spring/storage/queue/core/StorageQueueTemplateReceiveTest.java index 9b28dac3746de..68f6374abb1f2 100644 --- a/sdk/spring/azure-spring-storage-queue/src/test/java/com/azure/spring/storage/queue/core/StorageQueueTemplateReceiveTest.java +++ b/sdk/spring/azure-spring-storage-queue/src/test/java/com/azure/spring/storage/queue/core/StorageQueueTemplateReceiveTest.java @@ -10,7 +10,7 @@ import com.azure.core.util.IterableStream; import com.azure.spring.messaging.AzureHeaders; import com.azure.spring.messaging.checkpoint.CheckpointMode; -import com.azure.spring.messaging.checkpoint.reactor.Checkpointer; +import com.azure.spring.messaging.checkpoint.Checkpointer; import com.azure.storage.queue.QueueAsyncClient; import com.azure.storage.queue.models.QueueMessageItem; import com.azure.storage.queue.models.QueueStorageException; diff --git a/sdk/spring/azure-spring-storage-queue/src/test/java/com/azure/spring/storage/queue/core/StorageQueueTemplateSendTest.java b/sdk/spring/azure-spring-storage-queue/src/test/java/com/azure/spring/storage/queue/core/StorageQueueTemplateSendTest.java index 5c2637d521828..56ee49d9285d0 100644 --- a/sdk/spring/azure-spring-storage-queue/src/test/java/com/azure/spring/storage/queue/core/StorageQueueTemplateSendTest.java +++ b/sdk/spring/azure-spring-storage-queue/src/test/java/com/azure/spring/storage/queue/core/StorageQueueTemplateSendTest.java @@ -3,7 +3,7 @@ package com.azure.spring.storage.queue.core; -import com.azure.spring.messaging.core.reactor.SendOperationTest; +import com.azure.spring.messaging.core.SendOperationTest; import com.azure.storage.queue.QueueAsyncClient; import com.azure.storage.queue.models.SendMessageResult; import org.junit.jupiter.api.AfterEach; diff --git a/sdk/spring/spring-cloud-azure-stream-binder-eventhubs/src/main/java/com/azure/spring/cloud/stream/binder/eventhubs/EventHubMessageChannelBinder.java b/sdk/spring/spring-cloud-azure-stream-binder-eventhubs/src/main/java/com/azure/spring/cloud/stream/binder/eventhubs/EventHubMessageChannelBinder.java index bec48bb9abf5d..1cefdb31e7f74 100644 --- a/sdk/spring/spring-cloud-azure-stream-binder-eventhubs/src/main/java/com/azure/spring/cloud/stream/binder/eventhubs/EventHubMessageChannelBinder.java +++ b/sdk/spring/spring-cloud-azure-stream-binder-eventhubs/src/main/java/com/azure/spring/cloud/stream/binder/eventhubs/EventHubMessageChannelBinder.java @@ -10,7 +10,7 @@ import com.azure.spring.eventhubs.core.EventHubOperation; import com.azure.spring.eventhubs.support.StartPosition; import com.azure.spring.integration.eventhubs.inbound.EventHubInboundChannelAdapter; -import com.azure.spring.integration.handler.reactor.DefaultMessageHandler; +import com.azure.spring.integration.handler.DefaultMessageHandler; import com.azure.spring.messaging.checkpoint.CheckpointConfig; import org.springframework.cloud.stream.binder.AbstractMessageChannelBinder; import org.springframework.cloud.stream.binder.BinderHeaders; diff --git a/sdk/spring/spring-cloud-azure-stream-binder-eventhubs/src/test/java/com/azure/spring/cloud/stream/binder/eventhubs/EventHubBinderConsumeErrorIT.java b/sdk/spring/spring-cloud-azure-stream-binder-eventhubs/src/test/java/com/azure/spring/cloud/stream/binder/eventhubs/EventHubBinderConsumeErrorIT.java index 9ba6cdccd3b19..568316d2b8bdf 100644 --- a/sdk/spring/spring-cloud-azure-stream-binder-eventhubs/src/test/java/com/azure/spring/cloud/stream/binder/eventhubs/EventHubBinderConsumeErrorIT.java +++ b/sdk/spring/spring-cloud-azure-stream-binder-eventhubs/src/test/java/com/azure/spring/cloud/stream/binder/eventhubs/EventHubBinderConsumeErrorIT.java @@ -4,7 +4,7 @@ package com.azure.spring.cloud.stream.binder.eventhubs; import com.azure.spring.messaging.AzureHeaders; -import com.azure.spring.messaging.checkpoint.reactor.Checkpointer; +import com.azure.spring.messaging.checkpoint.Checkpointer; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; diff --git a/sdk/spring/spring-cloud-azure-stream-binder-eventhubs/src/test/java/com/azure/spring/cloud/stream/binder/eventhubs/EventHubBinderManualModeIT.java b/sdk/spring/spring-cloud-azure-stream-binder-eventhubs/src/test/java/com/azure/spring/cloud/stream/binder/eventhubs/EventHubBinderManualModeIT.java index d529388eb16f2..ce99f01a20390 100644 --- a/sdk/spring/spring-cloud-azure-stream-binder-eventhubs/src/test/java/com/azure/spring/cloud/stream/binder/eventhubs/EventHubBinderManualModeIT.java +++ b/sdk/spring/spring-cloud-azure-stream-binder-eventhubs/src/test/java/com/azure/spring/cloud/stream/binder/eventhubs/EventHubBinderManualModeIT.java @@ -4,7 +4,7 @@ package com.azure.spring.cloud.stream.binder.eventhubs; import com.azure.spring.messaging.AzureHeaders; -import com.azure.spring.messaging.checkpoint.reactor.Checkpointer; +import com.azure.spring.messaging.checkpoint.Checkpointer; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.slf4j.Logger; diff --git a/sdk/spring/spring-cloud-azure-stream-binder-eventhubs/src/test/java/com/azure/spring/cloud/stream/binder/eventhubs/EventHubMessageChannelBinderTest.java b/sdk/spring/spring-cloud-azure-stream-binder-eventhubs/src/test/java/com/azure/spring/cloud/stream/binder/eventhubs/EventHubMessageChannelBinderTest.java index 0179c7e202a43..06b4af041188f 100644 --- a/sdk/spring/spring-cloud-azure-stream-binder-eventhubs/src/test/java/com/azure/spring/cloud/stream/binder/eventhubs/EventHubMessageChannelBinderTest.java +++ b/sdk/spring/spring-cloud-azure-stream-binder-eventhubs/src/test/java/com/azure/spring/cloud/stream/binder/eventhubs/EventHubMessageChannelBinderTest.java @@ -6,7 +6,7 @@ import com.azure.messaging.eventhubs.models.EventContext; import com.azure.spring.cloud.stream.binder.eventhubs.properties.EventHubProducerProperties; import com.azure.spring.cloud.stream.binder.eventhubs.provisioning.EventHubProducerDestination; -import com.azure.spring.integration.handler.reactor.DefaultMessageHandler; +import com.azure.spring.integration.handler.DefaultMessageHandler; import com.azure.spring.eventhubs.core.EventHubClientFactory; import com.azure.spring.eventhubs.support.EventHubTestOperation; import org.assertj.core.api.Assertions; diff --git a/sdk/spring/spring-cloud-azure-stream-binder-servicebus-queue/src/test/java/com/azure/spring/cloud/stream/binder/servicebus/support/ServiceBusQueueTestOperation.java b/sdk/spring/spring-cloud-azure-stream-binder-servicebus-queue/src/test/java/com/azure/spring/cloud/stream/binder/servicebus/support/ServiceBusQueueTestOperation.java index c581a2cd9281a..4eff49b8c1bbb 100644 --- a/sdk/spring/spring-cloud-azure-stream-binder-servicebus-queue/src/test/java/com/azure/spring/cloud/stream/binder/servicebus/support/ServiceBusQueueTestOperation.java +++ b/sdk/spring/spring-cloud-azure-stream-binder-servicebus-queue/src/test/java/com/azure/spring/cloud/stream/binder/servicebus/support/ServiceBusQueueTestOperation.java @@ -12,6 +12,7 @@ import com.azure.spring.servicebus.core.queue.ServiceBusQueueTemplate; import org.springframework.lang.NonNull; import org.springframework.messaging.Message; +import reactor.core.publisher.Mono; import java.util.ArrayList; import java.util.Arrays; @@ -21,7 +22,6 @@ import java.util.Map; import java.util.Optional; import java.util.Random; -import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; import static org.mockito.Mockito.mock; @@ -43,7 +43,7 @@ public ServiceBusQueueTestOperation(ServiceBusQueueClientFactory clientFactory) } @Override - public CompletableFuture sendAsync(String name, Message message, PartitionSupplier partitionSupplier) { + public Mono sendAsync(String name, Message message, PartitionSupplier partitionSupplier) { ServiceBusMessage azureMessage = getMessageConverter().fromMessage(message, ServiceBusMessage.class); final ServiceBusReceivedMessageContext receivedMessageContext = mockReceivedMessageContext(azureMessage); @@ -56,7 +56,7 @@ public CompletableFuture sendAsync(String name, Message message, Pa getRandom(processorsByQueue.get(name)).ifPresent(c -> c.processMessage().accept(receivedMessageContext)); - return CompletableFuture.completedFuture(null); + return Mono.empty(); } @Override diff --git a/sdk/spring/spring-cloud-azure-stream-binder-servicebus-topic/src/test/java/com/azure/spring/cloud/stream/binder/servicebus/support/ServiceBusTopicTestOperation.java b/sdk/spring/spring-cloud-azure-stream-binder-servicebus-topic/src/test/java/com/azure/spring/cloud/stream/binder/servicebus/support/ServiceBusTopicTestOperation.java index 1de1e55e319c1..39ee40e367ee9 100644 --- a/sdk/spring/spring-cloud-azure-stream-binder-servicebus-topic/src/test/java/com/azure/spring/cloud/stream/binder/servicebus/support/ServiceBusTopicTestOperation.java +++ b/sdk/spring/spring-cloud-azure-stream-binder-servicebus-topic/src/test/java/com/azure/spring/cloud/stream/binder/servicebus/support/ServiceBusTopicTestOperation.java @@ -12,13 +12,13 @@ import com.azure.spring.servicebus.core.topic.ServiceBusTopicTemplate; import org.springframework.lang.NonNull; import org.springframework.messaging.Message; +import reactor.core.publisher.Mono; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Consumer; @@ -39,7 +39,7 @@ public ServiceBusTopicTestOperation(ServiceBusTopicClientFactory clientFactory) } @Override - public CompletableFuture sendAsync(String name, Message message, PartitionSupplier partitionSupplier) { + public Mono sendAsync(String name, Message message, PartitionSupplier partitionSupplier) { ServiceBusMessage azureMessage = getMessageConverter().fromMessage(message, ServiceBusMessage.class); @@ -52,7 +52,7 @@ public CompletableFuture sendAsync(String name, Message message, Pa } processorsByTopicAndSub.get(name).values().forEach(c -> c.processMessage().accept(receivedMessageContext)); - return CompletableFuture.completedFuture(null); + return Mono.empty(); } @Override From 4951d8c84d582765f4b70599793ef5b9eaafc469 Mon Sep 17 00:00:00 2001 From: yiliu6 Date: Sun, 26 Sep 2021 16:59:30 +0800 Subject: [PATCH 2/7] add sync api for operation class --- .../messaging/core/BatchSendOperation.java | 27 +++++++++++++++++-- .../messaging/core/ReceiveOperation.java | 11 +++++++- .../spring/messaging/core/SendOperation.java | 27 +++++++++++++++++-- .../queue/core/StorageQueueTemplate.java | 10 +++---- 4 files changed, 65 insertions(+), 10 deletions(-) diff --git a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/BatchSendOperation.java b/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/BatchSendOperation.java index f4336dc4fb1a7..3c0f9b220745e 100644 --- a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/BatchSendOperation.java +++ b/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/BatchSendOperation.java @@ -18,7 +18,7 @@ public interface BatchSendOperation { /** - * Send a {@link Collection}<{@link Message}> to the given destination with a given partition supplier. + * Send a {@link Collection}<{@link Message}> to the given destination with a given partition supplier asynchronously. * @param destination destination * @param messages message set * @param partitionSupplier partition supplier @@ -29,7 +29,7 @@ Mono sendAsync(String destination, Collection> messages, PartitionSupplier partitionSupplier); /** - * Send a {@link Collection}<{@link Message}> to the given destination. + * Send a {@link Collection}<{@link Message}> to the given destination asynchronously. * @param destination destination * @param messages message set * @param payload type in message @@ -38,4 +38,27 @@ Mono sendAsync(String destination, Collection> messages, default Mono sendAsync(String destination, Collection> messages) { return sendAsync(destination, messages, null); } + + /** + * Send a {@link Collection}<{@link Message}> to the given destination with a given partition supplier synchronously. + * @param destination destination + * @param messages message set + * @param partitionSupplier partition supplier + * @param payload type in message + * @return Mono Void + */ + default void send(String destination, Collection> messages, PartitionSupplier partitionSupplier) { + sendAsync(destination, messages, partitionSupplier).block(); + } + + /** + * Send a {@link Collection}<{@link Message}> to the given destination synchronously. + * @param destination destination + * @param messages message set + * @param payload type in message + * @return Mono Void + */ + default void send(String destination, Collection> messages) { + send(destination, messages, null); + } } diff --git a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/ReceiveOperation.java b/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/ReceiveOperation.java index d6c0c1fe79fc3..a0978466d8829 100644 --- a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/ReceiveOperation.java +++ b/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/ReceiveOperation.java @@ -17,12 +17,21 @@ public interface ReceiveOperation { /** - * Receive a message from destination async. + * Receive a message from destination asynchronously. * @param destination destination * @return {@link Mono} of the next available {@link Message} or {@code null} if empty */ Mono> receiveAsync(String destination); + /** + * Receive a message from destination synchronously. + * @param destination destination + * @return received {@link Message} or {@code null} if empty + */ + default Object receive(String destination) { + return receiveAsync(destination).block(); + } + /** * Set message payload type. Default is {@code byte[]} * @param messagePayloadType message payload type diff --git a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/SendOperation.java b/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/SendOperation.java index b7b692df15572..aa1959498b875 100644 --- a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/SendOperation.java +++ b/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/SendOperation.java @@ -16,7 +16,7 @@ public interface SendOperation { /** - * Send a {@link Message} to the given destination with a given partition supplier. + * Send a {@link Message} to the given destination with a given partition supplier asynchronously. * @param destination destination * @param message message * @param partitionSupplier partition supplier @@ -26,7 +26,7 @@ public interface SendOperation { Mono sendAsync(String destination, Message message, PartitionSupplier partitionSupplier); /** - * Send a {@link Message} to the given destination. + * Send a {@link Message} to the given destination asynchronously. * @param destination destination * @param message message * @param payload class in message @@ -35,4 +35,27 @@ public interface SendOperation { default Mono sendAsync(String destination, Message message) { return sendAsync(destination, message, null); } + + /** + * Send a {@link Message} to the given destination with a given partition supplier synchronously. + * @param destination destination + * @param message message + * @param partitionSupplier partition supplier + * @param payload class in message + * @return void + */ + default void send(String destination, Message message, PartitionSupplier partitionSupplier) { + sendAsync(destination, message, partitionSupplier).block(); + } + + /** + * Send a {@link Message} to the given destination synchronously. + * @param destination destination + * @param message message + * @param payload class in message + * @return void + */ + default void send(String destination, Message message) { + send(destination, message, null); + } } diff --git a/sdk/spring/azure-spring-storage-queue/src/main/java/com/azure/spring/storage/queue/core/StorageQueueTemplate.java b/sdk/spring/azure-spring-storage-queue/src/main/java/com/azure/spring/storage/queue/core/StorageQueueTemplate.java index 263b488ca5bb4..03019ba71fa14 100644 --- a/sdk/spring/azure-spring-storage-queue/src/main/java/com/azure/spring/storage/queue/core/StorageQueueTemplate.java +++ b/sdk/spring/azure-spring-storage-queue/src/main/java/com/azure/spring/storage/queue/core/StorageQueueTemplate.java @@ -3,16 +3,16 @@ package com.azure.spring.storage.queue.core; -import com.azure.storage.queue.QueueAsyncClient; -import com.azure.storage.queue.models.QueueMessageItem; -import com.azure.storage.queue.models.QueueStorageException; import com.azure.spring.messaging.AzureHeaders; -import com.azure.spring.messaging.checkpoint.CheckpointMode; import com.azure.spring.messaging.PartitionSupplier; import com.azure.spring.messaging.checkpoint.AzureCheckpointer; +import com.azure.spring.messaging.checkpoint.CheckpointMode; import com.azure.spring.messaging.checkpoint.Checkpointer; -import com.azure.spring.storage.queue.support.converter.StorageQueueMessageConverter; import com.azure.spring.storage.queue.support.StorageQueueHelper; +import com.azure.spring.storage.queue.support.converter.StorageQueueMessageConverter; +import com.azure.storage.queue.QueueAsyncClient; +import com.azure.storage.queue.models.QueueMessageItem; +import com.azure.storage.queue.models.QueueStorageException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.lang.NonNull; From 4022dd594ea0793ca34109ce194f480474ccbfc6 Mon Sep 17 00:00:00 2001 From: yiliu6 Date: Sun, 26 Sep 2021 17:19:45 +0800 Subject: [PATCH 3/7] fix javadoc error --- .../com/azure/spring/messaging/core/BatchSendOperation.java | 2 -- .../java/com/azure/spring/messaging/core/SendOperation.java | 2 -- 2 files changed, 4 deletions(-) diff --git a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/BatchSendOperation.java b/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/BatchSendOperation.java index 3c0f9b220745e..27ca4cc4cfa5a 100644 --- a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/BatchSendOperation.java +++ b/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/BatchSendOperation.java @@ -45,7 +45,6 @@ default Mono sendAsync(String destination, Collection> mess * @param messages message set * @param partitionSupplier partition supplier * @param payload type in message - * @return Mono Void */ default void send(String destination, Collection> messages, PartitionSupplier partitionSupplier) { sendAsync(destination, messages, partitionSupplier).block(); @@ -56,7 +55,6 @@ default void send(String destination, Collection> messages, Parti * @param destination destination * @param messages message set * @param payload type in message - * @return Mono Void */ default void send(String destination, Collection> messages) { send(destination, messages, null); diff --git a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/SendOperation.java b/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/SendOperation.java index aa1959498b875..281011bda8086 100644 --- a/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/SendOperation.java +++ b/sdk/spring/azure-spring-messaging/src/main/java/com/azure/spring/messaging/core/SendOperation.java @@ -42,7 +42,6 @@ default Mono sendAsync(String destination, Message message) { * @param message message * @param partitionSupplier partition supplier * @param payload class in message - * @return void */ default void send(String destination, Message message, PartitionSupplier partitionSupplier) { sendAsync(destination, message, partitionSupplier).block(); @@ -53,7 +52,6 @@ default void send(String destination, Message message, PartitionSupplier * @param destination destination * @param message message * @param payload class in message - * @return void */ default void send(String destination, Message message) { send(destination, message, null); From 09bebb888795efa9e7cbe18fe49eecf8e3e98870 Mon Sep 17 00:00:00 2001 From: yiliu6 Date: Mon, 27 Sep 2021 09:49:15 +0800 Subject: [PATCH 4/7] update method name for logging --- .../core/DefaultServiceBusMessageProcessor.java | 8 ++++---- .../servicebus/core/queue/ServiceBusQueueTemplate.java | 4 ++-- .../servicebus/core/topic/ServiceBusTopicTemplate.java | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/DefaultServiceBusMessageProcessor.java b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/DefaultServiceBusMessageProcessor.java index 0d0ae82898512..eccd173828c80 100644 --- a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/DefaultServiceBusMessageProcessor.java +++ b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/DefaultServiceBusMessageProcessor.java @@ -71,20 +71,20 @@ public Consumer processMessage() { if (this.checkpointConfig.getCheckpointMode() == CheckpointMode.RECORD) { checkpointer.success() - .doOnSuccess(t -> buildCheckpointSuccessMessage(message)) - .doOnError(t -> buildCheckpointFailMessage(message, t)) + .doOnSuccess(t -> logCheckpointSuccess(message)) + .doOnError(t -> logCheckpointFail(message, t)) .subscribe(); } }; } - protected void buildCheckpointFailMessage(Message message, Throwable t) { + protected void logCheckpointFail(Message message, Throwable t) { if (LOGGER.isWarnEnabled()) { LOGGER.warn(String.format(MSG_FAIL_CHECKPOINT, message), t); } } - protected void buildCheckpointSuccessMessage(Message message) { + protected void logCheckpointSuccess(Message message) { if (LOGGER.isDebugEnabled()) { LOGGER.debug(String.format(MSG_SUCCESS_CHECKPOINT, message, this.checkpointConfig.getCheckpointMode())); } diff --git a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/queue/ServiceBusQueueTemplate.java b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/queue/ServiceBusQueueTemplate.java index d410387e5e4e5..4e1fedc30f573 100644 --- a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/queue/ServiceBusQueueTemplate.java +++ b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/queue/ServiceBusQueueTemplate.java @@ -60,14 +60,14 @@ protected void internalSubscribe(String name, Consumer> consumer, Cla this.checkpointConfig, payloadType, consumer, this.messageConverter) { @Override - protected void buildCheckpointFailMessage(Message message, Throwable t) { + protected void logCheckpointFail(Message message, Throwable t) { if (LOGGER.isWarnEnabled()) { LOGGER.warn(String.format(MSG_FAIL_CHECKPOINT, message, name), t); } } @Override - protected void buildCheckpointSuccessMessage(Message message) { + protected void logCheckpointSuccess(Message message) { if (LOGGER.isDebugEnabled()) { LOGGER.debug(String.format(MSG_SUCCESS_CHECKPOINT, message, name, getCheckpointConfig().getCheckpointMode())); } diff --git a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/topic/ServiceBusTopicTemplate.java b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/topic/ServiceBusTopicTemplate.java index 1cbd85d7eb6c5..90e943b13d68e 100644 --- a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/topic/ServiceBusTopicTemplate.java +++ b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/topic/ServiceBusTopicTemplate.java @@ -99,14 +99,14 @@ protected void internalSubscribe(String name, final DefaultServiceBusMessageProcessor messageProcessor = new DefaultServiceBusMessageProcessor( this.checkpointConfig, payloadType, consumer, this.messageConverter) { @Override - protected void buildCheckpointFailMessage(Message message, Throwable t) { + protected void logCheckpointFail(Message message, Throwable t) { if (LOGGER.isWarnEnabled()) { LOGGER.warn(String.format(MSG_FAIL_CHECKPOINT, consumer, name, message), t); } } @Override - protected void buildCheckpointSuccessMessage(Message message) { + protected void logCheckpointSuccess(Message message) { if (LOGGER.isDebugEnabled()) { LOGGER.debug(String.format(MSG_SUCCESS_CHECKPOINT, consumer, name, message, getCheckpointConfig().getCheckpointMode())); From f852ebf6d49f91f31d4c691209178f41bd191929 Mon Sep 17 00:00:00 2001 From: yiliu6 Date: Mon, 27 Sep 2021 10:10:54 +0800 Subject: [PATCH 5/7] move provisioner from autoconfigure to messaging modules --- .../eventhub/resourcemanager/package-info.java | 7 ------- .../AzureEventHubResourceManagerAutoConfiguration.java | 4 ++-- .../AzureServiceBusResourceManagerAutoConfiguration.java | 8 ++++---- .../AzureServiceBusQueueOperationAutoConfiguration.java | 2 +- .../AzureServiceBusTopicOperationAutoConfiguration.java | 2 +- .../servicebus/resourcemanager/package-info.java | 7 ------- sdk/spring/azure-spring-eventhubs/pom.xml | 7 ++++++- .../resourcemanager/DefaultEventHubProvisioner.java | 4 +--- .../{core => resourcemanager}/EventHubProvisioner.java | 2 +- .../spring/eventhubs/resourcemanager/package-info.java | 7 +++++++ sdk/spring/azure-spring-servicebus/pom.xml | 7 +++++++ .../servicebus/core/AbstractServiceBusSenderFactory.java | 2 ++ .../DefaultServiceBusQueueProvisioner.java | 3 +-- .../DefaultServiceBusTopicProvisioner.java | 3 +-- .../ServiceBusQueueProvisioner.java | 2 +- .../ServiceBusTopicProvisioner.java | 2 +- .../spring/servicebus/resourcemanager/package-info.java | 7 +++++++ .../config/ServiceBusQueueBinderConfiguration.java | 2 +- .../ServiceBusQueueChannelResourceManagerProvisioner.java | 2 +- .../config/ServiceBusTopicBinderConfiguration.java | 2 +- .../ServiceBusTopicChannelResourceManagerProvisioner.java | 2 +- 21 files changed, 47 insertions(+), 37 deletions(-) delete mode 100644 sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/eventhub/resourcemanager/package-info.java delete mode 100644 sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/resourcemanager/package-info.java rename sdk/spring/{azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/eventhub => azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs}/resourcemanager/DefaultEventHubProvisioner.java (91%) rename sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/{core => resourcemanager}/EventHubProvisioner.java (88%) create mode 100644 sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/resourcemanager/package-info.java rename sdk/spring/{azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure => azure-spring-servicebus/src/main/java/com/azure/spring}/servicebus/resourcemanager/DefaultServiceBusQueueProvisioner.java (87%) rename sdk/spring/{azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure => azure-spring-servicebus/src/main/java/com/azure/spring}/servicebus/resourcemanager/DefaultServiceBusTopicProvisioner.java (91%) rename sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/{core => resourcemanager}/ServiceBusQueueProvisioner.java (83%) rename sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/{core => resourcemanager}/ServiceBusTopicProvisioner.java (87%) create mode 100644 sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/package-info.java diff --git a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/eventhub/resourcemanager/package-info.java b/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/eventhub/resourcemanager/package-info.java deleted file mode 100644 index 15b4783e295a1..0000000000000 --- a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/eventhub/resourcemanager/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -/** - * Package com.azure.spring.cloud.autoconfigure.eventhub.resourcemanager - */ -package com.azure.spring.cloud.autoconfigure.eventhub.resourcemanager; diff --git a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/resourcemanager/AzureEventHubResourceManagerAutoConfiguration.java b/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/resourcemanager/AzureEventHubResourceManagerAutoConfiguration.java index 6d5d5f68a97b1..344d59039875e 100644 --- a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/resourcemanager/AzureEventHubResourceManagerAutoConfiguration.java +++ b/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/resourcemanager/AzureEventHubResourceManagerAutoConfiguration.java @@ -5,9 +5,9 @@ import com.azure.resourcemanager.AzureResourceManager; import com.azure.spring.cloud.autoconfigure.eventhub.AzureEventHubProperties; -import com.azure.spring.cloud.autoconfigure.eventhub.resourcemanager.DefaultEventHubProvisioner; +import com.azure.spring.eventhubs.resourcemanager.DefaultEventHubProvisioner; import com.azure.spring.cloud.resourcemanager.connectionstring.EventHubArmConnectionStringProvider; -import com.azure.spring.eventhubs.core.EventHubProvisioner; +import com.azure.spring.eventhubs.resourcemanager.EventHubProvisioner; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; diff --git a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/resourcemanager/AzureServiceBusResourceManagerAutoConfiguration.java b/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/resourcemanager/AzureServiceBusResourceManagerAutoConfiguration.java index 6216774ed5660..02b083666350d 100644 --- a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/resourcemanager/AzureServiceBusResourceManagerAutoConfiguration.java +++ b/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/resourcemanager/AzureServiceBusResourceManagerAutoConfiguration.java @@ -5,11 +5,11 @@ import com.azure.resourcemanager.AzureResourceManager; import com.azure.spring.cloud.autoconfigure.servicebus.AzureServiceBusProperties; -import com.azure.spring.cloud.autoconfigure.servicebus.resourcemanager.DefaultServiceBusQueueProvisioner; -import com.azure.spring.cloud.autoconfigure.servicebus.resourcemanager.DefaultServiceBusTopicProvisioner; +import com.azure.spring.servicebus.resourcemanager.DefaultServiceBusQueueProvisioner; +import com.azure.spring.servicebus.resourcemanager.DefaultServiceBusTopicProvisioner; import com.azure.spring.cloud.resourcemanager.connectionstring.ServiceBusArmConnectionStringProvider; -import com.azure.spring.servicebus.core.ServiceBusQueueProvisioner; -import com.azure.spring.servicebus.core.ServiceBusTopicProvisioner; +import com.azure.spring.servicebus.resourcemanager.ServiceBusQueueProvisioner; +import com.azure.spring.servicebus.resourcemanager.ServiceBusTopicProvisioner; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; diff --git a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusQueueOperationAutoConfiguration.java b/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusQueueOperationAutoConfiguration.java index 24f1f78e3372c..f59a5f3b05c60 100644 --- a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusQueueOperationAutoConfiguration.java +++ b/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusQueueOperationAutoConfiguration.java @@ -6,7 +6,7 @@ import com.azure.messaging.servicebus.ServiceBusClientBuilder; import com.azure.spring.servicebus.core.DefaultServiceBusQueueClientFactory; import com.azure.spring.servicebus.core.ServiceBusQueueClientFactory; -import com.azure.spring.servicebus.core.ServiceBusQueueProvisioner; +import com.azure.spring.servicebus.resourcemanager.ServiceBusQueueProvisioner; import com.azure.spring.servicebus.core.queue.ServiceBusQueueOperation; import com.azure.spring.servicebus.core.queue.ServiceBusQueueTemplate; import com.azure.spring.servicebus.support.converter.ServiceBusMessageConverter; diff --git a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusTopicOperationAutoConfiguration.java b/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusTopicOperationAutoConfiguration.java index 07e09920487e9..9d4da1ed2a842 100644 --- a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusTopicOperationAutoConfiguration.java +++ b/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusTopicOperationAutoConfiguration.java @@ -6,7 +6,7 @@ import com.azure.messaging.servicebus.ServiceBusClientBuilder; import com.azure.spring.servicebus.core.DefaultServiceBusTopicClientFactory; import com.azure.spring.servicebus.core.ServiceBusTopicClientFactory; -import com.azure.spring.servicebus.core.ServiceBusTopicProvisioner; +import com.azure.spring.servicebus.resourcemanager.ServiceBusTopicProvisioner; import com.azure.spring.servicebus.core.topic.ServiceBusTopicOperation; import com.azure.spring.servicebus.core.topic.ServiceBusTopicTemplate; import com.azure.spring.servicebus.support.converter.ServiceBusMessageConverter; diff --git a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/resourcemanager/package-info.java b/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/resourcemanager/package-info.java deleted file mode 100644 index 7699cc4b34ba1..0000000000000 --- a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/resourcemanager/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -/** - * Package com.azure.spring.cloud.autoconfigure.servicebus.resourcemanager - */ -package com.azure.spring.cloud.autoconfigure.servicebus.resourcemanager; diff --git a/sdk/spring/azure-spring-eventhubs/pom.xml b/sdk/spring/azure-spring-eventhubs/pom.xml index 485c7fafe85bb..b0df7a9550b9f 100644 --- a/sdk/spring/azure-spring-eventhubs/pom.xml +++ b/sdk/spring/azure-spring-eventhubs/pom.xml @@ -40,7 +40,12 @@ azure-messaging-eventhubs 5.10.1 - + + com.azure.spring + azure-spring-cloud-resourcemanager + 4.0.0-beta.1 + true + com.azure diff --git a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/eventhub/resourcemanager/DefaultEventHubProvisioner.java b/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/resourcemanager/DefaultEventHubProvisioner.java similarity index 91% rename from sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/eventhub/resourcemanager/DefaultEventHubProvisioner.java rename to sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/resourcemanager/DefaultEventHubProvisioner.java index 284786cf70622..cfad15cb45e07 100644 --- a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/eventhub/resourcemanager/DefaultEventHubProvisioner.java +++ b/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/resourcemanager/DefaultEventHubProvisioner.java @@ -1,15 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.spring.cloud.autoconfigure.eventhub.resourcemanager; +package com.azure.spring.eventhubs.resourcemanager; import com.azure.resourcemanager.AzureResourceManager; import com.azure.spring.cloud.resourcemanager.implementation.crud.EventHubConsumerGroupCrud; import com.azure.spring.cloud.resourcemanager.implementation.crud.EventHubCrud; import com.azure.spring.cloud.resourcemanager.implementation.crud.EventHubNamespaceCrud; import com.azure.spring.core.properties.resource.AzureResourceMetadata; -import com.azure.spring.eventhubs.core.EventHubProvisioner; -import reactor.util.function.Tuple2; import reactor.util.function.Tuples; /** diff --git a/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/core/EventHubProvisioner.java b/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/resourcemanager/EventHubProvisioner.java similarity index 88% rename from sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/core/EventHubProvisioner.java rename to sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/resourcemanager/EventHubProvisioner.java index b2a7018b32514..0a1fff7e72a90 100644 --- a/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/core/EventHubProvisioner.java +++ b/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/resourcemanager/EventHubProvisioner.java @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.spring.eventhubs.core; +package com.azure.spring.eventhubs.resourcemanager; /** * An interface to provision Event Hubs resources. diff --git a/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/resourcemanager/package-info.java b/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/resourcemanager/package-info.java new file mode 100644 index 0000000000000..92b7032ef708d --- /dev/null +++ b/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/resourcemanager/package-info.java @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +/** + * Package com.azure.spring.eventhubs.resourcemanager + */ +package com.azure.spring.eventhubs.resourcemanager; diff --git a/sdk/spring/azure-spring-servicebus/pom.xml b/sdk/spring/azure-spring-servicebus/pom.xml index 844087ec6a6b0..b73b28306a434 100644 --- a/sdk/spring/azure-spring-servicebus/pom.xml +++ b/sdk/spring/azure-spring-servicebus/pom.xml @@ -41,6 +41,13 @@ azure-messaging-servicebus 7.4.1 + + com.azure.spring + azure-spring-cloud-resourcemanager + 4.0.0-beta.1 + true + + org.springframework spring-tx diff --git a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/AbstractServiceBusSenderFactory.java b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/AbstractServiceBusSenderFactory.java index e9fba1fbc8f6f..b4d8223396b0b 100644 --- a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/AbstractServiceBusSenderFactory.java +++ b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/AbstractServiceBusSenderFactory.java @@ -4,6 +4,8 @@ package com.azure.spring.servicebus.core; import com.azure.messaging.servicebus.ServiceBusClientBuilder; +import com.azure.spring.servicebus.resourcemanager.ServiceBusQueueProvisioner; +import com.azure.spring.servicebus.resourcemanager.ServiceBusTopicProvisioner; import javax.annotation.Nullable; diff --git a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/resourcemanager/DefaultServiceBusQueueProvisioner.java b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/DefaultServiceBusQueueProvisioner.java similarity index 87% rename from sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/resourcemanager/DefaultServiceBusQueueProvisioner.java rename to sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/DefaultServiceBusQueueProvisioner.java index d90f888ed96e9..025d34722ba78 100644 --- a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/resourcemanager/DefaultServiceBusQueueProvisioner.java +++ b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/DefaultServiceBusQueueProvisioner.java @@ -1,12 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.spring.cloud.autoconfigure.servicebus.resourcemanager; +package com.azure.spring.servicebus.resourcemanager; import com.azure.resourcemanager.AzureResourceManager; import com.azure.spring.cloud.resourcemanager.implementation.crud.ServiceBusQueueCrud; import com.azure.spring.core.properties.resource.AzureResourceMetadata; -import com.azure.spring.servicebus.core.ServiceBusQueueProvisioner; import reactor.util.function.Tuples; /** diff --git a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/resourcemanager/DefaultServiceBusTopicProvisioner.java b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/DefaultServiceBusTopicProvisioner.java similarity index 91% rename from sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/resourcemanager/DefaultServiceBusTopicProvisioner.java rename to sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/DefaultServiceBusTopicProvisioner.java index dce1e972209c0..1e148a6def213 100644 --- a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/resourcemanager/DefaultServiceBusTopicProvisioner.java +++ b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/DefaultServiceBusTopicProvisioner.java @@ -1,13 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.spring.cloud.autoconfigure.servicebus.resourcemanager; +package com.azure.spring.servicebus.resourcemanager; import com.azure.resourcemanager.AzureResourceManager; import com.azure.spring.cloud.resourcemanager.implementation.crud.ServiceBusTopicCrud; import com.azure.spring.cloud.resourcemanager.implementation.crud.ServiceBusTopicSubscriptionCrud; import com.azure.spring.core.properties.resource.AzureResourceMetadata; -import com.azure.spring.servicebus.core.ServiceBusTopicProvisioner; import reactor.util.function.Tuples; /** diff --git a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/ServiceBusQueueProvisioner.java b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/ServiceBusQueueProvisioner.java similarity index 83% rename from sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/ServiceBusQueueProvisioner.java rename to sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/ServiceBusQueueProvisioner.java index 50ffc6c9606d4..ff45f6d0eceee 100644 --- a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/ServiceBusQueueProvisioner.java +++ b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/ServiceBusQueueProvisioner.java @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.spring.servicebus.core; +package com.azure.spring.servicebus.resourcemanager; /** * An interface to provision Service Bus queue resources. diff --git a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/ServiceBusTopicProvisioner.java b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/ServiceBusTopicProvisioner.java similarity index 87% rename from sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/ServiceBusTopicProvisioner.java rename to sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/ServiceBusTopicProvisioner.java index 594acb250a6c5..4fe09481b63c1 100644 --- a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/ServiceBusTopicProvisioner.java +++ b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/ServiceBusTopicProvisioner.java @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.spring.servicebus.core; +package com.azure.spring.servicebus.resourcemanager; /** * An interface to provision Service Bus topic resources. diff --git a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/package-info.java b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/package-info.java new file mode 100644 index 0000000000000..f22df8d9397e4 --- /dev/null +++ b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/package-info.java @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +/** + * Package com.azure.spring.servicebus.resourcemanager + */ +package com.azure.spring.servicebus.resourcemanager; diff --git a/sdk/spring/spring-cloud-azure-stream-binder-servicebus-queue/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/config/ServiceBusQueueBinderConfiguration.java b/sdk/spring/spring-cloud-azure-stream-binder-servicebus-queue/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/config/ServiceBusQueueBinderConfiguration.java index e54414fb69fbb..1272fb1b785e3 100644 --- a/sdk/spring/spring-cloud-azure-stream-binder-servicebus-queue/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/config/ServiceBusQueueBinderConfiguration.java +++ b/sdk/spring/spring-cloud-azure-stream-binder-servicebus-queue/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/config/ServiceBusQueueBinderConfiguration.java @@ -13,7 +13,7 @@ import com.azure.spring.cloud.stream.binder.servicebus.provisioning.ServiceBusQueueChannelResourceManagerProvisioner; import com.azure.spring.cloud.stream.binder.servicebus.ServiceBusQueueMessageChannelBinder; import com.azure.spring.cloud.autoconfigure.servicebus.AzureServiceBusQueueOperationAutoConfiguration; -import com.azure.spring.servicebus.core.ServiceBusQueueProvisioner; +import com.azure.spring.servicebus.resourcemanager.ServiceBusQueueProvisioner; import com.azure.spring.servicebus.core.queue.ServiceBusQueueOperation; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; diff --git a/sdk/spring/spring-cloud-azure-stream-binder-servicebus-queue/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/provisioning/ServiceBusQueueChannelResourceManagerProvisioner.java b/sdk/spring/spring-cloud-azure-stream-binder-servicebus-queue/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/provisioning/ServiceBusQueueChannelResourceManagerProvisioner.java index 3131468d543b5..0cc84e8ff529d 100644 --- a/sdk/spring/spring-cloud-azure-stream-binder-servicebus-queue/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/provisioning/ServiceBusQueueChannelResourceManagerProvisioner.java +++ b/sdk/spring/spring-cloud-azure-stream-binder-servicebus-queue/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/provisioning/ServiceBusQueueChannelResourceManagerProvisioner.java @@ -3,7 +3,7 @@ package com.azure.spring.cloud.stream.binder.servicebus.provisioning; -import com.azure.spring.servicebus.core.ServiceBusQueueProvisioner; +import com.azure.spring.servicebus.resourcemanager.ServiceBusQueueProvisioner; import org.springframework.lang.NonNull; import org.springframework.util.Assert; diff --git a/sdk/spring/spring-cloud-azure-stream-binder-servicebus-topic/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/config/ServiceBusTopicBinderConfiguration.java b/sdk/spring/spring-cloud-azure-stream-binder-servicebus-topic/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/config/ServiceBusTopicBinderConfiguration.java index e7f1ff5aad856..121253f9703bb 100644 --- a/sdk/spring/spring-cloud-azure-stream-binder-servicebus-topic/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/config/ServiceBusTopicBinderConfiguration.java +++ b/sdk/spring/spring-cloud-azure-stream-binder-servicebus-topic/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/config/ServiceBusTopicBinderConfiguration.java @@ -11,7 +11,7 @@ import com.azure.spring.cloud.stream.binder.servicebus.properties.ServiceBusTopicExtendedBindingProperties; import com.azure.spring.cloud.stream.binder.servicebus.provisioning.ServiceBusChannelProvisioner; import com.azure.spring.cloud.stream.binder.servicebus.provisioning.ServiceBusTopicChannelResourceManagerProvisioner; -import com.azure.spring.servicebus.core.ServiceBusTopicProvisioner; +import com.azure.spring.servicebus.resourcemanager.ServiceBusTopicProvisioner; import com.azure.spring.servicebus.core.topic.ServiceBusTopicOperation; import com.azure.spring.cloud.stream.binder.servicebus.ServiceBusTopicMessageChannelBinder; import com.azure.spring.cloud.autoconfigure.servicebus.AzureServiceBusTopicOperationAutoConfiguration; diff --git a/sdk/spring/spring-cloud-azure-stream-binder-servicebus-topic/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/provisioning/ServiceBusTopicChannelResourceManagerProvisioner.java b/sdk/spring/spring-cloud-azure-stream-binder-servicebus-topic/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/provisioning/ServiceBusTopicChannelResourceManagerProvisioner.java index 523eef486cb68..1303f1cbc242d 100644 --- a/sdk/spring/spring-cloud-azure-stream-binder-servicebus-topic/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/provisioning/ServiceBusTopicChannelResourceManagerProvisioner.java +++ b/sdk/spring/spring-cloud-azure-stream-binder-servicebus-topic/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/provisioning/ServiceBusTopicChannelResourceManagerProvisioner.java @@ -3,7 +3,7 @@ package com.azure.spring.cloud.stream.binder.servicebus.provisioning; -import com.azure.spring.servicebus.core.ServiceBusTopicProvisioner; +import com.azure.spring.servicebus.resourcemanager.ServiceBusTopicProvisioner; import org.springframework.lang.NonNull; import org.springframework.util.Assert; From fc6499e499e2fb6a30e093acf2b0eb33e1cef178 Mon Sep 17 00:00:00 2001 From: yiliu6 Date: Mon, 27 Sep 2021 10:57:55 +0800 Subject: [PATCH 6/7] rename package path --- .../AzureEventHubResourceManagerAutoConfiguration.java | 4 ++-- .../AzureServiceBusResourceManagerAutoConfiguration.java | 8 ++++---- .../AzureServiceBusQueueOperationAutoConfiguration.java | 2 +- .../AzureServiceBusTopicOperationAutoConfiguration.java | 2 +- .../DefaultEventHubProvisioner.java | 2 +- .../EventHubProvisioner.java | 2 +- .../azure/spring/eventhubs/provisioning/package-info.java | 7 +++++++ .../spring/eventhubs/resourcemanager/package-info.java | 7 ------- .../servicebus/core/AbstractServiceBusSenderFactory.java | 4 ++-- .../DefaultServiceBusQueueProvisioner.java | 2 +- .../DefaultServiceBusTopicProvisioner.java | 2 +- .../ServiceBusQueueProvisioner.java | 2 +- .../ServiceBusTopicProvisioner.java | 2 +- .../spring/servicebus/provisioning/package-info.java | 7 +++++++ .../spring/servicebus/resourcemanager/package-info.java | 7 ------- .../config/ServiceBusQueueBinderConfiguration.java | 2 +- .../ServiceBusQueueChannelResourceManagerProvisioner.java | 2 +- .../config/ServiceBusTopicBinderConfiguration.java | 2 +- .../ServiceBusTopicChannelResourceManagerProvisioner.java | 2 +- 19 files changed, 34 insertions(+), 34 deletions(-) rename sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/{resourcemanager => provisioning}/DefaultEventHubProvisioner.java (97%) rename sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/{resourcemanager => provisioning}/EventHubProvisioner.java (88%) create mode 100644 sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/provisioning/package-info.java delete mode 100644 sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/resourcemanager/package-info.java rename sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/{resourcemanager => provisioning}/DefaultServiceBusQueueProvisioner.java (95%) rename sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/{resourcemanager => provisioning}/DefaultServiceBusTopicProvisioner.java (96%) rename sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/{resourcemanager => provisioning}/ServiceBusQueueProvisioner.java (83%) rename sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/{resourcemanager => provisioning}/ServiceBusTopicProvisioner.java (87%) create mode 100644 sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/package-info.java delete mode 100644 sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/package-info.java diff --git a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/resourcemanager/AzureEventHubResourceManagerAutoConfiguration.java b/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/resourcemanager/AzureEventHubResourceManagerAutoConfiguration.java index 344d59039875e..ea326e1bf8488 100644 --- a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/resourcemanager/AzureEventHubResourceManagerAutoConfiguration.java +++ b/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/resourcemanager/AzureEventHubResourceManagerAutoConfiguration.java @@ -5,9 +5,9 @@ import com.azure.resourcemanager.AzureResourceManager; import com.azure.spring.cloud.autoconfigure.eventhub.AzureEventHubProperties; -import com.azure.spring.eventhubs.resourcemanager.DefaultEventHubProvisioner; +import com.azure.spring.eventhubs.provisioning.DefaultEventHubProvisioner; import com.azure.spring.cloud.resourcemanager.connectionstring.EventHubArmConnectionStringProvider; -import com.azure.spring.eventhubs.resourcemanager.EventHubProvisioner; +import com.azure.spring.eventhubs.provisioning.EventHubProvisioner; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; diff --git a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/resourcemanager/AzureServiceBusResourceManagerAutoConfiguration.java b/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/resourcemanager/AzureServiceBusResourceManagerAutoConfiguration.java index 02b083666350d..3568cecfea7ba 100644 --- a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/resourcemanager/AzureServiceBusResourceManagerAutoConfiguration.java +++ b/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/resourcemanager/AzureServiceBusResourceManagerAutoConfiguration.java @@ -5,11 +5,11 @@ import com.azure.resourcemanager.AzureResourceManager; import com.azure.spring.cloud.autoconfigure.servicebus.AzureServiceBusProperties; -import com.azure.spring.servicebus.resourcemanager.DefaultServiceBusQueueProvisioner; -import com.azure.spring.servicebus.resourcemanager.DefaultServiceBusTopicProvisioner; +import com.azure.spring.servicebus.provisioning.DefaultServiceBusQueueProvisioner; +import com.azure.spring.servicebus.provisioning.DefaultServiceBusTopicProvisioner; import com.azure.spring.cloud.resourcemanager.connectionstring.ServiceBusArmConnectionStringProvider; -import com.azure.spring.servicebus.resourcemanager.ServiceBusQueueProvisioner; -import com.azure.spring.servicebus.resourcemanager.ServiceBusTopicProvisioner; +import com.azure.spring.servicebus.provisioning.ServiceBusQueueProvisioner; +import com.azure.spring.servicebus.provisioning.ServiceBusTopicProvisioner; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; diff --git a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusQueueOperationAutoConfiguration.java b/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusQueueOperationAutoConfiguration.java index f59a5f3b05c60..f5dce82d22783 100644 --- a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusQueueOperationAutoConfiguration.java +++ b/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusQueueOperationAutoConfiguration.java @@ -6,7 +6,7 @@ import com.azure.messaging.servicebus.ServiceBusClientBuilder; import com.azure.spring.servicebus.core.DefaultServiceBusQueueClientFactory; import com.azure.spring.servicebus.core.ServiceBusQueueClientFactory; -import com.azure.spring.servicebus.resourcemanager.ServiceBusQueueProvisioner; +import com.azure.spring.servicebus.provisioning.ServiceBusQueueProvisioner; import com.azure.spring.servicebus.core.queue.ServiceBusQueueOperation; import com.azure.spring.servicebus.core.queue.ServiceBusQueueTemplate; import com.azure.spring.servicebus.support.converter.ServiceBusMessageConverter; diff --git a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusTopicOperationAutoConfiguration.java b/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusTopicOperationAutoConfiguration.java index 9d4da1ed2a842..dc5804d954062 100644 --- a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusTopicOperationAutoConfiguration.java +++ b/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/servicebus/AzureServiceBusTopicOperationAutoConfiguration.java @@ -6,7 +6,7 @@ import com.azure.messaging.servicebus.ServiceBusClientBuilder; import com.azure.spring.servicebus.core.DefaultServiceBusTopicClientFactory; import com.azure.spring.servicebus.core.ServiceBusTopicClientFactory; -import com.azure.spring.servicebus.resourcemanager.ServiceBusTopicProvisioner; +import com.azure.spring.servicebus.provisioning.ServiceBusTopicProvisioner; import com.azure.spring.servicebus.core.topic.ServiceBusTopicOperation; import com.azure.spring.servicebus.core.topic.ServiceBusTopicTemplate; import com.azure.spring.servicebus.support.converter.ServiceBusMessageConverter; diff --git a/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/resourcemanager/DefaultEventHubProvisioner.java b/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/provisioning/DefaultEventHubProvisioner.java similarity index 97% rename from sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/resourcemanager/DefaultEventHubProvisioner.java rename to sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/provisioning/DefaultEventHubProvisioner.java index cfad15cb45e07..03e4697dfeede 100644 --- a/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/resourcemanager/DefaultEventHubProvisioner.java +++ b/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/provisioning/DefaultEventHubProvisioner.java @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.spring.eventhubs.resourcemanager; +package com.azure.spring.eventhubs.provisioning; import com.azure.resourcemanager.AzureResourceManager; import com.azure.spring.cloud.resourcemanager.implementation.crud.EventHubConsumerGroupCrud; diff --git a/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/resourcemanager/EventHubProvisioner.java b/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/provisioning/EventHubProvisioner.java similarity index 88% rename from sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/resourcemanager/EventHubProvisioner.java rename to sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/provisioning/EventHubProvisioner.java index 0a1fff7e72a90..d4b5446ef3023 100644 --- a/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/resourcemanager/EventHubProvisioner.java +++ b/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/provisioning/EventHubProvisioner.java @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.spring.eventhubs.resourcemanager; +package com.azure.spring.eventhubs.provisioning; /** * An interface to provision Event Hubs resources. diff --git a/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/provisioning/package-info.java b/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/provisioning/package-info.java new file mode 100644 index 0000000000000..b064c59bf201c --- /dev/null +++ b/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/provisioning/package-info.java @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +/** + * Package com.azure.spring.eventhubs.provisioning + */ +package com.azure.spring.eventhubs.provisioning; diff --git a/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/resourcemanager/package-info.java b/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/resourcemanager/package-info.java deleted file mode 100644 index 92b7032ef708d..0000000000000 --- a/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/resourcemanager/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -/** - * Package com.azure.spring.eventhubs.resourcemanager - */ -package com.azure.spring.eventhubs.resourcemanager; diff --git a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/AbstractServiceBusSenderFactory.java b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/AbstractServiceBusSenderFactory.java index b4d8223396b0b..b9f6eeb93d3ac 100644 --- a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/AbstractServiceBusSenderFactory.java +++ b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/core/AbstractServiceBusSenderFactory.java @@ -4,8 +4,8 @@ package com.azure.spring.servicebus.core; import com.azure.messaging.servicebus.ServiceBusClientBuilder; -import com.azure.spring.servicebus.resourcemanager.ServiceBusQueueProvisioner; -import com.azure.spring.servicebus.resourcemanager.ServiceBusTopicProvisioner; +import com.azure.spring.servicebus.provisioning.ServiceBusQueueProvisioner; +import com.azure.spring.servicebus.provisioning.ServiceBusTopicProvisioner; import javax.annotation.Nullable; diff --git a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/DefaultServiceBusQueueProvisioner.java b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/DefaultServiceBusQueueProvisioner.java similarity index 95% rename from sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/DefaultServiceBusQueueProvisioner.java rename to sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/DefaultServiceBusQueueProvisioner.java index 025d34722ba78..ba868704c71e2 100644 --- a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/DefaultServiceBusQueueProvisioner.java +++ b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/DefaultServiceBusQueueProvisioner.java @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.spring.servicebus.resourcemanager; +package com.azure.spring.servicebus.provisioning; import com.azure.resourcemanager.AzureResourceManager; import com.azure.spring.cloud.resourcemanager.implementation.crud.ServiceBusQueueCrud; diff --git a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/DefaultServiceBusTopicProvisioner.java b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/DefaultServiceBusTopicProvisioner.java similarity index 96% rename from sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/DefaultServiceBusTopicProvisioner.java rename to sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/DefaultServiceBusTopicProvisioner.java index 1e148a6def213..857e7fd991bdf 100644 --- a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/DefaultServiceBusTopicProvisioner.java +++ b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/DefaultServiceBusTopicProvisioner.java @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.spring.servicebus.resourcemanager; +package com.azure.spring.servicebus.provisioning; import com.azure.resourcemanager.AzureResourceManager; import com.azure.spring.cloud.resourcemanager.implementation.crud.ServiceBusTopicCrud; diff --git a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/ServiceBusQueueProvisioner.java b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/ServiceBusQueueProvisioner.java similarity index 83% rename from sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/ServiceBusQueueProvisioner.java rename to sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/ServiceBusQueueProvisioner.java index ff45f6d0eceee..0acdfe989f3e6 100644 --- a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/ServiceBusQueueProvisioner.java +++ b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/ServiceBusQueueProvisioner.java @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.spring.servicebus.resourcemanager; +package com.azure.spring.servicebus.provisioning; /** * An interface to provision Service Bus queue resources. diff --git a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/ServiceBusTopicProvisioner.java b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/ServiceBusTopicProvisioner.java similarity index 87% rename from sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/ServiceBusTopicProvisioner.java rename to sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/ServiceBusTopicProvisioner.java index 4fe09481b63c1..f88112fa54fa6 100644 --- a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/ServiceBusTopicProvisioner.java +++ b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/ServiceBusTopicProvisioner.java @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.spring.servicebus.resourcemanager; +package com.azure.spring.servicebus.provisioning; /** * An interface to provision Service Bus topic resources. diff --git a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/package-info.java b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/package-info.java new file mode 100644 index 0000000000000..0c9022fc3245a --- /dev/null +++ b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/package-info.java @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +/** + * Package com.azure.spring.servicebus.provisioning + */ +package com.azure.spring.servicebus.provisioning; diff --git a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/package-info.java b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/package-info.java deleted file mode 100644 index f22df8d9397e4..0000000000000 --- a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/resourcemanager/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -/** - * Package com.azure.spring.servicebus.resourcemanager - */ -package com.azure.spring.servicebus.resourcemanager; diff --git a/sdk/spring/spring-cloud-azure-stream-binder-servicebus-queue/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/config/ServiceBusQueueBinderConfiguration.java b/sdk/spring/spring-cloud-azure-stream-binder-servicebus-queue/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/config/ServiceBusQueueBinderConfiguration.java index 1272fb1b785e3..78570eedaea75 100644 --- a/sdk/spring/spring-cloud-azure-stream-binder-servicebus-queue/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/config/ServiceBusQueueBinderConfiguration.java +++ b/sdk/spring/spring-cloud-azure-stream-binder-servicebus-queue/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/config/ServiceBusQueueBinderConfiguration.java @@ -13,7 +13,7 @@ import com.azure.spring.cloud.stream.binder.servicebus.provisioning.ServiceBusQueueChannelResourceManagerProvisioner; import com.azure.spring.cloud.stream.binder.servicebus.ServiceBusQueueMessageChannelBinder; import com.azure.spring.cloud.autoconfigure.servicebus.AzureServiceBusQueueOperationAutoConfiguration; -import com.azure.spring.servicebus.resourcemanager.ServiceBusQueueProvisioner; +import com.azure.spring.servicebus.provisioning.ServiceBusQueueProvisioner; import com.azure.spring.servicebus.core.queue.ServiceBusQueueOperation; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; diff --git a/sdk/spring/spring-cloud-azure-stream-binder-servicebus-queue/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/provisioning/ServiceBusQueueChannelResourceManagerProvisioner.java b/sdk/spring/spring-cloud-azure-stream-binder-servicebus-queue/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/provisioning/ServiceBusQueueChannelResourceManagerProvisioner.java index 0cc84e8ff529d..26c9c24b805e8 100644 --- a/sdk/spring/spring-cloud-azure-stream-binder-servicebus-queue/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/provisioning/ServiceBusQueueChannelResourceManagerProvisioner.java +++ b/sdk/spring/spring-cloud-azure-stream-binder-servicebus-queue/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/provisioning/ServiceBusQueueChannelResourceManagerProvisioner.java @@ -3,7 +3,7 @@ package com.azure.spring.cloud.stream.binder.servicebus.provisioning; -import com.azure.spring.servicebus.resourcemanager.ServiceBusQueueProvisioner; +import com.azure.spring.servicebus.provisioning.ServiceBusQueueProvisioner; import org.springframework.lang.NonNull; import org.springframework.util.Assert; diff --git a/sdk/spring/spring-cloud-azure-stream-binder-servicebus-topic/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/config/ServiceBusTopicBinderConfiguration.java b/sdk/spring/spring-cloud-azure-stream-binder-servicebus-topic/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/config/ServiceBusTopicBinderConfiguration.java index 121253f9703bb..004c3849df443 100644 --- a/sdk/spring/spring-cloud-azure-stream-binder-servicebus-topic/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/config/ServiceBusTopicBinderConfiguration.java +++ b/sdk/spring/spring-cloud-azure-stream-binder-servicebus-topic/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/config/ServiceBusTopicBinderConfiguration.java @@ -11,7 +11,7 @@ import com.azure.spring.cloud.stream.binder.servicebus.properties.ServiceBusTopicExtendedBindingProperties; import com.azure.spring.cloud.stream.binder.servicebus.provisioning.ServiceBusChannelProvisioner; import com.azure.spring.cloud.stream.binder.servicebus.provisioning.ServiceBusTopicChannelResourceManagerProvisioner; -import com.azure.spring.servicebus.resourcemanager.ServiceBusTopicProvisioner; +import com.azure.spring.servicebus.provisioning.ServiceBusTopicProvisioner; import com.azure.spring.servicebus.core.topic.ServiceBusTopicOperation; import com.azure.spring.cloud.stream.binder.servicebus.ServiceBusTopicMessageChannelBinder; import com.azure.spring.cloud.autoconfigure.servicebus.AzureServiceBusTopicOperationAutoConfiguration; diff --git a/sdk/spring/spring-cloud-azure-stream-binder-servicebus-topic/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/provisioning/ServiceBusTopicChannelResourceManagerProvisioner.java b/sdk/spring/spring-cloud-azure-stream-binder-servicebus-topic/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/provisioning/ServiceBusTopicChannelResourceManagerProvisioner.java index 1303f1cbc242d..82a73d911d409 100644 --- a/sdk/spring/spring-cloud-azure-stream-binder-servicebus-topic/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/provisioning/ServiceBusTopicChannelResourceManagerProvisioner.java +++ b/sdk/spring/spring-cloud-azure-stream-binder-servicebus-topic/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/provisioning/ServiceBusTopicChannelResourceManagerProvisioner.java @@ -3,7 +3,7 @@ package com.azure.spring.cloud.stream.binder.servicebus.provisioning; -import com.azure.spring.servicebus.resourcemanager.ServiceBusTopicProvisioner; +import com.azure.spring.servicebus.provisioning.ServiceBusTopicProvisioner; import org.springframework.lang.NonNull; import org.springframework.util.Assert; From a277b81c6c67d93d7fc3cd05bd867cb08b542815 Mon Sep 17 00:00:00 2001 From: yiliu6 Date: Mon, 27 Sep 2021 13:07:35 +0800 Subject: [PATCH 7/7] move default provisioner to arm package --- .../AzureEventHubResourceManagerAutoConfiguration.java | 2 +- .../AzureServiceBusResourceManagerAutoConfiguration.java | 4 ++-- .../provisioning/{ => arm}/DefaultEventHubProvisioner.java | 3 ++- .../spring/eventhubs/provisioning/arm/package-info.java | 7 +++++++ .../{ => arm}/DefaultServiceBusQueueProvisioner.java | 3 ++- .../{ => arm}/DefaultServiceBusTopicProvisioner.java | 3 ++- .../spring/servicebus/provisioning/arm/package-info.java | 7 +++++++ 7 files changed, 23 insertions(+), 6 deletions(-) rename sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/provisioning/{ => arm}/DefaultEventHubProvisioner.java (93%) create mode 100644 sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/provisioning/arm/package-info.java rename sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/{ => arm}/DefaultServiceBusQueueProvisioner.java (88%) rename sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/{ => arm}/DefaultServiceBusTopicProvisioner.java (91%) create mode 100644 sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/arm/package-info.java diff --git a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/resourcemanager/AzureEventHubResourceManagerAutoConfiguration.java b/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/resourcemanager/AzureEventHubResourceManagerAutoConfiguration.java index ea326e1bf8488..a78acf0265791 100644 --- a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/resourcemanager/AzureEventHubResourceManagerAutoConfiguration.java +++ b/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/resourcemanager/AzureEventHubResourceManagerAutoConfiguration.java @@ -5,7 +5,7 @@ import com.azure.resourcemanager.AzureResourceManager; import com.azure.spring.cloud.autoconfigure.eventhub.AzureEventHubProperties; -import com.azure.spring.eventhubs.provisioning.DefaultEventHubProvisioner; +import com.azure.spring.eventhubs.provisioning.arm.DefaultEventHubProvisioner; import com.azure.spring.cloud.resourcemanager.connectionstring.EventHubArmConnectionStringProvider; import com.azure.spring.eventhubs.provisioning.EventHubProvisioner; import org.springframework.boot.autoconfigure.AutoConfigureAfter; diff --git a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/resourcemanager/AzureServiceBusResourceManagerAutoConfiguration.java b/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/resourcemanager/AzureServiceBusResourceManagerAutoConfiguration.java index 3568cecfea7ba..c6273bc99cda9 100644 --- a/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/resourcemanager/AzureServiceBusResourceManagerAutoConfiguration.java +++ b/sdk/spring/azure-spring-cloud-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/resourcemanager/AzureServiceBusResourceManagerAutoConfiguration.java @@ -5,8 +5,8 @@ import com.azure.resourcemanager.AzureResourceManager; import com.azure.spring.cloud.autoconfigure.servicebus.AzureServiceBusProperties; -import com.azure.spring.servicebus.provisioning.DefaultServiceBusQueueProvisioner; -import com.azure.spring.servicebus.provisioning.DefaultServiceBusTopicProvisioner; +import com.azure.spring.servicebus.provisioning.arm.DefaultServiceBusQueueProvisioner; +import com.azure.spring.servicebus.provisioning.arm.DefaultServiceBusTopicProvisioner; import com.azure.spring.cloud.resourcemanager.connectionstring.ServiceBusArmConnectionStringProvider; import com.azure.spring.servicebus.provisioning.ServiceBusQueueProvisioner; import com.azure.spring.servicebus.provisioning.ServiceBusTopicProvisioner; diff --git a/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/provisioning/DefaultEventHubProvisioner.java b/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/provisioning/arm/DefaultEventHubProvisioner.java similarity index 93% rename from sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/provisioning/DefaultEventHubProvisioner.java rename to sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/provisioning/arm/DefaultEventHubProvisioner.java index 03e4697dfeede..1b3fd91e4695f 100644 --- a/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/provisioning/DefaultEventHubProvisioner.java +++ b/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/provisioning/arm/DefaultEventHubProvisioner.java @@ -1,13 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.spring.eventhubs.provisioning; +package com.azure.spring.eventhubs.provisioning.arm; import com.azure.resourcemanager.AzureResourceManager; import com.azure.spring.cloud.resourcemanager.implementation.crud.EventHubConsumerGroupCrud; import com.azure.spring.cloud.resourcemanager.implementation.crud.EventHubCrud; import com.azure.spring.cloud.resourcemanager.implementation.crud.EventHubNamespaceCrud; import com.azure.spring.core.properties.resource.AzureResourceMetadata; +import com.azure.spring.eventhubs.provisioning.EventHubProvisioner; import reactor.util.function.Tuples; /** diff --git a/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/provisioning/arm/package-info.java b/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/provisioning/arm/package-info.java new file mode 100644 index 0000000000000..594031dba20f3 --- /dev/null +++ b/sdk/spring/azure-spring-eventhubs/src/main/java/com/azure/spring/eventhubs/provisioning/arm/package-info.java @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +/** + * Package com.azure.spring.eventhubs.provisioning.arm + */ +package com.azure.spring.eventhubs.provisioning.arm; diff --git a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/DefaultServiceBusQueueProvisioner.java b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/arm/DefaultServiceBusQueueProvisioner.java similarity index 88% rename from sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/DefaultServiceBusQueueProvisioner.java rename to sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/arm/DefaultServiceBusQueueProvisioner.java index ba868704c71e2..ed85948450b1a 100644 --- a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/DefaultServiceBusQueueProvisioner.java +++ b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/arm/DefaultServiceBusQueueProvisioner.java @@ -1,11 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.spring.servicebus.provisioning; +package com.azure.spring.servicebus.provisioning.arm; import com.azure.resourcemanager.AzureResourceManager; import com.azure.spring.cloud.resourcemanager.implementation.crud.ServiceBusQueueCrud; import com.azure.spring.core.properties.resource.AzureResourceMetadata; +import com.azure.spring.servicebus.provisioning.ServiceBusQueueProvisioner; import reactor.util.function.Tuples; /** diff --git a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/DefaultServiceBusTopicProvisioner.java b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/arm/DefaultServiceBusTopicProvisioner.java similarity index 91% rename from sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/DefaultServiceBusTopicProvisioner.java rename to sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/arm/DefaultServiceBusTopicProvisioner.java index 857e7fd991bdf..889204eb050c0 100644 --- a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/DefaultServiceBusTopicProvisioner.java +++ b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/arm/DefaultServiceBusTopicProvisioner.java @@ -1,12 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.spring.servicebus.provisioning; +package com.azure.spring.servicebus.provisioning.arm; import com.azure.resourcemanager.AzureResourceManager; import com.azure.spring.cloud.resourcemanager.implementation.crud.ServiceBusTopicCrud; import com.azure.spring.cloud.resourcemanager.implementation.crud.ServiceBusTopicSubscriptionCrud; import com.azure.spring.core.properties.resource.AzureResourceMetadata; +import com.azure.spring.servicebus.provisioning.ServiceBusTopicProvisioner; import reactor.util.function.Tuples; /** diff --git a/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/arm/package-info.java b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/arm/package-info.java new file mode 100644 index 0000000000000..d8f0eec876292 --- /dev/null +++ b/sdk/spring/azure-spring-servicebus/src/main/java/com/azure/spring/servicebus/provisioning/arm/package-info.java @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +/** + * Package com.azure.spring.servicebus.provisioning.arm + */ +package com.azure.spring.servicebus.provisioning.arm;