Steve973 commented on code in PR #11906:
URL: https://github.com/apache/camel/pull/11906#discussion_r1383983952


##########
components/camel-dynamic-router/src/main/java/org/apache/camel/component/dynamicrouter/DynamicRouterMulticastProcessor.java:
##########
@@ -0,0 +1,292 @@
+/*
+ * 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.dynamicrouter;
+
+import java.util.*;
+import java.util.concurrent.ExecutorService;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
+
+import org.apache.camel.*;
+import org.apache.camel.processor.FilterProcessor;
+import org.apache.camel.processor.MulticastProcessor;
+import org.apache.camel.processor.ProcessorExchangePair;
+import org.apache.camel.spi.ProducerCache;
+import org.apache.camel.support.*;
+import org.apache.camel.support.service.ServiceHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static 
org.apache.camel.component.dynamicrouter.DynamicRouterConstants.MODE_FIRST_MATCH;
+
+public class DynamicRouterMulticastProcessor extends MulticastProcessor {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(DynamicRouterMulticastProcessor.class);
+
+    /**
+     * Template for a logging endpoint, showing all, and multiline.
+     */
+    private static final String LOG_ENDPOINT = 
"log:%s.%s?level=%s&showAll=true&multiline=true";
+
+    private boolean ignoreInvalidEndpoints;
+
+    private final ProducerCache producerCache;
+
+    /**
+     * {@link FilterProcessor}s, mapped by subscription ID, to determine if 
the incoming exchange should be routed based
+     * on the content.
+     */
+    private final TreeMap<String, PrioritizedFilter> filterMap;
+
+    /**
+     * Indicates the behavior of the Dynamic Router when routing participants 
are selected to receive an incoming
+     * exchange. If the mode is "firstMatch", then the exchange is routed only 
to the first participant that has a
+     * matching predicate. If the mode is "allMatch", then the exchange is 
routed to all participants that have a
+     * matching predicate.
+     */
+    private final String recipientMode;
+
+    /**
+     * The {@link FilterProcessor} factory.
+     */
+    private final Supplier<PrioritizedFilter.PrioritizedFilterFactory> 
filterProcessorFactorySupplier;
+
+    /**
+     * Flag to log a warning if a message is dropped due to no matching 
filters.
+     */
+    private final boolean warnDroppedMessage;
+
+    public DynamicRouterMulticastProcessor(String id, CamelContext 
camelContext, Route route, String recipientMode,
+                                           final boolean warnDroppedMessage,
+                                           final 
Supplier<PrioritizedFilter.PrioritizedFilterFactory> 
filterProcessorFactorySupplier,
+                                           ProducerCache producerCache, 
AggregationStrategy aggregationStrategy,
+                                           boolean parallelProcessing, 
ExecutorService executorService,
+                                           boolean shutdownExecutorService,
+                                           boolean streaming, boolean 
stopOnException,
+                                           long timeout, Processor onPrepare, 
boolean shareUnitOfWork,
+                                           boolean parallelAggregate) {
+        super(camelContext, route, new ArrayList<>(), aggregationStrategy, 
parallelProcessing, executorService,
+              shutdownExecutorService,
+              streaming, stopOnException, timeout, onPrepare,
+              shareUnitOfWork, parallelAggregate);
+        setId(id);
+        this.producerCache = producerCache;
+        this.filterMap = new TreeMap<>();
+        this.recipientMode = recipientMode;
+        this.filterProcessorFactorySupplier = filterProcessorFactorySupplier;
+        this.warnDroppedMessage = warnDroppedMessage;
+    }
+
+    public boolean isIgnoreInvalidEndpoints() {
+        return ignoreInvalidEndpoints;
+    }
+
+    public void setIgnoreInvalidEndpoints(boolean ignoreInvalidEndpoints) {
+        this.ignoreInvalidEndpoints = ignoreInvalidEndpoints;
+    }
+
+    protected List<Processor> createEndpointProcessors(Exchange exchange) {

Review Comment:
   Thanks.  I simplified some of this, so please let me know if it looks better.



-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

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

Reply via email to