davsclaus commented on a change in pull request #4913:
URL: https://github.com/apache/camel/pull/4913#discussion_r563043005



##########
File path: 
components/camel-infinispan/camel-infinispan-common/src/main/java/org/apache/camel/component/infinispan/InfinispanRoutePolicy.java
##########
@@ -0,0 +1,246 @@
+/*
+ * 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.infinispan;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelContextAware;
+import org.apache.camel.Route;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.Service;
+import org.apache.camel.api.management.ManagedAttribute;
+import org.apache.camel.support.RoutePolicySupport;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.ReferenceCount;
+import org.apache.camel.util.StringHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class InfinispanRoutePolicy extends RoutePolicySupport 
implements CamelContextAware {

Review comment:
       Just a thought I wonder didnt we have some SPI interface in 
camel-cluster to do clustered routes?

##########
File path: 
components/camel-infinispan/camel-infinispan-common/src/main/java/org/apache/camel/component/infinispan/InfinispanConsumer.java
##########
@@ -0,0 +1,84 @@
+/*
+ * 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.infinispan;
+
+import java.util.function.Consumer;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.support.DefaultConsumer;
+import org.infinispan.commons.api.BasicCache;
+import org.infinispan.commons.api.BasicCacheContainer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class InfinispanConsumer<
+        ContainerType extends BasicCacheContainer,
+        ManagerType extends InfinispanManager<ContainerType>,
+        ConfigurationType extends InfinispanConfiguration>
+        extends DefaultConsumer
+        implements InfinispanEventProcessor {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(InfinispanProducer.class);
+
+    protected final ConfigurationType configuration;
+    protected final ManagerType manager;
+    protected final String cacheName;
+
+    protected InfinispanConsumer(InfinispanEndpoint endpoint, Processor 
processor, String cacheName, ManagerType manager,
+                                 ConfigurationType configuration) {
+        super(endpoint, processor);
+        this.cacheName = cacheName;
+        this.configuration = configuration;
+        this.manager = manager;
+    }
+
+    @Override
+    public void processEvent(String eventType, String cacheName, Object key, 
Object eventData, Consumer<Exchange> consumer) {
+        Exchange exchange = getEndpoint().createExchange();
+        exchange.getMessage().setHeader(InfinispanConstants.EVENT_TYPE, 
eventType);
+        exchange.getMessage().setHeader(InfinispanConstants.CACHE_NAME, 
cacheName);
+
+        if (key != null) {
+            exchange.getMessage().setHeader(InfinispanConstants.KEY, key);
+        }
+        if (eventData != null) {
+            exchange.getMessage().setHeader(InfinispanConstants.EVENT_DATA, 
eventData);
+        }
+        if (consumer != null) {
+            consumer.accept(exchange);
+        }
+
+        try {
+            getProcessor().process(exchange);
+        } catch (Exception e) {
+            LOG.error("Error processing event ", e);

Review comment:
       Use getExceptionHandler().handleException instead of LOG




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