oscerd commented on a change in pull request #3897:
URL: https://github.com/apache/camel/pull/3897#discussion_r445311790



##########
File path: 
components/camel-minio/src/main/java/org/apache/camel/component/minio/MinioConsumer.java
##########
@@ -0,0 +1,286 @@
+/*
+ * 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.minio;
+
+import java.io.InputStream;
+import java.util.*;
+
+import io.minio.MinioClient;
+import io.minio.Result;
+import io.minio.errors.MinioException;
+import io.minio.messages.Item;
+import org.apache.camel.*;
+import org.apache.camel.spi.Synchronization;
+import org.apache.camel.support.ScheduledBatchPollingConsumer;
+import org.apache.camel.util.CastUtils;
+import org.apache.camel.util.IOHelper;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.URISupport;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A Consumer of messages from the Minio Storage Service.
+ */
+public class MinioConsumer extends ScheduledBatchPollingConsumer {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(MinioConsumer.class);
+
+    private Iterator<Result<Item>> marker;
+    private transient String minioConsumerToString;
+
+    public MinioConsumer(MinioEndpoint endpoint, Processor processor) throws 
NoFactoryAvailableException {
+        super(endpoint, processor);
+    }
+
+    @Override
+    protected int poll() throws Exception {
+        // must reset for each poll
+        shutdownRunningTask = null;
+        pendingExchanges = 0;
+
+        MinioClient minioClient = getConfiguration().getMinioClient();
+        String objectName = getConfiguration().getObjectName();
+        String bucketName = getConfiguration().getBucketName();
+        Queue<Exchange> exchanges = null;
+
+        if (objectName != null) {
+            LOG.trace("Getting object in bucket [{}] with object name 
[{}]...", bucketName, objectName);
+
+            try {
+                InputStream stream = minioClient.getObject(bucketName,
+                        objectName,
+                        getConfiguration().getOffset(),
+                        getConfiguration().getLength(),
+                        getConfiguration().getServerSideEncryption());
+
+                exchanges = createExchanges(stream, objectName);
+            } catch (Exception e) {
+                LOG.trace("Failed to get object in bucket [{}] with object 
name [{}], Error message [{}]", bucketName, objectName, e);
+            }
+
+        } else {
+
+            LOG.trace("Queueing objects in bucket [{}]...", bucketName);
+
+            Iterable<Result<Item>> results = 
minioClient.listObjects(bucketName,

Review comment:
       Not all the objects in one call, you need to define a limit for the 
batch, like setMaxKeys in AWS2 S3 component 
https://github.com/apache/camel/blob/master/components/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Consumer.java#L88
   
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to