You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by se...@apache.org on 2017/02/21 12:44:10 UTC
[1/2] camel git commit: [CAMEL-10786] Adding initial Azure Queue
component code
Repository: camel
Updated Branches:
refs/heads/master dbeb42c42 -> 507e8b5f8
[CAMEL-10786] Adding initial Azure Queue component code
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/1b40de61
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1b40de61
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1b40de61
Branch: refs/heads/master
Commit: 1b40de614c99824efcaf2e438acc3df2a5b9b8c0
Parents: dbeb42c
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Tue Feb 21 12:39:40 2017 +0000
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Tue Feb 21 12:39:40 2017 +0000
----------------------------------------------------------------------
.../src/main/docs/azure-blob-component.adoc | 6 ++--
.../azure/blob/BlobServiceComponent.java | 2 +-
.../azure/blob/BlobServiceConfiguration.java | 32 ++++++++++----------
.../azure/common/AbstractConfiguration.java | 1 -
.../BlobServiceComponentConfigurationTest.java | 11 +++++++
...dditional-spring-configuration-metadata.json | 6 ++++
.../main/resources/META-INF/spring.factories | 4 ++-
7 files changed, 40 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/1b40de61/components/camel-azure/src/main/docs/azure-blob-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-azure/src/main/docs/azure-blob-component.adoc b/components/camel-azure/src/main/docs/azure-blob-component.adoc
index de323e7..69e7629 100644
--- a/components/camel-azure/src/main/docs/azure-blob-component.adoc
+++ b/components/camel-azure/src/main/docs/azure-blob-component.adoc
@@ -62,7 +62,7 @@ The Azure Storage Blob Service component supports 20 endpoint options which are
| credentials | common | | StorageCredentials | Set the storage credentials required in most cases
| dataLength | common | | Long | Set the data length for the download or page blob upload operations
| fileDir | common | | String | Set the file directory where the downloaded blobs will be saved to
-| publicForRead | common | false | boolean | Blobs can be public for reading their content if this property is enabled then the credentials do not have to be set
+| publicForRead | common | false | boolean | Storage resources can be public for reading their content if this property is enabled then the credentials do not have to be set
| streamReadSize | common | | int | Set the minimum read size in bytes when reading the blob content
| bridgeErrorHandler | consumer | false | boolean | 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 message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN or ERROR level and ignored.
| exceptionHandler | consumer (advanced) | | ExceptionHandler | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN or ERROR level and ignored.
@@ -70,7 +70,7 @@ The Azure Storage Blob Service component supports 20 endpoint options which are
| blobMetadata | producer | | Map | Set the blob meta-data
| blobPrefix | producer | | String | Set a prefix which can be used for listing the blobs
| closeStreamAfterWrite | producer | true | boolean | Close the stream after write or keep it open default is true
-| operation | producer | listBlobs | BlobServiceOperations | Required blob service operation hint to the producer
+| operation | producer | listBlobs | BlobServiceOperations | Blob service operation hint to the producer
| streamWriteSize | producer | | int | Set the size of the buffer for writing block and page blocks
| useFlatListing | producer | true | boolean | Specify if the flat or hierarchical blob listing should be used
| synchronous | advanced | false | boolean | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported).
@@ -162,4 +162,4 @@ where `${camel-version`} must be replaced by the actual version of Camel
* link:endpoint.html[Endpoint]
* link:getting-started.html[Getting Started]
-* link:azure.html[Azure Component]
\ No newline at end of file
+* link:azure.html[Azure Component]
http://git-wip-us.apache.org/repos/asf/camel/blob/1b40de61/components/camel-azure/src/main/java/org/apache/camel/component/azure/blob/BlobServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-azure/src/main/java/org/apache/camel/component/azure/blob/BlobServiceComponent.java b/components/camel-azure/src/main/java/org/apache/camel/component/azure/blob/BlobServiceComponent.java
index 68925aa..6c83384 100644
--- a/components/camel-azure/src/main/java/org/apache/camel/component/azure/blob/BlobServiceComponent.java
+++ b/components/camel-azure/src/main/java/org/apache/camel/component/azure/blob/BlobServiceComponent.java
@@ -44,7 +44,7 @@ public class BlobServiceComponent extends UriEndpointComponent {
parts = remaining.split("/");
}
if (parts == null || parts.length < 2) {
- throw new IllegalArgumentException("At least account and container names must be specified.");
+ throw new IllegalArgumentException("At least the account and container names must be specified.");
}
configuration.setAccountName(parts[0]);
http://git-wip-us.apache.org/repos/asf/camel/blob/1b40de61/components/camel-azure/src/main/java/org/apache/camel/component/azure/blob/BlobServiceConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-azure/src/main/java/org/apache/camel/component/azure/blob/BlobServiceConfiguration.java b/components/camel-azure/src/main/java/org/apache/camel/component/azure/blob/BlobServiceConfiguration.java
index c6f47a5..a94dbfd 100644
--- a/components/camel-azure/src/main/java/org/apache/camel/component/azure/blob/BlobServiceConfiguration.java
+++ b/components/camel-azure/src/main/java/org/apache/camel/component/azure/blob/BlobServiceConfiguration.java
@@ -63,12 +63,12 @@ public class BlobServiceConfiguration extends AbstractConfiguration {
@UriParam
private Long dataLength;
- @UriParam
- private boolean publicForRead;
-
@UriParam(label = "producer")
private String blobPrefix;
+ @UriParam
+ private boolean publicForRead;
+
@UriParam(label = "producer", defaultValue = "true")
private boolean useFlatListing = true;
@@ -77,7 +77,7 @@ public class BlobServiceConfiguration extends AbstractConfiguration {
}
/**
- * Required blob service operation hint to the producer
+ * Blob service operation hint to the producer
*/
public void setOperation(BlobServiceOperations operation) {
this.operation = operation;
@@ -215,18 +215,6 @@ public class BlobServiceConfiguration extends AbstractConfiguration {
this.dataLength = dataLength;
}
- public boolean isPublicForRead() {
- return publicForRead;
- }
-
- /**
- * Blobs can be public for reading their content, if this property is enabled
- * then the credentials do not have to be set
- */
- public void setPublicForRead(boolean publicForRead) {
- this.publicForRead = publicForRead;
- }
-
public String getBlobPrefix() {
return blobPrefix;
}
@@ -237,6 +225,18 @@ public class BlobServiceConfiguration extends AbstractConfiguration {
public void setBlobPrefix(String blobPrefix) {
this.blobPrefix = blobPrefix;
}
+
+ public boolean isPublicForRead() {
+ return publicForRead;
+ }
+
+ /**
+ * Storage resources can be public for reading their content, if this property is enabled
+ * then the credentials do not have to be set
+ */
+ public void setPublicForRead(boolean publicForRead) {
+ this.publicForRead = publicForRead;
+ }
public boolean isUseFlatListing() {
return useFlatListing;
http://git-wip-us.apache.org/repos/asf/camel/blob/1b40de61/components/camel-azure/src/main/java/org/apache/camel/component/azure/common/AbstractConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-azure/src/main/java/org/apache/camel/component/azure/common/AbstractConfiguration.java b/components/camel-azure/src/main/java/org/apache/camel/component/azure/common/AbstractConfiguration.java
index c230044..6f69d5b 100644
--- a/components/camel-azure/src/main/java/org/apache/camel/component/azure/common/AbstractConfiguration.java
+++ b/components/camel-azure/src/main/java/org/apache/camel/component/azure/common/AbstractConfiguration.java
@@ -48,5 +48,4 @@ public abstract class AbstractConfiguration implements Cloneable {
public void setCredentials(StorageCredentials credentials) {
this.credentials = credentials;
}
-
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/1b40de61/components/camel-azure/src/test/java/org/apache/camel/component/azure/blob/BlobServiceComponentConfigurationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-azure/src/test/java/org/apache/camel/component/azure/blob/BlobServiceComponentConfigurationTest.java b/components/camel-azure/src/test/java/org/apache/camel/component/azure/blob/BlobServiceComponentConfigurationTest.java
index 326a4e8..b9195e3 100644
--- a/components/camel-azure/src/test/java/org/apache/camel/component/azure/blob/BlobServiceComponentConfigurationTest.java
+++ b/components/camel-azure/src/test/java/org/apache/camel/component/azure/blob/BlobServiceComponentConfigurationTest.java
@@ -226,6 +226,17 @@ public class BlobServiceComponentConfigurationTest extends CamelTestSupport {
}
}
+ @Test
+ public void testTooFewPathSegments() throws Exception {
+ BlobServiceComponent component = new BlobServiceComponent(context);
+ try {
+ component.createEndpoint("azure-blob://camelazure");
+ fail();
+ } catch (IllegalArgumentException ex) {
+ assertEquals("At least the account and container names must be specified.", ex.getMessage());
+ }
+ }
+
private static void createConsumer(Endpoint endpoint) throws Exception {
endpoint.createConsumer(new Processor() {
@Override
http://git-wip-us.apache.org/repos/asf/camel/blob/1b40de61/platforms/spring-boot/components-starter/camel-azure-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-azure-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/platforms/spring-boot/components-starter/camel-azure-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
index b9abe08..4b5841a 100644
--- a/platforms/spring-boot/components-starter/camel-azure-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
+++ b/platforms/spring-boot/components-starter/camel-azure-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
@@ -5,6 +5,12 @@
"name": "camel.component.azure-blob.enabled",
"description": "Enable azure-blob component",
"type": "java.lang.Boolean"
+ },
+ {
+ "defaultValue": true,
+ "name": "camel.component.azure-queue.enabled",
+ "description": "Enable azure-queue component",
+ "type": "java.lang.Boolean"
}
]
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/1b40de61/platforms/spring-boot/components-starter/camel-azure-starter/src/main/resources/META-INF/spring.factories
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-azure-starter/src/main/resources/META-INF/spring.factories b/platforms/spring-boot/components-starter/camel-azure-starter/src/main/resources/META-INF/spring.factories
index 7ecd61b..5b8a773 100644
--- a/platforms/spring-boot/components-starter/camel-azure-starter/src/main/resources/META-INF/spring.factories
+++ b/platforms/spring-boot/components-starter/camel-azure-starter/src/main/resources/META-INF/spring.factories
@@ -16,4 +16,6 @@
#
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
-org.apache.camel.component.azure.blob.springboot.BlobServiceComponentAutoConfiguration
+org.apache.camel.component.azure.blob.springboot.BlobServiceComponentAutoConfiguration,\
+org.apache.camel.component.azure.blob.springboot.QueueServiceComponentAutoConfiguration
+
[2/2] camel git commit: [CAMEL-10786] Adding the missing resources
Posted by se...@apache.org.
[CAMEL-10786] Adding the missing resources
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/507e8b5f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/507e8b5f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/507e8b5f
Branch: refs/heads/master
Commit: 507e8b5f849e85f78548cba2acfd9341e5975b07
Parents: 1b40de6
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Tue Feb 21 12:43:51 2017 +0000
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Tue Feb 21 12:43:51 2017 +0000
----------------------------------------------------------------------
.../azure/queue/QueueServiceComponent.java | 70 ++++++++++
.../azure/queue/QueueServiceConfiguration.java | 66 ++++++++++
.../azure/queue/QueueServiceConstants.java | 28 ++++
.../azure/queue/QueueServiceConsumer.java | 68 ++++++++++
.../azure/queue/QueueServiceEndpoint.java | 83 ++++++++++++
.../azure/queue/QueueServiceOperations.java | 22 ++++
.../azure/queue/QueueServiceProducer.java | 93 ++++++++++++++
.../component/azure/queue/QueueServiceUtil.java | 67 ++++++++++
.../org/apache/camel/component/azure-queue | 18 +++
.../QueueServiceComponentConfigurationTest.java | 128 +++++++++++++++++++
.../azure/queue/QueueServiceUtilTest.java | 88 +++++++++++++
.../QueueServiceComponentAutoConfiguration.java | 80 ++++++++++++
12 files changed, 811 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/507e8b5f/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceComponent.java b/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceComponent.java
new file mode 100644
index 0000000..42bd47d
--- /dev/null
+++ b/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceComponent.java
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.azure.queue;
+
+import java.util.Map;
+
+import com.microsoft.azure.storage.StorageCredentials;
+import com.microsoft.azure.storage.queue.CloudQueue;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.UriEndpointComponent;
+
+public class QueueServiceComponent extends UriEndpointComponent {
+
+ public QueueServiceComponent() {
+ super(QueueServiceEndpoint.class);
+ }
+
+ public QueueServiceComponent(CamelContext context) {
+ super(context, QueueServiceEndpoint.class);
+ }
+
+ protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+ QueueServiceConfiguration configuration = new QueueServiceConfiguration();
+ setProperties(configuration, parameters);
+
+ String[] parts = null;
+ if (remaining != null) {
+ parts = remaining.split("/");
+ }
+ if (parts == null || parts.length < 2) {
+ throw new IllegalArgumentException("The account and queue names must be specified.");
+ }
+ if (parts.length > 2) {
+ throw new IllegalArgumentException("Only the account and queue names must be specified.");
+ }
+
+ configuration.setAccountName(parts[0]);
+ configuration.setQueueName(parts[1]);
+
+ checkCredentials(configuration);
+
+ QueueServiceEndpoint endpoint = new QueueServiceEndpoint(uri, this, configuration);
+ setProperties(endpoint, parameters);
+ return endpoint;
+ }
+
+ private void checkCredentials(QueueServiceConfiguration cfg) {
+ CloudQueue client = cfg.getAzureQueueClient();
+ StorageCredentials creds = client == null ? cfg.getCredentials()
+ : client.getServiceClient().getCredentials();
+ if (creds == null) {
+ throw new IllegalArgumentException("Credentials must be specified.");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/507e8b5f/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceConfiguration.java b/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceConfiguration.java
new file mode 100644
index 0000000..d211d7e
--- /dev/null
+++ b/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceConfiguration.java
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.azure.queue;
+
+import com.microsoft.azure.storage.queue.CloudQueue;
+import org.apache.camel.component.azure.common.AbstractConfiguration;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriParams;
+
+@UriParams
+public class QueueServiceConfiguration extends AbstractConfiguration {
+
+ private String queueName;
+ @UriParam
+ private CloudQueue azureQueueClient;
+
+ @UriParam(label = "producer", defaultValue = "getMessage")
+ private QueueServiceOperations operation = QueueServiceOperations.getMessage;
+
+ public String getQueueName() {
+ return queueName;
+ }
+
+ /**
+ * The queue resource name
+ */
+ public void setQueueName(String queueName) {
+ this.queueName = queueName;
+ }
+
+ public CloudQueue getAzureQueueClient() {
+ return azureQueueClient;
+ }
+
+ /**
+ * The queue service client
+ */
+ public void setAzureQueueClient(CloudQueue azureQueueClient) {
+ this.azureQueueClient = azureQueueClient;
+ }
+
+ public QueueServiceOperations getOperation() {
+ return operation;
+ }
+
+ /**
+ * Queue service operation hint to the producer
+ */
+ public void setOperation(QueueServiceOperations operation) {
+ this.operation = operation;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/507e8b5f/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceConstants.java
----------------------------------------------------------------------
diff --git a/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceConstants.java b/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceConstants.java
new file mode 100644
index 0000000..0e7a523
--- /dev/null
+++ b/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceConstants.java
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.azure.queue;
+
+public interface QueueServiceConstants {
+
+ String OPERATION = "operation";
+ String QUEUE_CLIENT = "AzureQueueClient";
+
+ String SERVICE_URI_SEGMENT = ".queue.core.windows.net";
+ String ACCESS_CONDITION = "BlobAccessCondition";
+ String BLOB_REQUEST_OPTIONS = "BlobRequestOptions";
+ String OPERATION_CONTEXT = "BlobOperationContext";
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/507e8b5f/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceConsumer.java b/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceConsumer.java
new file mode 100644
index 0000000..9793a1c
--- /dev/null
+++ b/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceConsumer.java
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.azure.queue;
+
+import com.microsoft.azure.storage.StorageException;
+import org.apache.camel.Exchange;
+import org.apache.camel.NoFactoryAvailableException;
+import org.apache.camel.Processor;
+import org.apache.camel.impl.ScheduledPollConsumer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A Consumer of the queue content from the Azure Queue Service
+ */
+public class QueueServiceConsumer extends ScheduledPollConsumer {
+ private static final Logger LOG = LoggerFactory.getLogger(QueueServiceConsumer.class);
+
+ public QueueServiceConsumer(QueueServiceEndpoint endpoint, Processor processor) throws NoFactoryAvailableException {
+ super(endpoint, processor);
+ }
+
+ @Override
+ protected int poll() throws Exception {
+ Exchange exchange = super.getEndpoint().createExchange();
+ try {
+ getMessage(exchange);
+ super.getAsyncProcessor().process(exchange);
+ return 1;
+ } catch (StorageException ex) {
+ if (404 == ex.getHttpStatusCode()) {
+ return 0;
+ } else {
+ throw ex;
+ }
+ }
+ }
+
+ private void getMessage(Exchange exchange) throws Exception {
+ LOG.trace("Getting the message from the queue [{}] from exchange [{}]...",
+ getConfiguration().getQueueName(), exchange);
+ throw new UnsupportedOperationException();
+ }
+
+ protected QueueServiceConfiguration getConfiguration() {
+ return getEndpoint().getConfiguration();
+ }
+
+ @Override
+ public QueueServiceEndpoint getEndpoint() {
+ return (QueueServiceEndpoint) super.getEndpoint();
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/507e8b5f/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceEndpoint.java b/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceEndpoint.java
new file mode 100644
index 0000000..3f70804
--- /dev/null
+++ b/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceEndpoint.java
@@ -0,0 +1,83 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.azure.queue;
+
+import org.apache.camel.Component;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.azure.blob.BlobServiceConfiguration;
+import org.apache.camel.component.azure.blob.BlobServiceConsumer;
+import org.apache.camel.component.azure.blob.BlobServiceOperations;
+import org.apache.camel.component.azure.blob.BlobServiceProducer;
+import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The azure-queue component is used for storing and retrieving messages from Azure Storage Queue Service.
+ */
+@UriEndpoint(firstVersion = "2.19.0",
+ scheme = "azure-queue",
+ title = "Azure Storage Queue Service",
+ syntax = "azure-blob:queueOrMessageUri",
+ consumerClass = QueueServiceConsumer.class,
+ label = "cloud,queue,azure")
+public class QueueServiceEndpoint extends DefaultEndpoint {
+
+ private static final Logger LOG = LoggerFactory.getLogger(QueueServiceEndpoint.class);
+
+ @UriPath(description = "Queue or Message compact Uri")
+ @Metadata(required = "true")
+ private String queueOrMessageUri; // to support component docs
+ @UriParam
+ private QueueServiceConfiguration configuration;
+
+ public QueueServiceEndpoint(String uri, Component comp, QueueServiceConfiguration configuration) {
+ super(uri, comp);
+ this.configuration = configuration;
+ }
+
+ public Consumer createConsumer(Processor processor) throws Exception {
+ LOG.trace("Creating a consumer");
+ QueueServiceConsumer consumer = new QueueServiceConsumer(this, processor);
+ configureConsumer(consumer);
+ return consumer;
+ }
+
+ public Producer createProducer() throws Exception {
+ LOG.trace("Creating a producer");
+ return new QueueServiceProducer(this);
+ }
+
+ public boolean isSingleton() {
+ return true;
+ }
+
+ public QueueServiceConfiguration getConfiguration() {
+ return configuration;
+ }
+
+ public void setConfiguration(QueueServiceConfiguration configuration) {
+ this.configuration = configuration;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/507e8b5f/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceOperations.java
----------------------------------------------------------------------
diff --git a/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceOperations.java b/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceOperations.java
new file mode 100644
index 0000000..a1e0898
--- /dev/null
+++ b/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceOperations.java
@@ -0,0 +1,22 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.azure.queue;
+
+public enum QueueServiceOperations {
+ getMessage,
+ putMessage
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/507e8b5f/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceProducer.java b/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceProducer.java
new file mode 100644
index 0000000..434ed2d
--- /dev/null
+++ b/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceProducer.java
@@ -0,0 +1,93 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.azure.queue;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.azure.blob.BlobServiceConstants;
+import org.apache.camel.impl.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.URISupport;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A Producer which sends messages to the Azure Storage Queue Service
+ */
+public class QueueServiceProducer extends DefaultProducer {
+
+ private static final Logger LOG = LoggerFactory.getLogger(QueueServiceProducer.class);
+
+ public QueueServiceProducer(final Endpoint endpoint) {
+ super(endpoint);
+ }
+
+ @Override
+ public void process(final Exchange exchange) throws Exception {
+ QueueServiceOperations operation = determineOperation(exchange);
+ if (ObjectHelper.isEmpty(operation)) {
+ operation = QueueServiceOperations.getMessage;
+ } else {
+ switch (operation) {
+ case getMessage:
+ getMessage(exchange);
+ break;
+ case putMessage:
+ putMessage(exchange);
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported operation");
+ }
+ }
+
+ }
+
+ private void getMessage(Exchange exchange) {
+ LOG.trace("Getting the message from the queue [{}] from exchange [{}]...",
+ getConfiguration().getQueueName(), exchange);
+ throw new UnsupportedOperationException();
+ }
+ private void putMessage(Exchange exchange) {
+ LOG.trace("Putting the message into the queue [{}] from exchange [{}]...",
+ getConfiguration().getQueueName(), exchange);
+ throw new UnsupportedOperationException();
+ }
+
+ private QueueServiceOperations determineOperation(Exchange exchange) {
+ QueueServiceOperations operation = exchange.getIn().getHeader(BlobServiceConstants.OPERATION,
+ QueueServiceOperations.class);
+ if (operation == null) {
+ operation = getConfiguration().getOperation();
+ }
+ return operation;
+ }
+
+ protected QueueServiceConfiguration getConfiguration() {
+ return getEndpoint().getConfiguration();
+ }
+
+ @Override
+ public String toString() {
+ return "StorageQueueProducer[" + URISupport.sanitizeUri(getEndpoint().getEndpointUri()) + "]";
+ }
+
+ @Override
+ public QueueServiceEndpoint getEndpoint() {
+ return (QueueServiceEndpoint) super.getEndpoint();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/507e8b5f/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceUtil.java
----------------------------------------------------------------------
diff --git a/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceUtil.java b/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceUtil.java
new file mode 100644
index 0000000..17121b0
--- /dev/null
+++ b/components/camel-azure/src/main/java/org/apache/camel/component/azure/queue/QueueServiceUtil.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.azure.queue;
+
+import java.net.URI;
+
+import com.microsoft.azure.storage.StorageCredentials;
+import com.microsoft.azure.storage.queue.CloudQueue;
+
+public final class QueueServiceUtil {
+ private QueueServiceUtil() {
+ }
+
+ public static URI prepareStorageQueueUri(QueueServiceConfiguration cfg) {
+ return prepareStorageQueueUri(cfg, true);
+ }
+
+ public static URI prepareStorageQueueUri(QueueServiceConfiguration cfg, boolean isForMessages) {
+ StringBuilder uriBuilder = new StringBuilder();
+ uriBuilder.append("https://")
+ .append(cfg.getAccountName())
+ .append(QueueServiceConstants.SERVICE_URI_SEGMENT)
+ .append("/")
+ .append(cfg.getQueueName());
+ if (isForMessages) {
+ uriBuilder.append("/messages");
+ }
+ return URI.create(uriBuilder.toString());
+ }
+
+ public static CloudQueue createQueueClient(QueueServiceConfiguration cfg)
+ throws Exception {
+ CloudQueue client = (CloudQueue) getConfiguredClient(cfg);
+ if (client == null) {
+ URI uri = prepareStorageQueueUri(cfg);
+ StorageCredentials creds = getAccountCredentials(cfg);
+ client = new CloudQueue(uri, creds);
+ }
+ return client;
+ }
+
+ public static CloudQueue getConfiguredClient(QueueServiceConfiguration cfg) {
+ CloudQueue client = cfg.getAzureQueueClient();
+ if (client != null && !client.getUri().equals(prepareStorageQueueUri(cfg))) {
+ throw new IllegalArgumentException("Invalid Client URI");
+ }
+ return client;
+ }
+
+ public static StorageCredentials getAccountCredentials(QueueServiceConfiguration cfg) {
+ return cfg.getCredentials();
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/507e8b5f/components/camel-azure/src/main/resources/META-INF/services/org/apache/camel/component/azure-queue
----------------------------------------------------------------------
diff --git a/components/camel-azure/src/main/resources/META-INF/services/org/apache/camel/component/azure-queue b/components/camel-azure/src/main/resources/META-INF/services/org/apache/camel/component/azure-queue
new file mode 100644
index 0000000..debd117
--- /dev/null
+++ b/components/camel-azure/src/main/resources/META-INF/services/org/apache/camel/component/azure-queue
@@ -0,0 +1,18 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+class=org.apache.camel.component.azure.queue.QueueServiceComponent
http://git-wip-us.apache.org/repos/asf/camel/blob/507e8b5f/components/camel-azure/src/test/java/org/apache/camel/component/azure/queue/QueueServiceComponentConfigurationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-azure/src/test/java/org/apache/camel/component/azure/queue/QueueServiceComponentConfigurationTest.java b/components/camel-azure/src/test/java/org/apache/camel/component/azure/queue/QueueServiceComponentConfigurationTest.java
new file mode 100644
index 0000000..800aebc
--- /dev/null
+++ b/components/camel-azure/src/test/java/org/apache/camel/component/azure/queue/QueueServiceComponentConfigurationTest.java
@@ -0,0 +1,128 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.azure.queue;
+
+import java.net.URI;
+
+import com.microsoft.azure.storage.StorageCredentials;
+import com.microsoft.azure.storage.StorageCredentialsAccountAndKey;
+import com.microsoft.azure.storage.core.Base64;
+import com.microsoft.azure.storage.queue.CloudQueue;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.impl.PropertyPlaceholderDelegateRegistry;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class QueueServiceComponentConfigurationTest extends CamelTestSupport {
+
+ @Test
+ public void testCreateEndpointWithMinConfigForClientOnly() throws Exception {
+ CloudQueue client =
+ new CloudQueue(URI.create("https://camelazure.queue.core.windows.net/testqueue/messages"),
+ newAccountKeyCredentials());
+
+ JndiRegistry registry = (JndiRegistry) ((PropertyPlaceholderDelegateRegistry) context.getRegistry()).getRegistry();
+ registry.bind("azureQueueClient", client);
+
+ QueueServiceComponent component = new QueueServiceComponent(context);
+ QueueServiceEndpoint endpoint =
+ (QueueServiceEndpoint) component.createEndpoint("azure-queue://camelazure/testqueue?azureQueueClient=#azureQueueClient");
+
+ doTestCreateEndpointWithMinConfig(endpoint, true);
+ }
+
+ @Test
+ public void testCreateEndpointWithMinConfigForCredsOnly() throws Exception {
+ registerCredentials();
+
+ QueueServiceComponent component = new QueueServiceComponent(context);
+ QueueServiceEndpoint endpoint =
+ (QueueServiceEndpoint) component.createEndpoint("azure-queue://camelazure/testqueue?credentials=#creds");
+
+ doTestCreateEndpointWithMinConfig(endpoint, false);
+ }
+
+ private void doTestCreateEndpointWithMinConfig(QueueServiceEndpoint endpoint, boolean clientExpected)
+ throws Exception {
+ assertEquals("camelazure", endpoint.getConfiguration().getAccountName());
+ assertEquals("testqueue", endpoint.getConfiguration().getQueueName());
+ if (clientExpected) {
+ assertNotNull(endpoint.getConfiguration().getAzureQueueClient());
+ assertNull(endpoint.getConfiguration().getCredentials());
+ } else {
+ assertNull(endpoint.getConfiguration().getAzureQueueClient());
+ assertNotNull(endpoint.getConfiguration().getCredentials());
+ }
+ createConsumer(endpoint);
+ }
+
+ @Test
+ public void testNoCredentials() throws Exception {
+ QueueServiceComponent component = new QueueServiceComponent(context);
+ try {
+ component.createEndpoint("azure-queue://camelazure/testqueue");
+ fail();
+ } catch (IllegalArgumentException ex) {
+ assertEquals("Credentials must be specified.", ex.getMessage());
+ }
+ }
+
+ @Test
+ public void testTooManyPathSegments() throws Exception {
+ QueueServiceComponent component = new QueueServiceComponent(context);
+ try {
+ component.createEndpoint("azure-queue://camelazure/testqueue/1");
+ fail();
+ } catch (IllegalArgumentException ex) {
+ assertEquals("Only the account and queue names must be specified.", ex.getMessage());
+ }
+ }
+
+ @Test
+ public void testTooFewPathSegments() throws Exception {
+ QueueServiceComponent component = new QueueServiceComponent(context);
+ try {
+ component.createEndpoint("azure-queue://camelazure");
+ fail();
+ } catch (IllegalArgumentException ex) {
+ assertEquals("The account and queue names must be specified.", ex.getMessage());
+ }
+ }
+
+
+ private static void createConsumer(Endpoint endpoint) throws Exception {
+ endpoint.createConsumer(new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ // noop
+ }
+ });
+ }
+
+ private void registerCredentials() {
+ JndiRegistry registry = (JndiRegistry) ((PropertyPlaceholderDelegateRegistry) context.getRegistry()).getRegistry();
+ registry.bind("creds", newAccountKeyCredentials());
+ }
+ private StorageCredentials newAccountKeyCredentials() {
+ return new StorageCredentialsAccountAndKey("camelazure",
+ Base64.encode("key".getBytes()));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/507e8b5f/components/camel-azure/src/test/java/org/apache/camel/component/azure/queue/QueueServiceUtilTest.java
----------------------------------------------------------------------
diff --git a/components/camel-azure/src/test/java/org/apache/camel/component/azure/queue/QueueServiceUtilTest.java b/components/camel-azure/src/test/java/org/apache/camel/component/azure/queue/QueueServiceUtilTest.java
new file mode 100644
index 0000000..40bf2a4
--- /dev/null
+++ b/components/camel-azure/src/test/java/org/apache/camel/component/azure/queue/QueueServiceUtilTest.java
@@ -0,0 +1,88 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.azure.queue;
+
+import java.net.URI;
+
+import com.microsoft.azure.storage.StorageCredentials;
+import com.microsoft.azure.storage.StorageCredentialsAccountAndKey;
+import com.microsoft.azure.storage.core.Base64;
+import com.microsoft.azure.storage.queue.CloudQueue;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.impl.PropertyPlaceholderDelegateRegistry;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class QueueServiceUtilTest extends CamelTestSupport {
+
+ @Test
+ public void testPrepareUri() throws Exception {
+ registerCredentials();
+
+ QueueServiceComponent component = new QueueServiceComponent(context);
+ QueueServiceEndpoint endpoint =
+ (QueueServiceEndpoint) component.createEndpoint("azure-queue://camelazure/testqueue?credentials=#creds");
+ URI uri =
+ QueueServiceUtil.prepareStorageQueueUri(endpoint.getConfiguration());
+ assertEquals("https://camelazure.queue.core.windows.net/testqueue/messages", uri.toString());
+ }
+
+ @Test
+ public void testGetConfiguredClient() throws Exception {
+ CloudQueue client =
+ new CloudQueue(URI.create("https://camelazure.queue.core.windows.net/testqueue/messages"),
+ newAccountKeyCredentials());
+
+ JndiRegistry registry = (JndiRegistry) ((PropertyPlaceholderDelegateRegistry) context.getRegistry()).getRegistry();
+ registry.bind("azureQueueClient", client);
+
+ QueueServiceComponent component = new QueueServiceComponent(context);
+ QueueServiceEndpoint endpoint =
+ (QueueServiceEndpoint) component.createEndpoint("azure-queue://camelazure/testqueue?azureQueueClient=#azureQueueClient");
+ assertSame(client, QueueServiceUtil.getConfiguredClient(endpoint.getConfiguration()));
+ }
+ @Test
+ public void testGetConfiguredClientUriMismatch() throws Exception {
+ CloudQueue client =
+ new CloudQueue(URI.create("https://camelazure.queue.core.windows.net/testqueue"),
+ newAccountKeyCredentials());
+
+ JndiRegistry registry = (JndiRegistry) ((PropertyPlaceholderDelegateRegistry) context.getRegistry()).getRegistry();
+ registry.bind("azureQueueClient", client);
+
+ QueueServiceComponent component = new QueueServiceComponent(context);
+ QueueServiceEndpoint endpoint =
+ (QueueServiceEndpoint) component.createEndpoint("azure-queue://camelazure/testqueue2?azureQueueClient=#azureQueueClient");
+
+ try {
+ QueueServiceUtil.getConfiguredClient(endpoint.getConfiguration());
+ fail();
+ } catch (IllegalArgumentException ex) {
+ assertEquals("Invalid Client URI", ex.getMessage());
+ }
+ }
+
+ private void registerCredentials() {
+ JndiRegistry registry = (JndiRegistry) ((PropertyPlaceholderDelegateRegistry) context.getRegistry()).getRegistry();
+ registry.bind("creds", newAccountKeyCredentials());
+ }
+
+ private StorageCredentials newAccountKeyCredentials() {
+ return new StorageCredentialsAccountAndKey("camelazure",
+ Base64.encode("key".getBytes()));
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/507e8b5f/platforms/spring-boot/components-starter/camel-azure-starter/src/main/java/org/apache/camel/component/azure/queue/springboot/QueueServiceComponentAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-azure-starter/src/main/java/org/apache/camel/component/azure/queue/springboot/QueueServiceComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-azure-starter/src/main/java/org/apache/camel/component/azure/queue/springboot/QueueServiceComponentAutoConfiguration.java
new file mode 100644
index 0000000..a929af0
--- /dev/null
+++ b/platforms/spring-boot/components-starter/camel-azure-starter/src/main/java/org/apache/camel/component/azure/queue/springboot/QueueServiceComponentAutoConfiguration.java
@@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.azure.queue.springboot;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.azure.queue.QueueServiceComponent;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionMessage;
+import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
+import org.springframework.boot.bind.RelaxedPropertyResolver;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ConditionContext;
+import org.springframework.context.annotation.Conditional;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.core.type.AnnotatedTypeMetadata;
+
+/**
+ * Generated by camel-package-maven-plugin - do not edit this file!
+ */
+@Configuration
+@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration")
+@Conditional(QueueServiceComponentAutoConfiguration.Condition.class)
+@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration")
+public class QueueServiceComponentAutoConfiguration {
+
+ @Lazy
+ @Bean(name = "azure-queue-component")
+ @ConditionalOnClass(CamelContext.class)
+ @ConditionalOnMissingBean(QueueServiceComponent.class)
+ public QueueServiceComponent configureQueueServiceComponent(
+ CamelContext camelContext) throws Exception {
+ QueueServiceComponent component = new QueueServiceComponent();
+ component.setCamelContext(camelContext);
+ return component;
+ }
+
+ public static class Condition extends SpringBootCondition {
+ @Override
+ public ConditionOutcome getMatchOutcome(
+ ConditionContext conditionContext,
+ AnnotatedTypeMetadata annotatedTypeMetadata) {
+ boolean groupEnabled = isEnabled(conditionContext,
+ "camel.component.", true);
+ ConditionMessage.Builder message = ConditionMessage
+ .forCondition("camel.component.azure-queue");
+ if (isEnabled(conditionContext, "camel.component.azure-queue.",
+ groupEnabled)) {
+ return ConditionOutcome.match(message.because("enabled"));
+ }
+ return ConditionOutcome.noMatch(message.because("not enabled"));
+ }
+
+ private boolean isEnabled(
+ org.springframework.context.annotation.ConditionContext context,
+ java.lang.String prefix, boolean defaultValue) {
+ RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
+ context.getEnvironment(), prefix);
+ return resolver.getProperty("enabled", Boolean.class, defaultValue);
+ }
+ }
+}
\ No newline at end of file