This is an automated email from the ASF dual-hosted git repository.

oalsafi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-examples.git


The following commit(s) were added to refs/heads/master by this push:
     new 386b8de  Add an example of list large azure storage blob container. 
(#32)
386b8de is described below

commit 386b8de50f5dbb7e3f0160177883abf05e8d8a3d
Author: Mark Andreev <mrk.andreev+git...@yandex.ru>
AuthorDate: Tue Jan 26 20:24:48 2021 +0300

    Add an example of list large azure storage blob container. (#32)
---
 examples/README.adoc                               |   2 +
 .../camel-example-azure-storage-blob/README.adoc   |  47 ++++++++++
 examples/camel-example-azure-storage-blob/pom.xml  | 103 +++++++++++++++++++++
 .../example/azurestorageblob/Application.java      |  80 ++++++++++++++++
 .../src/main/resources/log4j2.properties           |  23 +++++
 examples/pom.xml                                   |   1 +
 6 files changed, 256 insertions(+)

diff --git a/examples/README.adoc b/examples/README.adoc
index 8c15fae..bd5e49e 100644
--- a/examples/README.adoc
+++ b/examples/README.adoc
@@ -76,6 +76,8 @@ Number of Examples: 86 (0 deprecated)
 
 | link:camel-example-ssh/README.adoc[Ssh] (camel-example-ssh) | Beginner | An 
example that uses Camel SSH component
 
+| link:camel-example-azure-storage-blob/README.adoc[Azure Storage Blob List] 
(camel-example-azure-storage-blob) | Beginner | An example that uses Camel 
Azure Storage Blob and explain how list large blob container.
+
 | link:camel-example-cassandra-kubernetes/README.adoc[Cassandra Kubernetes] 
(camel-example-cassandra-kubernetes) | Cloud | An example with Camel and 
Cassandra running on Kubernetes
 
 | link:camel-example-cdi-aws-s3/README.adoc[CDI AWS S3] 
(camel-example-cdi-aws-s3) | Cloud | AWS S3 CDI example
diff --git a/examples/camel-example-azure-storage-blob/README.adoc 
b/examples/camel-example-azure-storage-blob/README.adoc
new file mode 100644
index 0000000..7986864
--- /dev/null
+++ b/examples/camel-example-azure-storage-blob/README.adoc
@@ -0,0 +1,47 @@
+== Camel Basic Example
+
+=== Introduction
+
+This is a very basic example that shows how to list large azure storage blob 
container.
+
+This example shows you that Camel can be used in standalone mode
+as a _public static void main_ application.
+
+The example has only 1 java file in the `Application.java` located in the src 
folder.
+There is code comments explaining in more details.
+
+Set `ACCOUNT` & `ACCESS_KEY` & `BLOB_CONTAINER_NAME` for start example.
+
+=== Build
+
+You will need to compile this example first:
+
+....
+mvn compile
+....
+
+=== Run
+
+To run the example type
+
+....
+mvn camel:run
+....
+
+The
+
+To stop the example hit ctrl+c
+
+You can also run the example from your editor such as Eclipse, IDEA etc,
+by opening the org.apache.camel.example.basic.CamelBasic class
+and then right click, and chose run java application.
+
+=== Help and contributions
+
+If you hit any problem using Camel or have some feedback, then please
+https://camel.apache.org/support.html[let us know].
+
+We also love contributors, so
+https://camel.apache.org/contributing.html[get involved] :-)
+
+The Camel riders!
diff --git a/examples/camel-example-azure-storage-blob/pom.xml 
b/examples/camel-example-azure-storage-blob/pom.xml
new file mode 100644
index 0000000..183440f
--- /dev/null
+++ b/examples/camel-example-azure-storage-blob/pom.xml
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.camel.example</groupId>
+        <artifactId>examples</artifactId>
+        <version>3.8.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>camel-example-azure-storage-blob</artifactId>
+    <packaging>jar</packaging>
+    <name>Camel :: Example :: Azure Storage Blob</name>
+    <description>Azure Storage Blob example</description>
+
+    <properties>
+        <category>Beginner</category>
+    </properties>
+
+    <dependencyManagement>
+        <dependencies>
+            <!-- Add Camel BOM -->
+            <dependency>
+                <groupId>org.apache.camel</groupId>
+                <artifactId>camel-bom</artifactId>
+                <version>${camel.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-core</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-azure-storage-blob</artifactId>
+        </dependency>
+
+        <!-- logging -->
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-api</artifactId>
+            <scope>runtime</scope>
+            <version>${log4j2-version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-core</artifactId>
+            <scope>runtime</scope>
+            <version>${log4j2-version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-slf4j-impl</artifactId>
+            <scope>runtime</scope>
+            <version>${log4j2-version}</version>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+
+            <!-- Allows the routes to be run via 'mvn camel:run' -->
+            <plugin>
+                <groupId>org.apache.camel</groupId>
+                <artifactId>camel-maven-plugin</artifactId>
+                <version>${camel.version}</version>
+                <configuration>
+                    
<mainClass>org.apache.camel.example.azurestorageblob.Application</mainClass>
+                </configuration>
+            </plugin>
+
+        </plugins>
+
+    </build>
+
+</project>
diff --git 
a/examples/camel-example-azure-storage-blob/src/main/java/org/apache/camel/example/azurestorageblob/Application.java
 
b/examples/camel-example-azure-storage-blob/src/main/java/org/apache/camel/example/azurestorageblob/Application.java
new file mode 100644
index 0000000..17e15f1
--- /dev/null
+++ 
b/examples/camel-example-azure-storage-blob/src/main/java/org/apache/camel/example/azurestorageblob/Application.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.example.azurestorageblob;
+
+import com.azure.storage.blob.BlobServiceClientBuilder;
+import com.azure.storage.blob.models.ListBlobsOptions;
+import com.azure.storage.common.StorageSharedKeyCredential;
+import java.util.Iterator;
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.DefaultCamelContext;
+
+/**
+ * A basic example of list large azure blob storage.
+ */
+public final class Application {
+    private static final String ACCOUNT = "ENTER_YOUR_ACCOUNT";
+    private static final String ACCESS_KEY = "ACCESS_KEY";
+    private static final String BLOB_CONTAINER_NAME = "CONTAINER";
+
+    public static void main(String[] args) throws Exception {
+        // create a CamelContext
+        try (CamelContext camel = new DefaultCamelContext()) {
+
+            // add routes which can be inlined as anonymous inner class
+            // (to keep all code in a single java file for this basic example)
+            camel.addRoutes(new RouteBuilder() {
+                @Override
+                public void configure() throws Exception {
+                    from("timer://runOnce?repeatCount=1&delay=0")
+                        .routeId("listBlobs")
+                        .process(exchange -> exchange.getIn()
+                            .setBody(
+                                new BlobServiceClientBuilder()
+                                    
.endpoint(String.format("https://%s.blob.core.windows.net";, ACCOUNT))
+                                    .credential(new 
StorageSharedKeyCredential(ACCOUNT, ACCESS_KEY))
+                                    .buildClient()
+                                    
.getBlobContainerClient(BLOB_CONTAINER_NAME)
+                                    .listBlobs(
+                                        new 
ListBlobsOptions().setMaxResultsPerPage(1),
+                                        null
+                                    )
+                            )
+                        )
+                        .loopDoWhile(exchange ->
+                            exchange.getIn().getBody(Iterator.class).hasNext()
+                        )
+                        .process(exchange ->
+                            
exchange.getIn().setBody(exchange.getIn().getBody(Iterator.class).next())
+                        )
+                        .log("${body.name}")
+                        .end();
+                }
+            });
+
+            // start is not blocking
+            camel.start();
+
+            // so run for 10 seconds
+            Thread.sleep(10_000);
+
+            // and then stop nicely
+            camel.stop();
+        }
+    }
+}
diff --git 
a/examples/camel-example-azure-storage-blob/src/main/resources/log4j2.properties
 
b/examples/camel-example-azure-storage-blob/src/main/resources/log4j2.properties
new file mode 100644
index 0000000..d9f0508
--- /dev/null
+++ 
b/examples/camel-example-azure-storage-blob/src/main/resources/log4j2.properties
@@ -0,0 +1,23 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+appender.out.type = Console
+appender.out.name = out
+appender.out.layout.type = PatternLayout
+appender.out.layout.pattern = [%30.30t] %-30.30c{1} %-5p %m%n
+rootLogger.level = INFO
+rootLogger.appenderRef.out.ref = out
diff --git a/examples/pom.xml b/examples/pom.xml
index d3cff30..d203536 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -165,6 +165,7 @@
         <module>camel-example-widget-gadget-cdi</module>
         <module>camel-example-widget-gadget-java</module>
         <module>camel-example-widget-gadget-xml</module>
+        <module>camel-example-azure-storage-blob</module>
   </modules>
 
     <properties>

Reply via email to