This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 24199f8 CAMEL-17706: camel-azure-servicebus: add
fullyQualifiedNamespace and tokenCredential parameters to the component (#7035)
24199f8 is described below
commit 24199f88c350c4de18957f007a3b4e68e8ffd85d
Author: matt v <[email protected]>
AuthorDate: Sat Feb 26 02:10:12 2022 -0500
CAMEL-17706: camel-azure-servicebus: add fullyQualifiedNamespace and
tokenCredential parameters to the component (#7035)
* CAMEL-17706: add fqns and credential parameter, update variable name,
update validation, add test
* CAMEL-17706: update unit test
* CAMEL-17706: comment and clean up
* CAMEL-17706: remove 'required' for connectionString field
---
.../camel/catalog/components/azure-servicebus.json | 8 +-
.../camel-azure/camel-azure-servicebus/pom.xml | 5 +
.../servicebus/ServiceBusComponentConfigurer.java | 12 ++
.../servicebus/ServiceBusEndpointConfigurer.java | 12 ++
.../servicebus/ServiceBusEndpointUriFactory.java | 18 +--
.../azure/servicebus/azure-servicebus.json | 8 +-
.../azure/servicebus/ServiceBusComponent.java | 25 +++-
.../azure/servicebus/ServiceBusConfiguration.java | 28 +++-
.../servicebus/client/ServiceBusClientFactory.java | 18 ++-
.../azure/servicebus/ServiceBusEndpointTest.java | 73 ++++++++++
.../AzureServicebusComponentBuilderFactory.java | 35 +++++
.../dsl/ServiceBusEndpointBuilderFactory.java | 155 ++++++++++++++++++++-
12 files changed, 376 insertions(+), 21 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/azure-servicebus.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/azure-servicebus.json
index 1c0aeff..b6773a3 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/azure-servicebus.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/azure-servicebus.json
@@ -26,8 +26,10 @@
"amqpTransportType": { "kind": "property", "displayName": "Amqp Transport
Type", "group": "common", "label": "common", "required": false, "type":
"object", "javaType": "com.azure.core.amqp.AmqpTransportType", "enum": [
"Amqp", "AmqpWebSockets" ], "deprecated": false, "autowired": false, "secret":
false, "defaultValue": "AMQP", "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Sets the tr [...]
"clientOptions": { "kind": "property", "displayName": "Client Options",
"group": "common", "label": "common", "required": false, "type": "object",
"javaType": "com.azure.core.util.ClientOptions", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Sets the ClientOptions
to be sent from the client built from this builder, enabling cu [...]
"configuration": { "kind": "property", "displayName": "Configuration",
"group": "common", "label": "", "required": false, "type": "object",
"javaType":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"deprecated": false, "autowired": false, "secret": false, "description": "The
component configurations" },
+ "fullyQualifiedNamespace": { "kind": "property", "displayName": "Fully
Qualified Namespace", "group": "common", "label": "common", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Fully Qualified
Namespace of the service bus" },
"proxyOptions": { "kind": "property", "displayName": "Proxy Options",
"group": "common", "label": "common", "required": false, "type": "object",
"javaType": "com.azure.core.amqp.ProxyOptions", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Sets the proxy
configuration to use for ServiceBusSenderAsyncClient. When a proxy is conf [...]
"serviceBusType": { "kind": "property", "displayName": "Service Bus Type",
"group": "common", "label": "common", "required": true, "type": "object",
"javaType": "org.apache.camel.component.azure.servicebus.ServiceBusType",
"enum": [ "queue", "topic" ], "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "defaultValue": "queue",
"configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration [...]
+ "tokenCredential": { "kind": "property", "displayName": "Token
Credential", "group": "common", "label": "common", "required": false, "type":
"object", "javaType": "com.azure.core.credential.TokenCredential",
"deprecated": false, "autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "A TokenCredential for
Azure AD authentication, implemented in com.azure.id [...]
"bridgeErrorHandler": { "kind": "property", "displayName": "Bridge Error
Handler", "group": "consumer", "label": "consumer", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "description": "Allows for bridging the
consumer to the Camel routing Error Handler, which mean any exceptions occurred
while the consumer is trying to pickup incoming messages, or the likes, will
now be processed as a me [...]
"consumerOperation": { "kind": "property", "displayName": "Consumer
Operation", "group": "consumer", "label": "consumer", "required": false,
"type": "object", "javaType":
"org.apache.camel.component.azure.servicebus.ServiceBusConsumerOperationDefinition",
"enum": [ "receiveMessages", "peekMessages" ], "deprecated": false,
"autowired": false, "secret": false, "defaultValue": "receiveMessages",
"configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration", [...]
"disableAutoComplete": { "kind": "property", "displayName": "Disable Auto
Complete", "group": "consumer", "label": "consumer", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Disables auto-complete
and auto-abandon of received messages. By defaul [...]
@@ -44,15 +46,17 @@
"senderAsyncClient": { "kind": "property", "displayName": "Sender Async
Client", "group": "producer", "label": "producer", "required": false, "type":
"object", "javaType":
"com.azure.messaging.servicebus.ServiceBusSenderAsyncClient", "deprecated":
false, "deprecationNote": "", "autowired": true, "secret": false,
"configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Sets SenderAsyncClient
to [...]
"serviceBusTransactionContext": { "kind": "property", "displayName":
"Service Bus Transaction Context", "group": "producer", "label": "producer",
"required": false, "type": "object", "javaType":
"com.azure.messaging.servicebus.ServiceBusTransactionContext", "deprecated":
false, "autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Represents transaction i
[...]
"autowiredEnabled": { "kind": "property", "displayName": "Autowired
Enabled", "group": "advanced", "label": "advanced", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether autowiring is
enabled. This is used for automatic autowiring options (the option must be
marked as autowired) by looking up in the registry to find if there is a single
instance of matching type, which t [...]
- "connectionString": { "kind": "property", "displayName": "Connection
String", "group": "security", "label": "security", "required": true, "type":
"string", "javaType": "java.lang.String", "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": true,
"configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Sets the connection
string for a Service Bus namespace or a specific Ser [...]
+ "connectionString": { "kind": "property", "displayName": "Connection
String", "group": "security", "label": "security", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": true, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Sets the connection
string for a Service Bus namespace or a specific Service Bus resource." }
},
"properties": {
"topicOrQueueName": { "kind": "path", "displayName": "Topic Or Queue
Name", "group": "common", "label": "", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Selected topic name or
the queue name, that is depending on serviceBusType config. For example if
service [...]
"amqpRetryOptions": { "kind": "parameter", "displayName": "Amqp Retry
Options", "group": "common", "label": "common", "required": false, "type":
"object", "javaType": "com.azure.core.amqp.AmqpRetryOptions", "deprecated":
false, "autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Sets the retry options
for Service Bus clients. If not specified, the defau [...]
"amqpTransportType": { "kind": "parameter", "displayName": "Amqp Transport
Type", "group": "common", "label": "common", "required": false, "type":
"object", "javaType": "com.azure.core.amqp.AmqpTransportType", "enum": [
"Amqp", "AmqpWebSockets" ], "deprecated": false, "autowired": false, "secret":
false, "defaultValue": "AMQP", "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Sets the t [...]
"clientOptions": { "kind": "parameter", "displayName": "Client Options",
"group": "common", "label": "common", "required": false, "type": "object",
"javaType": "com.azure.core.util.ClientOptions", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Sets the ClientOptions
to be sent from the client built from this builder, enabling c [...]
+ "fullyQualifiedNamespace": { "kind": "parameter", "displayName": "Fully
Qualified Namespace", "group": "common", "label": "common", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Fully Qualified
Namespace of the service bus" },
"proxyOptions": { "kind": "parameter", "displayName": "Proxy Options",
"group": "common", "label": "common", "required": false, "type": "object",
"javaType": "com.azure.core.amqp.ProxyOptions", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Sets the proxy
configuration to use for ServiceBusSenderAsyncClient. When a proxy is con [...]
"serviceBusType": { "kind": "parameter", "displayName": "Service Bus
Type", "group": "common", "label": "common", "required": true, "type":
"object", "javaType":
"org.apache.camel.component.azure.servicebus.ServiceBusType", "enum": [
"queue", "topic" ], "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "defaultValue": "queue", "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuratio [...]
+ "tokenCredential": { "kind": "parameter", "displayName": "Token
Credential", "group": "common", "label": "common", "required": false, "type":
"object", "javaType": "com.azure.core.credential.TokenCredential",
"deprecated": false, "autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "A TokenCredential for
Azure AD authentication, implemented in com.azure.i [...]
"bridgeErrorHandler": { "kind": "parameter", "displayName": "Bridge Error
Handler", "group": "consumer", "label": "consumer", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "description": "Allows for bridging the
consumer to the Camel routing Error Handler, which mean any exceptions occurred
while the consumer is trying to pickup incoming messages, or the likes, will
now be processed as a m [...]
"consumerOperation": { "kind": "parameter", "displayName": "Consumer
Operation", "group": "consumer", "label": "consumer", "required": false,
"type": "object", "javaType":
"org.apache.camel.component.azure.servicebus.ServiceBusConsumerOperationDefinition",
"enum": [ "receiveMessages", "peekMessages" ], "deprecated": false,
"autowired": false, "secret": false, "defaultValue": "receiveMessages",
"configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration" [...]
"disableAutoComplete": { "kind": "parameter", "displayName": "Disable Auto
Complete", "group": "consumer", "label": "consumer", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Disables auto-complete
and auto-abandon of received messages. By defau [...]
@@ -70,6 +74,6 @@
"scheduledEnqueueTime": { "kind": "parameter", "displayName": "Scheduled
Enqueue Time", "group": "producer", "label": "producer", "required": false,
"type": "object", "javaType": "java.time.OffsetDateTime", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Sets OffsetDateTime at
which the message should appear in the Service Bus q [...]
"senderAsyncClient": { "kind": "parameter", "displayName": "Sender Async
Client", "group": "producer", "label": "producer", "required": false, "type":
"object", "javaType":
"com.azure.messaging.servicebus.ServiceBusSenderAsyncClient", "deprecated":
false, "deprecationNote": "", "autowired": true, "secret": false,
"configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Sets SenderAsyncClient
to [...]
"serviceBusTransactionContext": { "kind": "parameter", "displayName":
"Service Bus Transaction Context", "group": "producer", "label": "producer",
"required": false, "type": "object", "javaType":
"com.azure.messaging.servicebus.ServiceBusTransactionContext", "deprecated":
false, "autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Represents transaction
[...]
- "connectionString": { "kind": "parameter", "displayName": "Connection
String", "group": "security", "label": "security", "required": true, "type":
"string", "javaType": "java.lang.String", "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": true,
"configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Sets the connection
string for a Service Bus namespace or a specific Se [...]
+ "connectionString": { "kind": "parameter", "displayName": "Connection
String", "group": "security", "label": "security", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": true, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Sets the connection
string for a Service Bus namespace or a specific Service Bus resource." }
}
}
diff --git a/components/camel-azure/camel-azure-servicebus/pom.xml
b/components/camel-azure/camel-azure-servicebus/pom.xml
index a76a6cd..54c48d4 100644
--- a/components/camel-azure/camel-azure-servicebus/pom.xml
+++ b/components/camel-azure/camel-azure-servicebus/pom.xml
@@ -53,6 +53,11 @@
<artifactId>azure-messaging-servicebus</artifactId>
<version>${azure-messaging-servicebus-version}</version>
</dependency>
+ <dependency>
+ <groupId>com.azure</groupId>
+ <artifactId>azure-identity</artifactId>
+ <version>${azure-identity-version}</version>
+ </dependency>
<!-- extras -->
<dependency>
diff --git
a/components/camel-azure/camel-azure-servicebus/src/generated/java/org/apache/camel/component/azure/servicebus/ServiceBusComponentConfigurer.java
b/components/camel-azure/camel-azure-servicebus/src/generated/java/org/apache/camel/component/azure/servicebus/ServiceBusComponentConfigurer.java
index 8f288ed..038dbe0 100644
---
a/components/camel-azure/camel-azure-servicebus/src/generated/java/org/apache/camel/component/azure/servicebus/ServiceBusComponentConfigurer.java
+++
b/components/camel-azure/camel-azure-servicebus/src/generated/java/org/apache/camel/component/azure/servicebus/ServiceBusComponentConfigurer.java
@@ -45,6 +45,8 @@ public class ServiceBusComponentConfigurer extends
PropertyConfigurerSupport imp
case "consumerOperation":
getOrCreateConfiguration(target).setConsumerOperation(property(camelContext,
org.apache.camel.component.azure.servicebus.ServiceBusConsumerOperationDefinition.class,
value)); return true;
case "disableautocomplete":
case "disableAutoComplete":
getOrCreateConfiguration(target).setDisableAutoComplete(property(camelContext,
boolean.class, value)); return true;
+ case "fullyqualifiednamespace":
+ case "fullyQualifiedNamespace":
getOrCreateConfiguration(target).setFullyQualifiedNamespace(property(camelContext,
java.lang.String.class, value)); return true;
case "lazystartproducer":
case "lazyStartProducer":
target.setLazyStartProducer(property(camelContext, boolean.class, value));
return true;
case "maxautolockrenewduration":
@@ -73,6 +75,8 @@ public class ServiceBusComponentConfigurer extends
PropertyConfigurerSupport imp
case "subQueue":
getOrCreateConfiguration(target).setSubQueue(property(camelContext,
com.azure.messaging.servicebus.models.SubQueue.class, value)); return true;
case "subscriptionname":
case "subscriptionName":
getOrCreateConfiguration(target).setSubscriptionName(property(camelContext,
java.lang.String.class, value)); return true;
+ case "tokencredential":
+ case "tokenCredential":
getOrCreateConfiguration(target).setTokenCredential(property(camelContext,
com.azure.core.credential.TokenCredential.class, value)); return true;
default: return false;
}
}
@@ -102,6 +106,8 @@ public class ServiceBusComponentConfigurer extends
PropertyConfigurerSupport imp
case "consumerOperation": return
org.apache.camel.component.azure.servicebus.ServiceBusConsumerOperationDefinition.class;
case "disableautocomplete":
case "disableAutoComplete": return boolean.class;
+ case "fullyqualifiednamespace":
+ case "fullyQualifiedNamespace": return java.lang.String.class;
case "lazystartproducer":
case "lazyStartProducer": return boolean.class;
case "maxautolockrenewduration":
@@ -130,6 +136,8 @@ public class ServiceBusComponentConfigurer extends
PropertyConfigurerSupport imp
case "subQueue": return
com.azure.messaging.servicebus.models.SubQueue.class;
case "subscriptionname":
case "subscriptionName": return java.lang.String.class;
+ case "tokencredential":
+ case "tokenCredential": return
com.azure.core.credential.TokenCredential.class;
default: return null;
}
}
@@ -155,6 +163,8 @@ public class ServiceBusComponentConfigurer extends
PropertyConfigurerSupport imp
case "consumerOperation": return
getOrCreateConfiguration(target).getConsumerOperation();
case "disableautocomplete":
case "disableAutoComplete": return
getOrCreateConfiguration(target).isDisableAutoComplete();
+ case "fullyqualifiednamespace":
+ case "fullyQualifiedNamespace": return
getOrCreateConfiguration(target).getFullyQualifiedNamespace();
case "lazystartproducer":
case "lazyStartProducer": return target.isLazyStartProducer();
case "maxautolockrenewduration":
@@ -183,6 +193,8 @@ public class ServiceBusComponentConfigurer extends
PropertyConfigurerSupport imp
case "subQueue": return getOrCreateConfiguration(target).getSubQueue();
case "subscriptionname":
case "subscriptionName": return
getOrCreateConfiguration(target).getSubscriptionName();
+ case "tokencredential":
+ case "tokenCredential": return
getOrCreateConfiguration(target).getTokenCredential();
default: return null;
}
}
diff --git
a/components/camel-azure/camel-azure-servicebus/src/generated/java/org/apache/camel/component/azure/servicebus/ServiceBusEndpointConfigurer.java
b/components/camel-azure/camel-azure-servicebus/src/generated/java/org/apache/camel/component/azure/servicebus/ServiceBusEndpointConfigurer.java
index 07bcf0d..64791d2 100644
---
a/components/camel-azure/camel-azure-servicebus/src/generated/java/org/apache/camel/component/azure/servicebus/ServiceBusEndpointConfigurer.java
+++
b/components/camel-azure/camel-azure-servicebus/src/generated/java/org/apache/camel/component/azure/servicebus/ServiceBusEndpointConfigurer.java
@@ -39,6 +39,8 @@ public class ServiceBusEndpointConfigurer extends
PropertyConfigurerSupport impl
case "exceptionHandler":
target.setExceptionHandler(property(camelContext,
org.apache.camel.spi.ExceptionHandler.class, value)); return true;
case "exchangepattern":
case "exchangePattern":
target.setExchangePattern(property(camelContext,
org.apache.camel.ExchangePattern.class, value)); return true;
+ case "fullyqualifiednamespace":
+ case "fullyQualifiedNamespace":
target.getConfiguration().setFullyQualifiedNamespace(property(camelContext,
java.lang.String.class, value)); return true;
case "lazystartproducer":
case "lazyStartProducer":
target.setLazyStartProducer(property(camelContext, boolean.class, value));
return true;
case "maxautolockrenewduration":
@@ -67,6 +69,8 @@ public class ServiceBusEndpointConfigurer extends
PropertyConfigurerSupport impl
case "subQueue":
target.getConfiguration().setSubQueue(property(camelContext,
com.azure.messaging.servicebus.models.SubQueue.class, value)); return true;
case "subscriptionname":
case "subscriptionName":
target.getConfiguration().setSubscriptionName(property(camelContext,
java.lang.String.class, value)); return true;
+ case "tokencredential":
+ case "tokenCredential":
target.getConfiguration().setTokenCredential(property(camelContext,
com.azure.core.credential.TokenCredential.class, value)); return true;
default: return false;
}
}
@@ -97,6 +101,8 @@ public class ServiceBusEndpointConfigurer extends
PropertyConfigurerSupport impl
case "exceptionHandler": return
org.apache.camel.spi.ExceptionHandler.class;
case "exchangepattern":
case "exchangePattern": return org.apache.camel.ExchangePattern.class;
+ case "fullyqualifiednamespace":
+ case "fullyQualifiedNamespace": return java.lang.String.class;
case "lazystartproducer":
case "lazyStartProducer": return boolean.class;
case "maxautolockrenewduration":
@@ -125,6 +131,8 @@ public class ServiceBusEndpointConfigurer extends
PropertyConfigurerSupport impl
case "subQueue": return
com.azure.messaging.servicebus.models.SubQueue.class;
case "subscriptionname":
case "subscriptionName": return java.lang.String.class;
+ case "tokencredential":
+ case "tokenCredential": return
com.azure.core.credential.TokenCredential.class;
default: return null;
}
}
@@ -151,6 +159,8 @@ public class ServiceBusEndpointConfigurer extends
PropertyConfigurerSupport impl
case "exceptionHandler": return target.getExceptionHandler();
case "exchangepattern":
case "exchangePattern": return target.getExchangePattern();
+ case "fullyqualifiednamespace":
+ case "fullyQualifiedNamespace": return
target.getConfiguration().getFullyQualifiedNamespace();
case "lazystartproducer":
case "lazyStartProducer": return target.isLazyStartProducer();
case "maxautolockrenewduration":
@@ -179,6 +189,8 @@ public class ServiceBusEndpointConfigurer extends
PropertyConfigurerSupport impl
case "subQueue": return target.getConfiguration().getSubQueue();
case "subscriptionname":
case "subscriptionName": return
target.getConfiguration().getSubscriptionName();
+ case "tokencredential":
+ case "tokenCredential": return
target.getConfiguration().getTokenCredential();
default: return null;
}
}
diff --git
a/components/camel-azure/camel-azure-servicebus/src/generated/java/org/apache/camel/component/azure/servicebus/ServiceBusEndpointUriFactory.java
b/components/camel-azure/camel-azure-servicebus/src/generated/java/org/apache/camel/component/azure/servicebus/ServiceBusEndpointUriFactory.java
index f7acea8..9831db3 100644
---
a/components/camel-azure/camel-azure-servicebus/src/generated/java/org/apache/camel/component/azure/servicebus/ServiceBusEndpointUriFactory.java
+++
b/components/camel-azure/camel-azure-servicebus/src/generated/java/org/apache/camel/component/azure/servicebus/ServiceBusEndpointUriFactory.java
@@ -21,28 +21,30 @@ 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<>(24);
+ Set<String> props = new HashSet<>(26);
props.add("clientOptions");
- props.add("serviceBusType");
props.add("connectionString");
props.add("prefetchCount");
- props.add("receiverAsyncClient");
props.add("serviceBusTransactionContext");
props.add("scheduledEnqueueTime");
+ props.add("consumerOperation");
+ props.add("senderAsyncClient");
+ props.add("bridgeErrorHandler");
+ props.add("peekNumMaxMessages");
+ props.add("topicOrQueueName");
+ props.add("serviceBusType");
+ props.add("receiverAsyncClient");
+ props.add("fullyQualifiedNamespace");
props.add("exchangePattern");
props.add("producerOperation");
props.add("amqpTransportType");
- props.add("consumerOperation");
props.add("serviceBusReceiveMode");
- props.add("senderAsyncClient");
props.add("lazyStartProducer");
- props.add("bridgeErrorHandler");
- props.add("peekNumMaxMessages");
props.add("subQueue");
- props.add("topicOrQueueName");
props.add("subscriptionName");
props.add("amqpRetryOptions");
props.add("proxyOptions");
+ props.add("tokenCredential");
props.add("disableAutoComplete");
props.add("exceptionHandler");
props.add("maxAutoLockRenewDuration");
diff --git
a/components/camel-azure/camel-azure-servicebus/src/generated/resources/org/apache/camel/component/azure/servicebus/azure-servicebus.json
b/components/camel-azure/camel-azure-servicebus/src/generated/resources/org/apache/camel/component/azure/servicebus/azure-servicebus.json
index 1c0aeff..b6773a3 100644
---
a/components/camel-azure/camel-azure-servicebus/src/generated/resources/org/apache/camel/component/azure/servicebus/azure-servicebus.json
+++
b/components/camel-azure/camel-azure-servicebus/src/generated/resources/org/apache/camel/component/azure/servicebus/azure-servicebus.json
@@ -26,8 +26,10 @@
"amqpTransportType": { "kind": "property", "displayName": "Amqp Transport
Type", "group": "common", "label": "common", "required": false, "type":
"object", "javaType": "com.azure.core.amqp.AmqpTransportType", "enum": [
"Amqp", "AmqpWebSockets" ], "deprecated": false, "autowired": false, "secret":
false, "defaultValue": "AMQP", "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Sets the tr [...]
"clientOptions": { "kind": "property", "displayName": "Client Options",
"group": "common", "label": "common", "required": false, "type": "object",
"javaType": "com.azure.core.util.ClientOptions", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Sets the ClientOptions
to be sent from the client built from this builder, enabling cu [...]
"configuration": { "kind": "property", "displayName": "Configuration",
"group": "common", "label": "", "required": false, "type": "object",
"javaType":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"deprecated": false, "autowired": false, "secret": false, "description": "The
component configurations" },
+ "fullyQualifiedNamespace": { "kind": "property", "displayName": "Fully
Qualified Namespace", "group": "common", "label": "common", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Fully Qualified
Namespace of the service bus" },
"proxyOptions": { "kind": "property", "displayName": "Proxy Options",
"group": "common", "label": "common", "required": false, "type": "object",
"javaType": "com.azure.core.amqp.ProxyOptions", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Sets the proxy
configuration to use for ServiceBusSenderAsyncClient. When a proxy is conf [...]
"serviceBusType": { "kind": "property", "displayName": "Service Bus Type",
"group": "common", "label": "common", "required": true, "type": "object",
"javaType": "org.apache.camel.component.azure.servicebus.ServiceBusType",
"enum": [ "queue", "topic" ], "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "defaultValue": "queue",
"configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration [...]
+ "tokenCredential": { "kind": "property", "displayName": "Token
Credential", "group": "common", "label": "common", "required": false, "type":
"object", "javaType": "com.azure.core.credential.TokenCredential",
"deprecated": false, "autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "A TokenCredential for
Azure AD authentication, implemented in com.azure.id [...]
"bridgeErrorHandler": { "kind": "property", "displayName": "Bridge Error
Handler", "group": "consumer", "label": "consumer", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "description": "Allows for bridging the
consumer to the Camel routing Error Handler, which mean any exceptions occurred
while the consumer is trying to pickup incoming messages, or the likes, will
now be processed as a me [...]
"consumerOperation": { "kind": "property", "displayName": "Consumer
Operation", "group": "consumer", "label": "consumer", "required": false,
"type": "object", "javaType":
"org.apache.camel.component.azure.servicebus.ServiceBusConsumerOperationDefinition",
"enum": [ "receiveMessages", "peekMessages" ], "deprecated": false,
"autowired": false, "secret": false, "defaultValue": "receiveMessages",
"configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration", [...]
"disableAutoComplete": { "kind": "property", "displayName": "Disable Auto
Complete", "group": "consumer", "label": "consumer", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Disables auto-complete
and auto-abandon of received messages. By defaul [...]
@@ -44,15 +46,17 @@
"senderAsyncClient": { "kind": "property", "displayName": "Sender Async
Client", "group": "producer", "label": "producer", "required": false, "type":
"object", "javaType":
"com.azure.messaging.servicebus.ServiceBusSenderAsyncClient", "deprecated":
false, "deprecationNote": "", "autowired": true, "secret": false,
"configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Sets SenderAsyncClient
to [...]
"serviceBusTransactionContext": { "kind": "property", "displayName":
"Service Bus Transaction Context", "group": "producer", "label": "producer",
"required": false, "type": "object", "javaType":
"com.azure.messaging.servicebus.ServiceBusTransactionContext", "deprecated":
false, "autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Represents transaction i
[...]
"autowiredEnabled": { "kind": "property", "displayName": "Autowired
Enabled", "group": "advanced", "label": "advanced", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether autowiring is
enabled. This is used for automatic autowiring options (the option must be
marked as autowired) by looking up in the registry to find if there is a single
instance of matching type, which t [...]
- "connectionString": { "kind": "property", "displayName": "Connection
String", "group": "security", "label": "security", "required": true, "type":
"string", "javaType": "java.lang.String", "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": true,
"configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Sets the connection
string for a Service Bus namespace or a specific Ser [...]
+ "connectionString": { "kind": "property", "displayName": "Connection
String", "group": "security", "label": "security", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": true, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Sets the connection
string for a Service Bus namespace or a specific Service Bus resource." }
},
"properties": {
"topicOrQueueName": { "kind": "path", "displayName": "Topic Or Queue
Name", "group": "common", "label": "", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Selected topic name or
the queue name, that is depending on serviceBusType config. For example if
service [...]
"amqpRetryOptions": { "kind": "parameter", "displayName": "Amqp Retry
Options", "group": "common", "label": "common", "required": false, "type":
"object", "javaType": "com.azure.core.amqp.AmqpRetryOptions", "deprecated":
false, "autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Sets the retry options
for Service Bus clients. If not specified, the defau [...]
"amqpTransportType": { "kind": "parameter", "displayName": "Amqp Transport
Type", "group": "common", "label": "common", "required": false, "type":
"object", "javaType": "com.azure.core.amqp.AmqpTransportType", "enum": [
"Amqp", "AmqpWebSockets" ], "deprecated": false, "autowired": false, "secret":
false, "defaultValue": "AMQP", "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Sets the t [...]
"clientOptions": { "kind": "parameter", "displayName": "Client Options",
"group": "common", "label": "common", "required": false, "type": "object",
"javaType": "com.azure.core.util.ClientOptions", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Sets the ClientOptions
to be sent from the client built from this builder, enabling c [...]
+ "fullyQualifiedNamespace": { "kind": "parameter", "displayName": "Fully
Qualified Namespace", "group": "common", "label": "common", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Fully Qualified
Namespace of the service bus" },
"proxyOptions": { "kind": "parameter", "displayName": "Proxy Options",
"group": "common", "label": "common", "required": false, "type": "object",
"javaType": "com.azure.core.amqp.ProxyOptions", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Sets the proxy
configuration to use for ServiceBusSenderAsyncClient. When a proxy is con [...]
"serviceBusType": { "kind": "parameter", "displayName": "Service Bus
Type", "group": "common", "label": "common", "required": true, "type":
"object", "javaType":
"org.apache.camel.component.azure.servicebus.ServiceBusType", "enum": [
"queue", "topic" ], "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "defaultValue": "queue", "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuratio [...]
+ "tokenCredential": { "kind": "parameter", "displayName": "Token
Credential", "group": "common", "label": "common", "required": false, "type":
"object", "javaType": "com.azure.core.credential.TokenCredential",
"deprecated": false, "autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "A TokenCredential for
Azure AD authentication, implemented in com.azure.i [...]
"bridgeErrorHandler": { "kind": "parameter", "displayName": "Bridge Error
Handler", "group": "consumer", "label": "consumer", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "description": "Allows for bridging the
consumer to the Camel routing Error Handler, which mean any exceptions occurred
while the consumer is trying to pickup incoming messages, or the likes, will
now be processed as a m [...]
"consumerOperation": { "kind": "parameter", "displayName": "Consumer
Operation", "group": "consumer", "label": "consumer", "required": false,
"type": "object", "javaType":
"org.apache.camel.component.azure.servicebus.ServiceBusConsumerOperationDefinition",
"enum": [ "receiveMessages", "peekMessages" ], "deprecated": false,
"autowired": false, "secret": false, "defaultValue": "receiveMessages",
"configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration" [...]
"disableAutoComplete": { "kind": "parameter", "displayName": "Disable Auto
Complete", "group": "consumer", "label": "consumer", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Disables auto-complete
and auto-abandon of received messages. By defau [...]
@@ -70,6 +74,6 @@
"scheduledEnqueueTime": { "kind": "parameter", "displayName": "Scheduled
Enqueue Time", "group": "producer", "label": "producer", "required": false,
"type": "object", "javaType": "java.time.OffsetDateTime", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Sets OffsetDateTime at
which the message should appear in the Service Bus q [...]
"senderAsyncClient": { "kind": "parameter", "displayName": "Sender Async
Client", "group": "producer", "label": "producer", "required": false, "type":
"object", "javaType":
"com.azure.messaging.servicebus.ServiceBusSenderAsyncClient", "deprecated":
false, "deprecationNote": "", "autowired": true, "secret": false,
"configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Sets SenderAsyncClient
to [...]
"serviceBusTransactionContext": { "kind": "parameter", "displayName":
"Service Bus Transaction Context", "group": "producer", "label": "producer",
"required": false, "type": "object", "javaType":
"com.azure.messaging.servicebus.ServiceBusTransactionContext", "deprecated":
false, "autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Represents transaction
[...]
- "connectionString": { "kind": "parameter", "displayName": "Connection
String", "group": "security", "label": "security", "required": true, "type":
"string", "javaType": "java.lang.String", "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": true,
"configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Sets the connection
string for a Service Bus namespace or a specific Se [...]
+ "connectionString": { "kind": "parameter", "displayName": "Connection
String", "group": "security", "label": "security", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": true, "configurationClass":
"org.apache.camel.component.azure.servicebus.ServiceBusConfiguration",
"configurationField": "configuration", "description": "Sets the connection
string for a Service Bus namespace or a specific Service Bus resource." }
}
}
diff --git
a/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/ServiceBusComponent.java
b/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/ServiceBusComponent.java
index 725d827..d828d2b 100644
---
a/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/ServiceBusComponent.java
+++
b/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/ServiceBusComponent.java
@@ -17,7 +17,10 @@
package org.apache.camel.component.azure.servicebus;
import java.util.Map;
+import java.util.Set;
+import com.azure.core.credential.TokenCredential;
+import com.azure.identity.DefaultAzureCredentialBuilder;
import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
import org.apache.camel.spi.Metadata;
@@ -60,11 +63,27 @@ public class ServiceBusComponent extends DefaultComponent {
final ServiceBusEndpoint endpoint = new ServiceBusEndpoint(uri, this,
configuration);
setProperties(endpoint, parameters);
+ setCredentials(configuration);
validateConfigurations(configuration);
return endpoint;
}
+ private void setCredentials(final ServiceBusConfiguration configuration) {
+ if
(ObjectHelper.isNotEmpty(configuration.getFullyQualifiedNamespace()) &&
+ ObjectHelper.isEmpty(configuration.getTokenCredential())) {
+ final Set<TokenCredential> tokenCredentialFromRegistry
+ =
getCamelContext().getRegistry().findByType(TokenCredential.class);
+
+ // Find exactly one from the registry or create one
+ if (tokenCredentialFromRegistry.size() == 1) {
+
configuration.setTokenCredential(tokenCredentialFromRegistry.stream().findFirst().get());
+ } else {
+ configuration.setTokenCredential(new
DefaultAzureCredentialBuilder().build());
+ }
+ }
+ }
+
/**
* The component configurations
*/
@@ -78,8 +97,10 @@ public class ServiceBusComponent extends DefaultComponent {
private void validateConfigurations(final ServiceBusConfiguration
configuration) {
if (configuration.getReceiverAsyncClient() == null ||
configuration.getSenderAsyncClient() == null) {
- if (ObjectHelper.isEmpty(configuration.getConnectionString())) {
- throw new IllegalArgumentException("Azure ServiceBus
ConnectionString must be specified.");
+ if (ObjectHelper.isEmpty(configuration.getConnectionString()) &&
+
ObjectHelper.isEmpty(configuration.getFullyQualifiedNamespace())) {
+ throw new IllegalArgumentException(
+ "Azure ServiceBus ConnectionString or FQNS must be
specified.");
}
}
}
diff --git
a/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/ServiceBusConfiguration.java
b/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/ServiceBusConfiguration.java
index b8de28c..f4a3673 100644
---
a/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/ServiceBusConfiguration.java
+++
b/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/ServiceBusConfiguration.java
@@ -22,6 +22,7 @@ import java.time.OffsetDateTime;
import com.azure.core.amqp.AmqpRetryOptions;
import com.azure.core.amqp.AmqpTransportType;
import com.azure.core.amqp.ProxyOptions;
+import com.azure.core.credential.TokenCredential;
import com.azure.core.util.ClientOptions;
import com.azure.messaging.servicebus.ServiceBusReceivedMessage;
import com.azure.messaging.servicebus.ServiceBusReceiverAsyncClient;
@@ -41,7 +42,6 @@ public class ServiceBusConfiguration implements Cloneable {
@UriPath
private String topicOrQueueName;
@UriParam(label = "security", secret = true)
- @Metadata(required = true)
private String connectionString;
@UriParam(label = "common", defaultValue = "queue")
@Metadata(required = true)
@@ -54,6 +54,10 @@ public class ServiceBusConfiguration implements Cloneable {
private AmqpRetryOptions amqpRetryOptions;
@UriParam(label = "common", defaultValue = "AMQP")
private AmqpTransportType amqpTransportType = AmqpTransportType.AMQP;
+ @UriParam(label = "common")
+ private String fullyQualifiedNamespace;
+ @UriParam(label = "common")
+ private TokenCredential tokenCredential;
@UriParam(label = "consumer", defaultValue = "receiveMessages")
private ServiceBusConsumerOperationDefinition consumerOperation =
ServiceBusConsumerOperationDefinition.receiveMessages;
@UriParam(label = "consumer")
@@ -265,6 +269,28 @@ public class ServiceBusConfiguration implements Cloneable {
}
/**
+ * Fully Qualified Namespace of the service bus
+ */
+ public String getFullyQualifiedNamespace() {
+ return fullyQualifiedNamespace;
+ }
+
+ public void setFullyQualifiedNamespace(String fullyQualifiedNamespace) {
+ this.fullyQualifiedNamespace = fullyQualifiedNamespace;
+ }
+
+ /**
+ * A {@link TokenCredential} for Azure AD authentication, implemented in
{@link com.azure.identity}
+ */
+ public TokenCredential getTokenCredential() {
+ return tokenCredential;
+ }
+
+ public void setTokenCredential(TokenCredential tokenCredential) {
+ this.tokenCredential = tokenCredential;
+ }
+
+ /**
* Sets the desired operation to be used in the consumer
*/
public ServiceBusConsumerOperationDefinition getConsumerOperation() {
diff --git
a/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/client/ServiceBusClientFactory.java
b/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/client/ServiceBusClientFactory.java
index d1b8485..7292bc3 100644
---
a/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/client/ServiceBusClientFactory.java
+++
b/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/client/ServiceBusClientFactory.java
@@ -16,11 +16,13 @@
*/
package org.apache.camel.component.azure.servicebus.client;
+import com.azure.core.credential.TokenCredential;
import com.azure.messaging.servicebus.ServiceBusClientBuilder;
import com.azure.messaging.servicebus.ServiceBusReceiverAsyncClient;
import com.azure.messaging.servicebus.ServiceBusSenderAsyncClient;
import org.apache.camel.component.azure.servicebus.ServiceBusConfiguration;
import org.apache.camel.component.azure.servicebus.ServiceBusType;
+import org.apache.camel.util.ObjectHelper;
public final class ServiceBusClientFactory {
@@ -44,12 +46,22 @@ public final class ServiceBusClientFactory {
}
private static ServiceBusClientBuilder createBaseServiceBusClient(final
ServiceBusConfiguration configuration) {
- return new ServiceBusClientBuilder()
+ ServiceBusClientBuilder builder = new ServiceBusClientBuilder()
.transportType(configuration.getAmqpTransportType())
.clientOptions(configuration.getClientOptions())
.retryOptions(configuration.getAmqpRetryOptions())
- .proxyOptions(configuration.getProxyOptions())
- .connectionString(configuration.getConnectionString());
+ .proxyOptions(configuration.getProxyOptions());
+
+ String fullyQualifiedNamespace =
configuration.getFullyQualifiedNamespace();
+ TokenCredential credential = configuration.getTokenCredential();
+
+ // If the FQNS and credential are available, use those to connect
+ if (ObjectHelper.isNotEmpty(fullyQualifiedNamespace) &&
ObjectHelper.isNotEmpty(credential)) {
+ builder.credential(fullyQualifiedNamespace, credential);
+ } else {
+ builder.connectionString(configuration.getConnectionString());
+ }
+ return builder;
}
private static ServiceBusClientBuilder.ServiceBusSenderClientBuilder
createBaseServiceBusSenderClient(
diff --git
a/components/camel-azure/camel-azure-servicebus/src/test/java/org/apache/camel/component/azure/servicebus/ServiceBusEndpointTest.java
b/components/camel-azure/camel-azure-servicebus/src/test/java/org/apache/camel/component/azure/servicebus/ServiceBusEndpointTest.java
index 94af271..6b03785 100644
---
a/components/camel-azure/camel-azure-servicebus/src/test/java/org/apache/camel/component/azure/servicebus/ServiceBusEndpointTest.java
+++
b/components/camel-azure/camel-azure-servicebus/src/test/java/org/apache/camel/component/azure/servicebus/ServiceBusEndpointTest.java
@@ -19,11 +19,14 @@ package org.apache.camel.component.azure.servicebus;
import java.util.HashMap;
import java.util.Map;
+import com.azure.core.credential.TokenCredential;
+import com.azure.identity.DefaultAzureCredentialBuilder;
import org.apache.camel.ResolveEndpointFailedException;
import org.apache.camel.test.junit5.CamelTestSupport;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
class ServiceBusEndpointTest extends CamelTestSupport {
@@ -35,6 +38,10 @@ class ServiceBusEndpointTest extends CamelTestSupport {
assertThrows(ResolveEndpointFailedException.class,
() ->
context.getEndpoint("azure-servicebus://?connectionString=test"));
+
+ // provided credential but no fully qualified namespace
+ assertThrows(ResolveEndpointFailedException.class,
+ () ->
context.getEndpoint("azure-servicebus:test?tokenCredential=credential"));
}
@Test
@@ -56,4 +63,70 @@ class ServiceBusEndpointTest extends CamelTestSupport {
assertEquals("testString",
endpoint.getConfiguration().getConnectionString());
}
+ @Test
+ void testCreateEndpointWithFqns() throws Exception {
+ final String uri = "azure-servicebus://testTopicOrQueue";
+ final String remaining = "testTopicOrQueue";
+ final String fullyQualifiedNamespace =
"namespace.servicebus.windows.net";
+ final Map<String, Object> params = new HashMap<>();
+ params.put("serviceBusType", ServiceBusType.topic);
+ params.put("prefetchCount", 10);
+ params.put("fullyQualifiedNamespace", fullyQualifiedNamespace);
+
+ final ServiceBusEndpoint endpoint
+ = (ServiceBusEndpoint)
context.getComponent("azure-servicebus", ServiceBusComponent.class)
+ .createEndpoint(uri, remaining, params);
+
+ assertEquals(ServiceBusType.topic,
endpoint.getConfiguration().getServiceBusType());
+ assertEquals("testTopicOrQueue",
endpoint.getConfiguration().getTopicOrQueueName());
+ assertEquals(10, endpoint.getConfiguration().getPrefetchCount());
+ assertEquals(fullyQualifiedNamespace,
endpoint.getConfiguration().getFullyQualifiedNamespace());
+ assertNotNull(endpoint.getConfiguration().getTokenCredential());
+ }
+
+ @Test
+ void testCreateEndpointWithFqnsAndCredential() throws Exception {
+ final String uri = "azure-servicebus://testTopicOrQueue";
+ final String remaining = "testTopicOrQueue";
+ final String fullyQualifiedNamespace =
"namespace.servicebus.windows.net";
+ final TokenCredential credential = new
DefaultAzureCredentialBuilder().build();
+ final Map<String, Object> params = new HashMap<>();
+ params.put("serviceBusType", ServiceBusType.topic);
+ params.put("prefetchCount", 10);
+ params.put("fullyQualifiedNamespace", fullyQualifiedNamespace);
+ params.put("tokenCredential", credential);
+
+ final ServiceBusEndpoint endpoint
+ = (ServiceBusEndpoint)
context.getComponent("azure-servicebus", ServiceBusComponent.class)
+ .createEndpoint(uri, remaining, params);
+
+ assertEquals(ServiceBusType.topic,
endpoint.getConfiguration().getServiceBusType());
+ assertEquals("testTopicOrQueue",
endpoint.getConfiguration().getTopicOrQueueName());
+ assertEquals(10, endpoint.getConfiguration().getPrefetchCount());
+ assertEquals(fullyQualifiedNamespace,
endpoint.getConfiguration().getFullyQualifiedNamespace());
+ assertEquals(credential,
endpoint.getConfiguration().getTokenCredential());
+ }
+
+ @Test
+ void testCreateEndpointWithFqnsAndCredentialFromRegistry() throws
Exception {
+ final String uri = "azure-servicebus://testTopicOrQueue";
+ final String remaining = "testTopicOrQueue";
+ final String fullyQualifiedNamespace =
"namespace.servicebus.windows.net";
+ final TokenCredential credential = new
DefaultAzureCredentialBuilder().build();
+ final Map<String, Object> params = new HashMap<>();
+ context().getRegistry().bind("tokenCredential", credential);
+ params.put("serviceBusType", ServiceBusType.topic);
+ params.put("prefetchCount", 10);
+ params.put("fullyQualifiedNamespace", fullyQualifiedNamespace);
+
+ final ServiceBusEndpoint endpoint
+ = (ServiceBusEndpoint)
context.getComponent("azure-servicebus", ServiceBusComponent.class)
+ .createEndpoint(uri, remaining, params);
+
+ assertEquals(ServiceBusType.topic,
endpoint.getConfiguration().getServiceBusType());
+ assertEquals("testTopicOrQueue",
endpoint.getConfiguration().getTopicOrQueueName());
+ assertEquals(10, endpoint.getConfiguration().getPrefetchCount());
+ assertEquals(fullyQualifiedNamespace,
endpoint.getConfiguration().getFullyQualifiedNamespace());
+ assertEquals(credential,
endpoint.getConfiguration().getTokenCredential());
+ }
}
diff --git
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AzureServicebusComponentBuilderFactory.java
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AzureServicebusComponentBuilderFactory.java
index b8c9948..9059c98 100644
---
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AzureServicebusComponentBuilderFactory.java
+++
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AzureServicebusComponentBuilderFactory.java
@@ -121,6 +121,21 @@ public interface AzureServicebusComponentBuilderFactory {
return this;
}
/**
+ * Fully Qualified Namespace of the service bus.
+ *
+ * The option is a: <code>java.lang.String</code> type.
+ *
+ * Group: common
+ *
+ * @param fullyQualifiedNamespace the value to set
+ * @return the dsl builder
+ */
+ default AzureServicebusComponentBuilder fullyQualifiedNamespace(
+ java.lang.String fullyQualifiedNamespace) {
+ doSetProperty("fullyQualifiedNamespace", fullyQualifiedNamespace);
+ return this;
+ }
+ /**
* Sets the proxy configuration to use for ServiceBusSenderAsyncClient.
* When a proxy is configured, AmqpTransportType#AMQP_WEB_SOCKETS must
* be used for the transport type.
@@ -157,6 +172,24 @@ public interface AzureServicebusComponentBuilderFactory {
return this;
}
/**
+ * A TokenCredential for Azure AD authentication, implemented in
+ * com.azure.identity.
+ *
+ * The option is a:
+ * <code>com.azure.core.credential.TokenCredential</code>
+ * type.
+ *
+ * Group: common
+ *
+ * @param tokenCredential the value to set
+ * @return the dsl builder
+ */
+ default AzureServicebusComponentBuilder tokenCredential(
+ com.azure.core.credential.TokenCredential tokenCredential) {
+ doSetProperty("tokenCredential", tokenCredential);
+ return this;
+ }
+ /**
* Allows for bridging the consumer to the Camel routing Error Handler,
* which mean any exceptions occurred while the consumer is trying to
* pickup incoming messages, or the likes, will now be processed as a
@@ -497,8 +530,10 @@ public interface AzureServicebusComponentBuilderFactory {
case "amqpTransportType":
getOrCreateConfiguration((ServiceBusComponent)
component).setAmqpTransportType((com.azure.core.amqp.AmqpTransportType) value);
return true;
case "clientOptions":
getOrCreateConfiguration((ServiceBusComponent)
component).setClientOptions((com.azure.core.util.ClientOptions) value); return
true;
case "configuration": ((ServiceBusComponent)
component).setConfiguration((org.apache.camel.component.azure.servicebus.ServiceBusConfiguration)
value); return true;
+ case "fullyQualifiedNamespace":
getOrCreateConfiguration((ServiceBusComponent)
component).setFullyQualifiedNamespace((java.lang.String) value); return true;
case "proxyOptions":
getOrCreateConfiguration((ServiceBusComponent)
component).setProxyOptions((com.azure.core.amqp.ProxyOptions) value); return
true;
case "serviceBusType":
getOrCreateConfiguration((ServiceBusComponent)
component).setServiceBusType((org.apache.camel.component.azure.servicebus.ServiceBusType)
value); return true;
+ case "tokenCredential":
getOrCreateConfiguration((ServiceBusComponent)
component).setTokenCredential((com.azure.core.credential.TokenCredential)
value); return true;
case "bridgeErrorHandler": ((ServiceBusComponent)
component).setBridgeErrorHandler((boolean) value); return true;
case "consumerOperation":
getOrCreateConfiguration((ServiceBusComponent)
component).setConsumerOperation((org.apache.camel.component.azure.servicebus.ServiceBusConsumerOperationDefinition)
value); return true;
case "disableAutoComplete":
getOrCreateConfiguration((ServiceBusComponent)
component).setDisableAutoComplete((boolean) value); return true;
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ServiceBusEndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ServiceBusEndpointBuilderFactory.java
index 9978792..25bb1a1 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ServiceBusEndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ServiceBusEndpointBuilderFactory.java
@@ -152,6 +152,21 @@ public interface ServiceBusEndpointBuilderFactory {
return this;
}
/**
+ * Fully Qualified Namespace of the service bus.
+ *
+ * The option is a: <code>java.lang.String</code> type.
+ *
+ * Group: common
+ *
+ * @param fullyQualifiedNamespace the value to set
+ * @return the dsl builder
+ */
+ default ServiceBusEndpointConsumerBuilder fullyQualifiedNamespace(
+ String fullyQualifiedNamespace) {
+ doSetProperty("fullyQualifiedNamespace", fullyQualifiedNamespace);
+ return this;
+ }
+ /**
* Sets the proxy configuration to use for ServiceBusSenderAsyncClient.
* When a proxy is configured, AmqpTransportType#AMQP_WEB_SOCKETS must
* be used for the transport type.
@@ -226,6 +241,42 @@ public interface ServiceBusEndpointBuilderFactory {
return this;
}
/**
+ * A TokenCredential for Azure AD authentication, implemented in
+ * com.azure.identity.
+ *
+ * The option is a:
+ * <code>com.azure.core.credential.TokenCredential</code>
+ * type.
+ *
+ * Group: common
+ *
+ * @param tokenCredential the value to set
+ * @return the dsl builder
+ */
+ default ServiceBusEndpointConsumerBuilder tokenCredential(
+ com.azure.core.credential.TokenCredential tokenCredential) {
+ doSetProperty("tokenCredential", tokenCredential);
+ return this;
+ }
+ /**
+ * A TokenCredential for Azure AD authentication, implemented in
+ * com.azure.identity.
+ *
+ * The option will be converted to a
+ * <code>com.azure.core.credential.TokenCredential</code>
+ * type.
+ *
+ * Group: common
+ *
+ * @param tokenCredential the value to set
+ * @return the dsl builder
+ */
+ default ServiceBusEndpointConsumerBuilder tokenCredential(
+ String tokenCredential) {
+ doSetProperty("tokenCredential", tokenCredential);
+ return this;
+ }
+ /**
* Allows for bridging the consumer to the Camel routing Error Handler,
* which mean any exceptions occurred while the consumer is trying to
* pickup incoming messages, or the likes, will now be processed as a
@@ -590,7 +641,6 @@ public interface ServiceBusEndpointBuilderFactory {
*
* The option is a: <code>java.lang.String</code> type.
*
- * Required: true
* Group: security
*
* @param connectionString the value to set
@@ -803,6 +853,21 @@ public interface ServiceBusEndpointBuilderFactory {
return this;
}
/**
+ * Fully Qualified Namespace of the service bus.
+ *
+ * The option is a: <code>java.lang.String</code> type.
+ *
+ * Group: common
+ *
+ * @param fullyQualifiedNamespace the value to set
+ * @return the dsl builder
+ */
+ default ServiceBusEndpointProducerBuilder fullyQualifiedNamespace(
+ String fullyQualifiedNamespace) {
+ doSetProperty("fullyQualifiedNamespace", fullyQualifiedNamespace);
+ return this;
+ }
+ /**
* Sets the proxy configuration to use for ServiceBusSenderAsyncClient.
* When a proxy is configured, AmqpTransportType#AMQP_WEB_SOCKETS must
* be used for the transport type.
@@ -877,6 +942,42 @@ public interface ServiceBusEndpointBuilderFactory {
return this;
}
/**
+ * A TokenCredential for Azure AD authentication, implemented in
+ * com.azure.identity.
+ *
+ * The option is a:
+ * <code>com.azure.core.credential.TokenCredential</code>
+ * type.
+ *
+ * Group: common
+ *
+ * @param tokenCredential the value to set
+ * @return the dsl builder
+ */
+ default ServiceBusEndpointProducerBuilder tokenCredential(
+ com.azure.core.credential.TokenCredential tokenCredential) {
+ doSetProperty("tokenCredential", tokenCredential);
+ return this;
+ }
+ /**
+ * A TokenCredential for Azure AD authentication, implemented in
+ * com.azure.identity.
+ *
+ * The option will be converted to a
+ * <code>com.azure.core.credential.TokenCredential</code>
+ * type.
+ *
+ * Group: common
+ *
+ * @param tokenCredential the value to set
+ * @return the dsl builder
+ */
+ default ServiceBusEndpointProducerBuilder tokenCredential(
+ String tokenCredential) {
+ doSetProperty("tokenCredential", tokenCredential);
+ return this;
+ }
+ /**
* Whether the producer should be started lazy (on the first message).
* By starting lazy you can use this to allow CamelContext and routes
to
* startup in situations where a producer may otherwise fail during
@@ -1065,7 +1166,6 @@ public interface ServiceBusEndpointBuilderFactory {
*
* The option is a: <code>java.lang.String</code> type.
*
- * Required: true
* Group: security
*
* @param connectionString the value to set
@@ -1208,6 +1308,21 @@ public interface ServiceBusEndpointBuilderFactory {
return this;
}
/**
+ * Fully Qualified Namespace of the service bus.
+ *
+ * The option is a: <code>java.lang.String</code> type.
+ *
+ * Group: common
+ *
+ * @param fullyQualifiedNamespace the value to set
+ * @return the dsl builder
+ */
+ default ServiceBusEndpointBuilder fullyQualifiedNamespace(
+ String fullyQualifiedNamespace) {
+ doSetProperty("fullyQualifiedNamespace", fullyQualifiedNamespace);
+ return this;
+ }
+ /**
* Sets the proxy configuration to use for ServiceBusSenderAsyncClient.
* When a proxy is configured, AmqpTransportType#AMQP_WEB_SOCKETS must
* be used for the transport type.
@@ -1280,12 +1395,46 @@ public interface ServiceBusEndpointBuilderFactory {
return this;
}
/**
+ * A TokenCredential for Azure AD authentication, implemented in
+ * com.azure.identity.
+ *
+ * The option is a:
+ * <code>com.azure.core.credential.TokenCredential</code>
+ * type.
+ *
+ * Group: common
+ *
+ * @param tokenCredential the value to set
+ * @return the dsl builder
+ */
+ default ServiceBusEndpointBuilder tokenCredential(
+ com.azure.core.credential.TokenCredential tokenCredential) {
+ doSetProperty("tokenCredential", tokenCredential);
+ return this;
+ }
+ /**
+ * A TokenCredential for Azure AD authentication, implemented in
+ * com.azure.identity.
+ *
+ * The option will be converted to a
+ * <code>com.azure.core.credential.TokenCredential</code>
+ * type.
+ *
+ * Group: common
+ *
+ * @param tokenCredential the value to set
+ * @return the dsl builder
+ */
+ default ServiceBusEndpointBuilder tokenCredential(String
tokenCredential) {
+ doSetProperty("tokenCredential", tokenCredential);
+ return this;
+ }
+ /**
* Sets the connection string for a Service Bus namespace or a specific
* Service Bus resource.
*
* The option is a: <code>java.lang.String</code> type.
*
- * Required: true
* Group: security
*
* @param connectionString the value to set