This is an automated email from the ASF dual-hosted git repository.
zhfeng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new 0caa4c4 Fix #3157 to make sure the brokers option is configured in
native mode (#3198)
0caa4c4 is described below
commit 0caa4c491a9711e21490bfa3f5c091411aaafcd3
Author: Amos Feng <[email protected]>
AuthorDate: Wed Oct 20 10:49:05 2021 +0800
Fix #3157 to make sure the brokers option is configured in native mode
(#3198)
* Fix #3157 to make sure the brokers option is configured in native mode
* override the camel.component.kafka.brokers in KafkaDevServicesDisabledTest
---
.../component/kafka/deployment/KafkaProcessor.java | 20 +++++-------
.../deployment/KafkaDevServicesDisabledTest.java | 3 +-
.../component/kafka/CamelKafkaRecorder.java | 36 ----------------------
3 files changed, 9 insertions(+), 50 deletions(-)
diff --git
a/extensions/kafka/deployment/src/main/java/org/apache/camel/quarkus/component/kafka/deployment/KafkaProcessor.java
b/extensions/kafka/deployment/src/main/java/org/apache/camel/quarkus/component/kafka/deployment/KafkaProcessor.java
index 8980431..6aab15e 100644
---
a/extensions/kafka/deployment/src/main/java/org/apache/camel/quarkus/component/kafka/deployment/KafkaProcessor.java
+++
b/extensions/kafka/deployment/src/main/java/org/apache/camel/quarkus/component/kafka/deployment/KafkaProcessor.java
@@ -24,21 +24,18 @@ import io.quarkus.deployment.Capability;
import io.quarkus.deployment.IsNormal;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
-import io.quarkus.deployment.annotations.ExecutionTime;
-import io.quarkus.deployment.annotations.Record;
+import io.quarkus.deployment.builditem.DevServicesConfigResultBuildItem;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.dev.devservices.GlobalDevServicesConfig;
import io.quarkus.kafka.client.deployment.DevServicesKafkaBrokerBuildItem;
import io.quarkus.kafka.client.deployment.KafkaBuildTimeConfig;
-import org.apache.camel.component.kafka.KafkaComponent;
-import org.apache.camel.quarkus.component.kafka.CamelKafkaRecorder;
import org.apache.camel.quarkus.component.kafka.KafkaClientFactoryProducer;
-import org.apache.camel.quarkus.core.deployment.spi.CamelBeanBuildItem;
import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.ConfigProvider;
class KafkaProcessor {
private static final String FEATURE = "camel-kafka";
+ private static final String CAMEL_KAFKA_BROKERS =
"camel.component.kafka.brokers";
@BuildStep
FeatureBuildItem feature() {
@@ -54,21 +51,18 @@ class KafkaProcessor {
}
}
- @Record(ExecutionTime.STATIC_INIT)
@BuildStep(onlyIfNot = IsNormal.class, onlyIf =
GlobalDevServicesConfig.Enabled.class)
public void configureKafkaComponentForDevServices(
DevServicesKafkaBrokerBuildItem kafkaBrokerBuildItem,
KafkaBuildTimeConfig kafkaBuildTimeConfig,
- BuildProducer<CamelBeanBuildItem> camelBean,
- CamelKafkaRecorder recorder) {
+ BuildProducer<DevServicesConfigResultBuildItem> devServiceConfig) {
Config config = ConfigProvider.getConfig();
- Optional<String> brokers =
config.getOptionalValue("camel.component.kafka.brokers", String.class);
+ Optional<String> brokers =
config.getOptionalValue(CAMEL_KAFKA_BROKERS, String.class);
+
if (brokers.isEmpty() &&
kafkaBuildTimeConfig.devservices.enabled.orElse(true)) {
- camelBean.produce(new CamelBeanBuildItem(
- "kafka",
- KafkaComponent.class.getName(),
-
recorder.createKafkaComponentForDevServices(kafkaBrokerBuildItem.getBootstrapServers())));
+ devServiceConfig.produce(new
DevServicesConfigResultBuildItem(CAMEL_KAFKA_BROKERS,
+ kafkaBrokerBuildItem.getBootstrapServers()));
}
}
}
diff --git
a/extensions/kafka/deployment/src/test/java/org/apache/camel/quarkus/component/kafka/deployment/KafkaDevServicesDisabledTest.java
b/extensions/kafka/deployment/src/test/java/org/apache/camel/quarkus/component/kafka/deployment/KafkaDevServicesDisabledTest.java
index 14883db..75daa19 100644
---
a/extensions/kafka/deployment/src/test/java/org/apache/camel/quarkus/component/kafka/deployment/KafkaDevServicesDisabledTest.java
+++
b/extensions/kafka/deployment/src/test/java/org/apache/camel/quarkus/component/kafka/deployment/KafkaDevServicesDisabledTest.java
@@ -34,7 +34,8 @@ public class KafkaDevServicesDisabledTest {
@RegisterExtension
static final QuarkusUnitTest CONFIG = new QuarkusUnitTest()
.withConfigurationResource("application-configuration-devservices-disabled.properties")
- .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class));
+ .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class))
+ .overrideConfigKey("camel.component.kafka.brokers", "");
@Inject
CamelContext context;
diff --git
a/extensions/kafka/runtime/src/main/java/org/apache/camel/quarkus/component/kafka/CamelKafkaRecorder.java
b/extensions/kafka/runtime/src/main/java/org/apache/camel/quarkus/component/kafka/CamelKafkaRecorder.java
deleted file mode 100644
index a52941f..0000000
---
a/extensions/kafka/runtime/src/main/java/org/apache/camel/quarkus/component/kafka/CamelKafkaRecorder.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.quarkus.component.kafka;
-
-import io.quarkus.runtime.RuntimeValue;
-import io.quarkus.runtime.annotations.Recorder;
-import org.apache.camel.component.kafka.KafkaComponent;
-import org.apache.camel.component.kafka.KafkaConfiguration;
-
-@Recorder
-public class CamelKafkaRecorder {
-
- public RuntimeValue<KafkaComponent>
createKafkaComponentForDevServices(String brokers) {
- KafkaConfiguration configuration = new KafkaConfiguration();
- configuration.setBrokers(brokers);
-
- KafkaComponent component = new KafkaComponent();
- component.setConfiguration(configuration);
-
- return new RuntimeValue<>(component);
- }
-}