[ 
https://issues.apache.org/jira/browse/CAMEL-11250?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16288877#comment-16288877
 ] 

ASF GitHub Bot commented on CAMEL-11250:
----------------------------------------

davsclaus commented on a change in pull request #2123: CAMEL-11250: File name 
pattern and file predicate for poll enrich use.
URL: https://github.com/apache/camel/pull/2123#discussion_r156590121
 
 

 ##########
 File path: 
camel-core/src/test/java/org/apache/camel/component/file/FileConsumePollEnrichFilePredicateTest.java
 ##########
 @@ -0,0 +1,75 @@
+/**
+ * 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.file;
+
+import java.util.function.Predicate;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+public class FileConsumePollEnrichFilePredicateTest extends ContextTestSupport 
{
+
+    @Override
+    protected void setUp() throws Exception {
+        deleteDirectory("target/enrich");
+        deleteDirectory("target/enrichdata");
+        super.setUp();
+    }
+
+    public void testPollEnrichFileReject() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.expectedBodiesReceived((Object) null);
+
+        template.sendBody("seda:start", "Start");
+        log.info("Sleeping for 1/4 sec before writing enrichdata file");
+        Thread.sleep(250);
+        template.sendBodyAndHeader("file://target/enrichdata", "O", 
Exchange.FILE_NAME, "AAA.dat");
+        log.info("... write done");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testPollEnrichFileAccept() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.expectedBodiesReceived("Hi Camel!");
+
+        template.sendBody("seda:start", "Start");
+        log.info("Sleeping for 1/4 sec before writing enrichdata file");
+        Thread.sleep(250);
+        template.sendBodyAndHeader("file://target/enrichdata", "Hi Camel!", 
Exchange.FILE_NAME, "AAA.dat");
+        log.info("... write done");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("seda:start")
+                    .setHeader(Exchange.FILE_PREDICATE, () -> 
(Predicate<GenericFile>) genericFile -> genericFile.getFileLength() > 4)
 
 Review comment:
   No I dont think we should complicate things even more, lets close this PR 
and the JIRA ticket at this moment.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


> File consumer - Allow to specify a header that has the file name to poll
> ------------------------------------------------------------------------
>
>                 Key: CAMEL-11250
>                 URL: https://issues.apache.org/jira/browse/CAMEL-11250
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Claus Ibsen
>             Fix For: Future
>
>
> See SO
> http://stackoverflow.com/questions/43849165/camel-pollenrich-generating-a-lot-of-timed-waiting-threads
> We can have a FILE_FILTER_NAME header that matches in the 
> org.apache.camel.component.file.GenericFileConsumer#isMatched(org.apache.camel.component.file.GenericFile<T>,
>  boolean, java.util.List<T>)
> so end users can set the header first and then do a pollEnrich with a static 
> endpoint.
> The header can then use equalsIgnoreCase and reguar exp for matching, to make 
> it easier to match files.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to