davsclaus commented on code in PR #30152:
URL: https://github.com/apache/camel/pull/30152#discussion_r4583537874


##########
core/camel-api/src/main/java/org/apache/camel/spi/InMemoryStrategy.java:
##########
@@ -0,0 +1,34 @@
+/*
+ * 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.spi;
+
+/**
+ * A store of state, such as an {@link IdempotentRepository} or an {@link 
AggregationRepository}, that tells whether it
+ * keeps its data only in the memory of this JVM. Such data is lost when the 
application stops: after a restart an
+ * idempotent consumer lets the same messages through again, a file consumer 
with noop=true reads the same files again,
+ * and an aggregator has lost the groups it was building.
+ * <p/>
+ * A store that can be configured either way, such as a cache with or without 
a disk tier, or a store that delegates to
+ * another store, answers for the configuration in use. A store that does not 
implement this interface does not tell.
+ */

Review Comment:
   Added `@since 4.24` in ff1067626f23.



##########
core/camel-console/src/main/java/org/apache/camel/impl/console/ProcessorDetailDevConsole.java:
##########
@@ -190,12 +216,69 @@ private static RouteDetail 
buildRouteDetail(ManagedRouteMBean mr) {
             // ignore
         }
 
-        ProcessorEntry fromEntry = new ProcessorEntry(fromId, "from", 
mr.getEndpointUri(), fromLine, new LinkedHashMap<>());
+        // the repositories the processors keep their state in, which the 
route dump does not show when they are defaults
+        processors.replaceAll(p -> withState(p, processorState(mcc, p.id(), 
p.type())));
+
+        ProcessorEntry fromEntry = new ProcessorEntry(
+                fromId, "from", mr.getEndpointUri(), fromLine, new 
LinkedHashMap<>(), endpointState(routeId));
         processors.add(0, fromEntry);
 
         return new RouteDetail(routeId, processors);
     }
 
+    private static ProcessorEntry withState(ProcessorEntry p, List<StateEntry> 
state) {
+        return state == null ? p : new ProcessorEntry(p.id(), p.type(), 
p.endpointUri(), p.line(), p.options(), state);
+    }
+
+    /**
+     * The repository of an idempotent consumer or an aggregator, from its 
managed object: the aggregator creates an
+     * in-memory one when none is configured.
+     */
+    private static List<StateEntry> processorState(ManagedCamelContext mcc, 
String id, String type) {
+        try {
+            if ("idempotentConsumer".equals(type)) {
+                ManagedIdempotentConsumerMBean mp = 
mcc.getManagedProcessor(id, ManagedIdempotentConsumerMBean.class);
+                if (mp != null && mp.getIdempotentRepositoryClassName() != 
null) {
+                    return List.of(new StateEntry(
+                            "idempotentRepository", 
mp.getIdempotentRepositoryClassName(),
+                            mp.isIdempotentRepositoryInMemory()));
+                }
+            } else if ("aggregate".equals(type)) {
+                ManagedAggregateProcessorMBean mp = 
mcc.getManagedProcessor(id, ManagedAggregateProcessorMBean.class);
+                if (mp != null && mp.getAggregationRepositoryClassName() != 
null) {
+                    return List.of(new StateEntry(
+                            "aggregationRepository", 
mp.getAggregationRepositoryClassName(),
+                            mp.isAggregationRepositoryInMemory()));
+                }
+            }
+        } catch (Exception e) {
+            // the processor is not managed, so its state is not shown
+        }
+        return null;

Review Comment:
   `catch (JMException e)` does not compile here: `JMException` is a checked 
exception, and nothing in the try block declares it. The JMX proxy wraps what 
goes wrong, such as `InstanceNotFoundException` for a processor that is not 
managed, in a runtime exception (`UndeclaredThrowableException`). So in 
ff1067626f23 the catch is narrowed to `RuntimeException`, and it logs at DEBUG, 
as you suggested as the other option.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to