You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "davsclaus (via GitHub)" <gi...@apache.org> on 2024/07/09 15:04:15 UTC
[PR] Kafka dev console and jbang command [camel]
davsclaus opened a new pull request, #14768:
URL: https://github.com/apache/camel/pull/14768
# Description
<!--
- Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
-->
# Target
- [ ] I checked that the commit is targeting the correct branch (note that Camel 3 uses `camel-3.x`, whereas Camel 4 uses the `main` branch)
# Tracking
- [ ] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it).
<!--
# *Note*: trivial changes like, typos, minor documentation fixes and other small items do not require a JIRA issue. In this case your pull request should address just this issue, without pulling in other changes.
-->
# Apache Camel coding standards and style
- [ ] I checked that each commit in the pull request has a meaningful subject line and body.
<!--
If you're unsure, you can format the pull request title like `[CAMEL-XXX] Fixes bug in camel-file component`, where you replace `CAMEL-XXX` with the appropriate JIRA issue.
-->
- [ ] I have run `mvn clean install -DskipTests` locally and I have committed all auto-generated changes
<!--
You can run the aforementioned command in your module so that the build auto-formats your code. This will also be verified as part of the checks and your PR may be rejected if if there are uncommited changes after running `mvn clean install -DskipTests`.
You can learn more about the contribution guidelines at https://github.com/apache/camel/blob/main/CONTRIBUTING.md
-->
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Kafka dev console and jbang command [camel]
Posted by "orpiske (via GitHub)" <gi...@apache.org>.
orpiske commented on PR #14768:
URL: https://github.com/apache/camel/pull/14768#issuecomment-2219661097
> > I've left some suggestions. I think this is adding a lot of complexity to a component that is already very complex. IMHO, a decorator would be able to isolate that complexity and reduce the performance impacts on the hot path.
>
> The dev consoles are basic string and json object - its pure easy code - overkill to have template language as it adds unwanted dependency on some library. The dev consoles are used during development
OK.
> ... and not any hot-path at all.
Actually, the code is indeed right in the hot path of the consumer, as it's within the loop that calls `poll`. That's my main concern with this change.
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Kafka dev console and jbang command [camel]
Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #14768:
URL: https://github.com/apache/camel/pull/14768#discussion_r1671659607
##########
components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaDevConsole.java:
##########
@@ -0,0 +1,181 @@
+/*
+ * 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.kafka;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.Route;
+import org.apache.camel.spi.annotations.DevConsole;
+import org.apache.camel.support.console.AbstractDevConsole;
+import org.apache.camel.util.StopWatch;
+import org.apache.camel.util.TimeUtils;
+import org.apache.camel.util.json.JsonArray;
+import org.apache.camel.util.json.JsonObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@DevConsole(name = "kafka", displayName = "Kafka", description = "Apache Kafka")
+public class KafkaDevConsole extends AbstractDevConsole {
+
+ private static final Logger LOG = LoggerFactory.getLogger(KafkaDevConsole.class);
+
+ private static final long COMMITTED_TIMEOUT = 10000;
+
+ /**
+ * Whether to include committed offset (sync operation to Kafka broker)
+ */
+ public static final String COMMITTED = "committed";
+
+ public KafkaDevConsole() {
+ super("camel", "kafka", "Kafka", "Apache Kafka");
+ }
+
+ @Override
+ protected String doCallText(Map<String, Object> options) {
+ final boolean committed = "true".equals(options.getOrDefault(COMMITTED, "false"));
+
+ StringBuilder sb = new StringBuilder();
+ for (Route route : getCamelContext().getRoutes()) {
+ if (route.getConsumer() instanceof KafkaConsumer kc) {
+ sb.append(String.format("\n Route Id: %s", route.getRouteId()));
+ sb.append(String.format("\n From: %s", route.getEndpoint().getEndpointUri()));
+ for (KafkaFetchRecords t : kc.tasks()) {
+ sb.append(String.format("\n Worked Thread: %s", t.getThreadId()));
+ sb.append(String.format("\n Worker State: %s", t.getState()));
+ TaskHealthState hs = t.healthState();
+ if (!hs.isReady()) {
+ sb.append(String.format("\n Worker Last Error: %s", hs.buildStateMessage()));
+ }
+ KafkaFetchRecords.GroupMetadata meta = t.getGroupMetadata();
+ if (meta != null) {
+ sb.append(String.format("\n Group Id: %s", meta.groupId()));
+ sb.append(String.format("\n Group Instance Id: %s", meta.groupInstanceId()));
+ sb.append(String.format("\n Member Id: %s", meta.memberId()));
+ sb.append(String.format("\n Generation Id: %d", meta.generationId()));
+ }
+ if (t.getLastRecord() != null) {
+ sb.append(String.format("\n Last Topic: %s", t.getLastRecord().topic()));
+ sb.append(String.format("\n Last Partition: %d", t.getLastRecord().partition()));
+ sb.append(String.format("\n Last Offset: %d", t.getLastRecord().offset()));
+ }
+ if (committed) {
+ List<KafkaFetchRecords.KafkaTopicPosition> l = fetchCommitOffsets(kc, t);
+ if (l != null) {
+ for (KafkaFetchRecords.KafkaTopicPosition r : l) {
+ sb.append(String.format("\n Commit Topic: %s", r.topic()));
+ sb.append(String.format("\n Commit Partition: %s", r.partition()));
+ sb.append(String.format("\n Commit Offset: %s", r.offset()));
+ if (r.epoch() > 0) {
+ long delta = System.currentTimeMillis() - r.epoch();
+ sb.append(String.format("\n Commit Offset Since: %s",
+ TimeUtils.printDuration(delta, true)));
+ }
+ }
+ }
+ }
Review Comment:
No this is how the dev consoles are already done
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Kafka dev console and jbang command [camel]
Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #14768:
URL: https://github.com/apache/camel/pull/14768#discussion_r1671735359
##########
components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaFetchRecords.java:
##########
@@ -343,6 +371,30 @@ protected void startPolling() {
final KafkaRecordProcessorFacade recordProcessorFacade = createRecordProcessor();
while (isKafkaConsumerRunnableAndNotStopped() && isConnected() && pollExceptionStrategy.canContinue()) {
+
+ if (commitRecordsRequested.compareAndSet(true, false)) {
+ try {
+ // we want to get details about last committed offsets (which MUST be done by this consumer thread)
+ Map<TopicPartition, OffsetAndMetadata> commits = consumer.committed(consumer.assignment());
+ commitRecords.clear();
+ for (var e : commits.entrySet()) {
+ KafkaTopicPosition p
+ = new KafkaTopicPosition(
+ e.getKey().topic(), e.getKey().partition(), e.getValue().offset(),
+ e.getValue().leaderEpoch().orElse(0));
+ commitRecords.add(p);
+ }
+ CountDownLatch count = latch.get();
+ if (count != null) {
+ count.countDown();
+ }
+ } catch (Exception e) {
+ // ignore cannot get last commit details
+ LOG.debug("Cannot get last offset committed from Kafka brokers due to: {}. This exception is ignored.",
+ e.getMessage(), e);
+ }
+ }
+
Review Comment:
added a check if dev console enabled to skip the CAS
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Kafka dev console and jbang command [camel]
Posted by "orpiske (via GitHub)" <gi...@apache.org>.
orpiske commented on code in PR #14768:
URL: https://github.com/apache/camel/pull/14768#discussion_r1671674901
##########
components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaFetchRecords.java:
##########
@@ -343,6 +371,30 @@ protected void startPolling() {
final KafkaRecordProcessorFacade recordProcessorFacade = createRecordProcessor();
while (isKafkaConsumerRunnableAndNotStopped() && isConnected() && pollExceptionStrategy.canContinue()) {
+
+ if (commitRecordsRequested.compareAndSet(true, false)) {
+ try {
+ // we want to get details about last committed offsets (which MUST be done by this consumer thread)
+ Map<TopicPartition, OffsetAndMetadata> commits = consumer.committed(consumer.assignment());
+ commitRecords.clear();
+ for (var e : commits.entrySet()) {
+ KafkaTopicPosition p
+ = new KafkaTopicPosition(
+ e.getKey().topic(), e.getKey().partition(), e.getValue().offset(),
+ e.getValue().leaderEpoch().orElse(0));
+ commitRecords.add(p);
+ }
+ CountDownLatch count = latch.get();
+ if (count != null) {
+ count.countDown();
+ }
+ } catch (Exception e) {
+ // ignore cannot get last commit details
+ LOG.debug("Cannot get last offset committed from Kafka brokers due to: {}. This exception is ignored.",
+ e.getMessage(), e);
+ }
+ }
+
Review Comment:
> No its only in use on special request
So yeah, that's my point. We are calling `compareAndSet` here which, even though is an Intrinsic method, may actually cause memory overhead due to need to perform CAS.
So, even though an integration doesn't need the console, it would still be subject to this, which could hurt performance.
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Kafka dev console and jbang command [camel]
Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on PR #14768:
URL: https://github.com/apache/camel/pull/14768#issuecomment-2219629075
> I've left some suggestions. I think this is adding a lot of complexity to a component that is already very complex. IMHO, a decorator would be able to isolate that complexity and reduce the performance impacts on the hot path.
The dev consoles are basic string and json object - its pure easy code - overkill to have template language as it adds unwanted dependency on some library. The dev consoles are used during development and not any hot-path at all.
Its a tremendous help for users of Camel & tooling and something we must add alot more to components.
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Kafka dev console and jbang command [camel]
Posted by "orpiske (via GitHub)" <gi...@apache.org>.
orpiske commented on code in PR #14768:
URL: https://github.com/apache/camel/pull/14768#discussion_r1671674901
##########
components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaFetchRecords.java:
##########
@@ -343,6 +371,30 @@ protected void startPolling() {
final KafkaRecordProcessorFacade recordProcessorFacade = createRecordProcessor();
while (isKafkaConsumerRunnableAndNotStopped() && isConnected() && pollExceptionStrategy.canContinue()) {
+
+ if (commitRecordsRequested.compareAndSet(true, false)) {
+ try {
+ // we want to get details about last committed offsets (which MUST be done by this consumer thread)
+ Map<TopicPartition, OffsetAndMetadata> commits = consumer.committed(consumer.assignment());
+ commitRecords.clear();
+ for (var e : commits.entrySet()) {
+ KafkaTopicPosition p
+ = new KafkaTopicPosition(
+ e.getKey().topic(), e.getKey().partition(), e.getValue().offset(),
+ e.getValue().leaderEpoch().orElse(0));
+ commitRecords.add(p);
+ }
+ CountDownLatch count = latch.get();
+ if (count != null) {
+ count.countDown();
+ }
+ } catch (Exception e) {
+ // ignore cannot get last commit details
+ LOG.debug("Cannot get last offset committed from Kafka brokers due to: {}. This exception is ignored.",
+ e.getMessage(), e);
+ }
+ }
+
Review Comment:
> No its only in use on special request
So yeah, that's my point. We are calling `compareAndSet` here which, even though is an Intrinsic method, may actually cause a memory overhead due to need to perform CAS.
So, even though an integration doesn't need the console, it would still be subject to this, which could hurt performance.
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Kafka dev console and jbang command [camel]
Posted by "orpiske (via GitHub)" <gi...@apache.org>.
orpiske commented on code in PR #14768:
URL: https://github.com/apache/camel/pull/14768#discussion_r1671653582
##########
components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaFetchRecords.java:
##########
@@ -343,6 +371,30 @@ protected void startPolling() {
final KafkaRecordProcessorFacade recordProcessorFacade = createRecordProcessor();
while (isKafkaConsumerRunnableAndNotStopped() && isConnected() && pollExceptionStrategy.canContinue()) {
+
+ if (commitRecordsRequested.compareAndSet(true, false)) {
+ try {
+ // we want to get details about last committed offsets (which MUST be done by this consumer thread)
+ Map<TopicPartition, OffsetAndMetadata> commits = consumer.committed(consumer.assignment());
+ commitRecords.clear();
+ for (var e : commits.entrySet()) {
+ KafkaTopicPosition p
+ = new KafkaTopicPosition(
+ e.getKey().topic(), e.getKey().partition(), e.getValue().offset(),
+ e.getValue().leaderEpoch().orElse(0));
+ commitRecords.add(p);
+ }
+ CountDownLatch count = latch.get();
+ if (count != null) {
+ count.countDown();
+ }
+ } catch (Exception e) {
+ // ignore cannot get last commit details
+ LOG.debug("Cannot get last offset committed from Kafka brokers due to: {}. This exception is ignored.",
+ e.getMessage(), e);
+ }
+ }
+
Review Comment:
IMHO, it would be better to do this using a decorator. The biggest problem here is that we are attaching an edge case behavior right into the hot path of the component.
##########
components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaDevConsole.java:
##########
@@ -0,0 +1,181 @@
+/*
+ * 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.kafka;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.Route;
+import org.apache.camel.spi.annotations.DevConsole;
+import org.apache.camel.support.console.AbstractDevConsole;
+import org.apache.camel.util.StopWatch;
+import org.apache.camel.util.TimeUtils;
+import org.apache.camel.util.json.JsonArray;
+import org.apache.camel.util.json.JsonObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@DevConsole(name = "kafka", displayName = "Kafka", description = "Apache Kafka")
+public class KafkaDevConsole extends AbstractDevConsole {
+
+ private static final Logger LOG = LoggerFactory.getLogger(KafkaDevConsole.class);
+
+ private static final long COMMITTED_TIMEOUT = 10000;
+
+ /**
+ * Whether to include committed offset (sync operation to Kafka broker)
+ */
+ public static final String COMMITTED = "committed";
+
+ public KafkaDevConsole() {
+ super("camel", "kafka", "Kafka", "Apache Kafka");
+ }
+
+ @Override
+ protected String doCallText(Map<String, Object> options) {
+ final boolean committed = "true".equals(options.getOrDefault(COMMITTED, "false"));
+
+ StringBuilder sb = new StringBuilder();
+ for (Route route : getCamelContext().getRoutes()) {
+ if (route.getConsumer() instanceof KafkaConsumer kc) {
+ sb.append(String.format("\n Route Id: %s", route.getRouteId()));
+ sb.append(String.format("\n From: %s", route.getEndpoint().getEndpointUri()));
+ for (KafkaFetchRecords t : kc.tasks()) {
+ sb.append(String.format("\n Worked Thread: %s", t.getThreadId()));
+ sb.append(String.format("\n Worker State: %s", t.getState()));
+ TaskHealthState hs = t.healthState();
+ if (!hs.isReady()) {
+ sb.append(String.format("\n Worker Last Error: %s", hs.buildStateMessage()));
+ }
+ KafkaFetchRecords.GroupMetadata meta = t.getGroupMetadata();
+ if (meta != null) {
+ sb.append(String.format("\n Group Id: %s", meta.groupId()));
+ sb.append(String.format("\n Group Instance Id: %s", meta.groupInstanceId()));
+ sb.append(String.format("\n Member Id: %s", meta.memberId()));
+ sb.append(String.format("\n Generation Id: %d", meta.generationId()));
+ }
+ if (t.getLastRecord() != null) {
+ sb.append(String.format("\n Last Topic: %s", t.getLastRecord().topic()));
+ sb.append(String.format("\n Last Partition: %d", t.getLastRecord().partition()));
+ sb.append(String.format("\n Last Offset: %d", t.getLastRecord().offset()));
+ }
+ if (committed) {
+ List<KafkaFetchRecords.KafkaTopicPosition> l = fetchCommitOffsets(kc, t);
+ if (l != null) {
+ for (KafkaFetchRecords.KafkaTopicPosition r : l) {
+ sb.append(String.format("\n Commit Topic: %s", r.topic()));
+ sb.append(String.format("\n Commit Partition: %s", r.partition()));
+ sb.append(String.format("\n Commit Offset: %s", r.offset()));
+ if (r.epoch() > 0) {
+ long delta = System.currentTimeMillis() - r.epoch();
+ sb.append(String.format("\n Commit Offset Since: %s",
+ TimeUtils.printDuration(delta, true)));
+ }
+ }
+ }
+ }
Review Comment:
IMHO, this would be much better done by using a script language such as Velocity. Formatting the strings builtin are terribly hard to maintain.
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Kafka dev console and jbang command [camel]
Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus merged PR #14768:
URL: https://github.com/apache/camel/pull/14768
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Kafka dev console and jbang command [camel]
Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #14768:
URL: https://github.com/apache/camel/pull/14768#discussion_r1671660004
##########
components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaFetchRecords.java:
##########
@@ -343,6 +371,30 @@ protected void startPolling() {
final KafkaRecordProcessorFacade recordProcessorFacade = createRecordProcessor();
while (isKafkaConsumerRunnableAndNotStopped() && isConnected() && pollExceptionStrategy.canContinue()) {
+
+ if (commitRecordsRequested.compareAndSet(true, false)) {
+ try {
+ // we want to get details about last committed offsets (which MUST be done by this consumer thread)
+ Map<TopicPartition, OffsetAndMetadata> commits = consumer.committed(consumer.assignment());
+ commitRecords.clear();
+ for (var e : commits.entrySet()) {
+ KafkaTopicPosition p
+ = new KafkaTopicPosition(
+ e.getKey().topic(), e.getKey().partition(), e.getValue().offset(),
+ e.getValue().leaderEpoch().orElse(0));
+ commitRecords.add(p);
+ }
+ CountDownLatch count = latch.get();
+ if (count != null) {
+ count.countDown();
+ }
+ } catch (Exception e) {
+ // ignore cannot get last commit details
+ LOG.debug("Cannot get last offset committed from Kafka brokers due to: {}. This exception is ignored.",
+ e.getMessage(), e);
+ }
+ }
+
Review Comment:
No its only in use on special request
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Kafka dev console and jbang command [camel]
Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on PR #14768:
URL: https://github.com/apache/camel/pull/14768#issuecomment-2219737159
> > > I've left some suggestions. I think this is adding a lot of complexity to a component that is already very complex. IMHO, a decorator would be able to isolate that complexity and reduce the performance impacts on the hot path.
> >
> >
> > The dev consoles are basic string and json object - its pure easy code - overkill to have template language as it adds unwanted dependency on some library. The dev consoles are used during development
>
> OK.
>
> > ... and not any hot-path at all.
>
> Actually, the code is indeed right in the hot path of the consumer, as it's within the loop that calls `poll`. That's my main concern with this change.
Only doing the boolean check if dev-console is enabled now
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Kafka dev console and jbang command [camel]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #14768:
URL: https://github.com/apache/camel/pull/14768#issuecomment-2217966293
:star2: Thank you for your contribution to the Apache Camel project! :star2:
:robot: CI automation will test this PR automatically.
:camel: Apache Camel Committers, please review the following items:
* First-time contributors **require MANUAL approval** for the GitHub Actions to run
* You can use the command `/component-test (camel-)component-name1 (camel-)component-name2..` to request a test from the test bot.
* You can label PRs using `build-all`, `build-dependents`, `skip-tests` and `test-dependents` to fine-tune the checks executed by this PR.
* Build and test logs are available in the Summary page. **Only** [Apache Camel committers](https://camel.apache.org/community/team/#committers) have access to the summary.
* :warning: Be careful when sharing logs. Review their contents before sharing them publicly.
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Kafka dev console and jbang command [camel]
Posted by "orpiske (via GitHub)" <gi...@apache.org>.
orpiske commented on code in PR #14768:
URL: https://github.com/apache/camel/pull/14768#discussion_r1671678632
##########
components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaFetchRecords.java:
##########
@@ -343,6 +371,30 @@ protected void startPolling() {
final KafkaRecordProcessorFacade recordProcessorFacade = createRecordProcessor();
while (isKafkaConsumerRunnableAndNotStopped() && isConnected() && pollExceptionStrategy.canContinue()) {
+
+ if (commitRecordsRequested.compareAndSet(true, false)) {
+ try {
+ // we want to get details about last committed offsets (which MUST be done by this consumer thread)
+ Map<TopicPartition, OffsetAndMetadata> commits = consumer.committed(consumer.assignment());
+ commitRecords.clear();
+ for (var e : commits.entrySet()) {
+ KafkaTopicPosition p
+ = new KafkaTopicPosition(
+ e.getKey().topic(), e.getKey().partition(), e.getValue().offset(),
+ e.getValue().leaderEpoch().orElse(0));
+ commitRecords.add(p);
+ }
+ CountDownLatch count = latch.get();
+ if (count != null) {
+ count.countDown();
+ }
+ } catch (Exception e) {
+ // ignore cannot get last commit details
+ LOG.debug("Cannot get last offset committed from Kafka brokers due to: {}. This exception is ignored.",
+ e.getMessage(), e);
+ }
+ }
+
Review Comment:
And the reason I suggested a decorator, is because if we have a NOOP one and a Console one, then we could give the JVM a chance to use DCE to eliminate the code without hurting the performance.
--
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-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org