Skip to content

Commit

Permalink
CAMEL-20266: Use high-level Azure Service Bus client (apache#13862)
Browse files Browse the repository at this point in the history
* CAMEL-20266: Use high-level Azure Service Bus client

* Add default value to `maxConcurrentCalls` metadata

* Commit missing generated sources

* Rewrite integration test for ServiceBusConsumer

* Rewrite integration test for ServiceBusProducer

* Correct typos

* Refactor `ServiceBusSenderOperationsTest` and framework

* Remove redundant tests and framework

* Implement unit test for `ServiceBusConsumer`

* Fix formatting

* Tweak `ServiceBusConsumerTest` verifications

* Improve `ServiceBusConsumerTest` assertions

* Document configuration changes in migration guide
  • Loading branch information
dylanpiergies authored and 4nt01ne committed May 14, 2024
1 parent 21fa3e6 commit b8edb20
Show file tree
Hide file tree
Showing 28 changed files with 1,400 additions and 1,561 deletions.

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions components/camel-azure/camel-azure-servicebus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@
<artifactId>camel-test-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand All @@ -84,5 +90,12 @@
<version>${awaitility-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-infra-core</artifactId>
<version>${project.version}</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,8 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj
case "configuration": target.setConfiguration(property(camelContext, org.apache.camel.component.azure.servicebus.ServiceBusConfiguration.class, value)); return true;
case "connectionstring":
case "connectionString": getOrCreateConfiguration(target).setConnectionString(property(camelContext, java.lang.String.class, value)); return true;
case "consumeroperation":
case "consumerOperation": getOrCreateConfiguration(target).setConsumerOperation(property(camelContext, org.apache.camel.component.azure.servicebus.ServiceBusConsumerOperationDefinition.class, value)); return true;
case "credentialtype":
case "credentialType": getOrCreateConfiguration(target).setCredentialType(property(camelContext, org.apache.camel.component.azure.servicebus.CredentialType.class, value)); return true;
case "disableautocomplete":
case "disableAutoComplete": getOrCreateConfiguration(target).setDisableAutoComplete(property(camelContext, boolean.class, value)); return true;
case "enabledeadlettering":
case "enableDeadLettering": getOrCreateConfiguration(target).setEnableDeadLettering(property(camelContext, boolean.class, value)); return true;
case "fullyqualifiednamespace":
Expand All @@ -60,18 +56,16 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj
case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true;
case "maxautolockrenewduration":
case "maxAutoLockRenewDuration": getOrCreateConfiguration(target).setMaxAutoLockRenewDuration(property(camelContext, java.time.Duration.class, value)); return true;
case "peeknummaxmessages":
case "peekNumMaxMessages": getOrCreateConfiguration(target).setPeekNumMaxMessages(property(camelContext, java.lang.Integer.class, value)); return true;
case "maxconcurrentcalls":
case "maxConcurrentCalls": getOrCreateConfiguration(target).setMaxConcurrentCalls(property(camelContext, int.class, value)); return true;
case "prefetchcount":
case "prefetchCount": getOrCreateConfiguration(target).setPrefetchCount(property(camelContext, int.class, value)); return true;
case "processorclient":
case "processorClient": getOrCreateConfiguration(target).setProcessorClient(property(camelContext, com.azure.messaging.servicebus.ServiceBusProcessorClient.class, value)); return true;
case "produceroperation":
case "producerOperation": getOrCreateConfiguration(target).setProducerOperation(property(camelContext, org.apache.camel.component.azure.servicebus.ServiceBusProducerOperationDefinition.class, value)); return true;
case "proxyoptions":
case "proxyOptions": getOrCreateConfiguration(target).setProxyOptions(property(camelContext, com.azure.core.amqp.ProxyOptions.class, value)); return true;
case "receiverasyncclient":
case "receiverAsyncClient": getOrCreateConfiguration(target).setReceiverAsyncClient(property(camelContext, com.azure.messaging.servicebus.ServiceBusReceiverAsyncClient.class, value)); return true;
case "reconnectdelay":
case "reconnectDelay": getOrCreateConfiguration(target).setReconnectDelay(property(camelContext, int.class, value)); return true;
case "scheduledenqueuetime":
case "scheduledEnqueueTime": getOrCreateConfiguration(target).setScheduledEnqueueTime(property(camelContext, java.time.OffsetDateTime.class, value)); return true;
case "senderasyncclient":
Expand All @@ -94,7 +88,7 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj

@Override
public String[] getAutowiredNames() {
return new String[]{"receiverAsyncClient", "senderAsyncClient"};
return new String[]{"processorClient", "senderAsyncClient"};
}

@Override
Expand All @@ -114,12 +108,8 @@ public Class<?> getOptionType(String name, boolean ignoreCase) {
case "configuration": return org.apache.camel.component.azure.servicebus.ServiceBusConfiguration.class;
case "connectionstring":
case "connectionString": return java.lang.String.class;
case "consumeroperation":
case "consumerOperation": return org.apache.camel.component.azure.servicebus.ServiceBusConsumerOperationDefinition.class;
case "credentialtype":
case "credentialType": return org.apache.camel.component.azure.servicebus.CredentialType.class;
case "disableautocomplete":
case "disableAutoComplete": return boolean.class;
case "enabledeadlettering":
case "enableDeadLettering": return boolean.class;
case "fullyqualifiednamespace":
Expand All @@ -130,18 +120,16 @@ public Class<?> getOptionType(String name, boolean ignoreCase) {
case "lazyStartProducer": return boolean.class;
case "maxautolockrenewduration":
case "maxAutoLockRenewDuration": return java.time.Duration.class;
case "peeknummaxmessages":
case "peekNumMaxMessages": return java.lang.Integer.class;
case "maxconcurrentcalls":
case "maxConcurrentCalls": return int.class;
case "prefetchcount":
case "prefetchCount": return int.class;
case "processorclient":
case "processorClient": return com.azure.messaging.servicebus.ServiceBusProcessorClient.class;
case "produceroperation":
case "producerOperation": return org.apache.camel.component.azure.servicebus.ServiceBusProducerOperationDefinition.class;
case "proxyoptions":
case "proxyOptions": return com.azure.core.amqp.ProxyOptions.class;
case "receiverasyncclient":
case "receiverAsyncClient": return com.azure.messaging.servicebus.ServiceBusReceiverAsyncClient.class;
case "reconnectdelay":
case "reconnectDelay": return int.class;
case "scheduledenqueuetime":
case "scheduledEnqueueTime": return java.time.OffsetDateTime.class;
case "senderasyncclient":
Expand Down Expand Up @@ -180,12 +168,8 @@ public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
case "configuration": return target.getConfiguration();
case "connectionstring":
case "connectionString": return getOrCreateConfiguration(target).getConnectionString();
case "consumeroperation":
case "consumerOperation": return getOrCreateConfiguration(target).getConsumerOperation();
case "credentialtype":
case "credentialType": return getOrCreateConfiguration(target).getCredentialType();
case "disableautocomplete":
case "disableAutoComplete": return getOrCreateConfiguration(target).isDisableAutoComplete();
case "enabledeadlettering":
case "enableDeadLettering": return getOrCreateConfiguration(target).isEnableDeadLettering();
case "fullyqualifiednamespace":
Expand All @@ -196,18 +180,16 @@ public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
case "lazyStartProducer": return target.isLazyStartProducer();
case "maxautolockrenewduration":
case "maxAutoLockRenewDuration": return getOrCreateConfiguration(target).getMaxAutoLockRenewDuration();
case "peeknummaxmessages":
case "peekNumMaxMessages": return getOrCreateConfiguration(target).getPeekNumMaxMessages();
case "maxconcurrentcalls":
case "maxConcurrentCalls": return getOrCreateConfiguration(target).getMaxConcurrentCalls();
case "prefetchcount":
case "prefetchCount": return getOrCreateConfiguration(target).getPrefetchCount();
case "processorclient":
case "processorClient": return getOrCreateConfiguration(target).getProcessorClient();
case "produceroperation":
case "producerOperation": return getOrCreateConfiguration(target).getProducerOperation();
case "proxyoptions":
case "proxyOptions": return getOrCreateConfiguration(target).getProxyOptions();
case "receiverasyncclient":
case "receiverAsyncClient": return getOrCreateConfiguration(target).getReceiverAsyncClient();
case "reconnectdelay":
case "reconnectDelay": return getOrCreateConfiguration(target).getReconnectDelay();
case "scheduledenqueuetime":
case "scheduledEnqueueTime": return getOrCreateConfiguration(target).getScheduledEnqueueTime();
case "senderasyncclient":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,8 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj
case "clientOptions": target.getConfiguration().setClientOptions(property(camelContext, com.azure.core.util.ClientOptions.class, value)); return true;
case "connectionstring":
case "connectionString": target.getConfiguration().setConnectionString(property(camelContext, java.lang.String.class, value)); return true;
case "consumeroperation":
case "consumerOperation": target.getConfiguration().setConsumerOperation(property(camelContext, org.apache.camel.component.azure.servicebus.ServiceBusConsumerOperationDefinition.class, value)); return true;
case "credentialtype":
case "credentialType": target.getConfiguration().setCredentialType(property(camelContext, org.apache.camel.component.azure.servicebus.CredentialType.class, value)); return true;
case "disableautocomplete":
case "disableAutoComplete": target.getConfiguration().setDisableAutoComplete(property(camelContext, boolean.class, value)); return true;
case "enabledeadlettering":
case "enableDeadLettering": target.getConfiguration().setEnableDeadLettering(property(camelContext, boolean.class, value)); return true;
case "exceptionhandler":
Expand All @@ -54,18 +50,16 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj
case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true;
case "maxautolockrenewduration":
case "maxAutoLockRenewDuration": target.getConfiguration().setMaxAutoLockRenewDuration(property(camelContext, java.time.Duration.class, value)); return true;
case "peeknummaxmessages":
case "peekNumMaxMessages": target.getConfiguration().setPeekNumMaxMessages(property(camelContext, java.lang.Integer.class, value)); return true;
case "maxconcurrentcalls":
case "maxConcurrentCalls": target.getConfiguration().setMaxConcurrentCalls(property(camelContext, int.class, value)); return true;
case "prefetchcount":
case "prefetchCount": target.getConfiguration().setPrefetchCount(property(camelContext, int.class, value)); return true;
case "processorclient":
case "processorClient": target.getConfiguration().setProcessorClient(property(camelContext, com.azure.messaging.servicebus.ServiceBusProcessorClient.class, value)); return true;
case "produceroperation":
case "producerOperation": target.getConfiguration().setProducerOperation(property(camelContext, org.apache.camel.component.azure.servicebus.ServiceBusProducerOperationDefinition.class, value)); return true;
case "proxyoptions":
case "proxyOptions": target.getConfiguration().setProxyOptions(property(camelContext, com.azure.core.amqp.ProxyOptions.class, value)); return true;
case "receiverasyncclient":
case "receiverAsyncClient": target.getConfiguration().setReceiverAsyncClient(property(camelContext, com.azure.messaging.servicebus.ServiceBusReceiverAsyncClient.class, value)); return true;
case "reconnectdelay":
case "reconnectDelay": target.getConfiguration().setReconnectDelay(property(camelContext, int.class, value)); return true;
case "scheduledenqueuetime":
case "scheduledEnqueueTime": target.getConfiguration().setScheduledEnqueueTime(property(camelContext, java.time.OffsetDateTime.class, value)); return true;
case "senderasyncclient":
Expand All @@ -88,7 +82,7 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj

@Override
public String[] getAutowiredNames() {
return new String[]{"receiverAsyncClient", "senderAsyncClient"};
return new String[]{"processorClient", "senderAsyncClient"};
}

@Override
Expand All @@ -105,12 +99,8 @@ public Class<?> getOptionType(String name, boolean ignoreCase) {
case "clientOptions": return com.azure.core.util.ClientOptions.class;
case "connectionstring":
case "connectionString": return java.lang.String.class;
case "consumeroperation":
case "consumerOperation": return org.apache.camel.component.azure.servicebus.ServiceBusConsumerOperationDefinition.class;
case "credentialtype":
case "credentialType": return org.apache.camel.component.azure.servicebus.CredentialType.class;
case "disableautocomplete":
case "disableAutoComplete": return boolean.class;
case "enabledeadlettering":
case "enableDeadLettering": return boolean.class;
case "exceptionhandler":
Expand All @@ -125,18 +115,16 @@ public Class<?> getOptionType(String name, boolean ignoreCase) {
case "lazyStartProducer": return boolean.class;
case "maxautolockrenewduration":
case "maxAutoLockRenewDuration": return java.time.Duration.class;
case "peeknummaxmessages":
case "peekNumMaxMessages": return java.lang.Integer.class;
case "maxconcurrentcalls":
case "maxConcurrentCalls": return int.class;
case "prefetchcount":
case "prefetchCount": return int.class;
case "processorclient":
case "processorClient": return com.azure.messaging.servicebus.ServiceBusProcessorClient.class;
case "produceroperation":
case "producerOperation": return org.apache.camel.component.azure.servicebus.ServiceBusProducerOperationDefinition.class;
case "proxyoptions":
case "proxyOptions": return com.azure.core.amqp.ProxyOptions.class;
case "receiverasyncclient":
case "receiverAsyncClient": return com.azure.messaging.servicebus.ServiceBusReceiverAsyncClient.class;
case "reconnectdelay":
case "reconnectDelay": return int.class;
case "scheduledenqueuetime":
case "scheduledEnqueueTime": return java.time.OffsetDateTime.class;
case "senderasyncclient":
Expand Down Expand Up @@ -172,12 +160,8 @@ public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
case "clientOptions": return target.getConfiguration().getClientOptions();
case "connectionstring":
case "connectionString": return target.getConfiguration().getConnectionString();
case "consumeroperation":
case "consumerOperation": return target.getConfiguration().getConsumerOperation();
case "credentialtype":
case "credentialType": return target.getConfiguration().getCredentialType();
case "disableautocomplete":
case "disableAutoComplete": return target.getConfiguration().isDisableAutoComplete();
case "enabledeadlettering":
case "enableDeadLettering": return target.getConfiguration().isEnableDeadLettering();
case "exceptionhandler":
Expand All @@ -192,18 +176,16 @@ public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
case "lazyStartProducer": return target.isLazyStartProducer();
case "maxautolockrenewduration":
case "maxAutoLockRenewDuration": return target.getConfiguration().getMaxAutoLockRenewDuration();
case "peeknummaxmessages":
case "peekNumMaxMessages": return target.getConfiguration().getPeekNumMaxMessages();
case "maxconcurrentcalls":
case "maxConcurrentCalls": return target.getConfiguration().getMaxConcurrentCalls();
case "prefetchcount":
case "prefetchCount": return target.getConfiguration().getPrefetchCount();
case "processorclient":
case "processorClient": return target.getConfiguration().getProcessorClient();
case "produceroperation":
case "producerOperation": return target.getConfiguration().getProducerOperation();
case "proxyoptions":
case "proxyOptions": return target.getConfiguration().getProxyOptions();
case "receiverasyncclient":
case "receiverAsyncClient": return target.getConfiguration().getReceiverAsyncClient();
case "reconnectdelay":
case "reconnectDelay": return target.getConfiguration().getReconnectDelay();
case "scheduledenqueuetime":
case "scheduledEnqueueTime": return target.getConfiguration().getScheduledEnqueueTime();
case "senderasyncclient":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,26 @@ public class ServiceBusEndpointUriFactory extends org.apache.camel.support.compo
private static final Set<String> SECRET_PROPERTY_NAMES;
private static final Set<String> MULTI_VALUE_PREFIXES;
static {
Set<String> props = new HashSet<>(31);
Set<String> props = new HashSet<>(28);
props.add("amqpRetryOptions");
props.add("amqpTransportType");
props.add("binary");
props.add("bridgeErrorHandler");
props.add("clientOptions");
props.add("connectionString");
props.add("consumerOperation");
props.add("credentialType");
props.add("disableAutoComplete");
props.add("enableDeadLettering");
props.add("exceptionHandler");
props.add("exchangePattern");
props.add("fullyQualifiedNamespace");
props.add("headerFilterStrategy");
props.add("lazyStartProducer");
props.add("maxAutoLockRenewDuration");
props.add("peekNumMaxMessages");
props.add("maxConcurrentCalls");
props.add("prefetchCount");
props.add("processorClient");
props.add("producerOperation");
props.add("proxyOptions");
props.add("receiverAsyncClient");
props.add("reconnectDelay");
props.add("scheduledEnqueueTime");
props.add("senderAsyncClient");
props.add("serviceBusReceiveMode");
Expand Down
Loading

0 comments on commit b8edb20

Please sign in to comment.