diff --git a/docs/modules/ROOT/pages/includes/quarkus-temporal.adoc b/docs/modules/ROOT/pages/includes/quarkus-temporal.adoc
index f8e03d0..f5ccf98 100644
--- a/docs/modules/ROOT/pages/includes/quarkus-temporal.adoc
+++ b/docs/modules/ROOT/pages/includes/quarkus-temporal.adoc
@@ -27,6 +27,24 @@ endif::add-copy-button-to-env-var[]
|`false`
+a|icon:lock[title=Fixed at build time] [[quarkus-temporal_quarkus-temporal-channel-type]]`link:#quarkus-temporal_quarkus-temporal-channel-type[quarkus.temporal.channel-type]`
+
+
+[.description]
+--
+either use a channel managed by temporal client (built-in) or use a channel managed by quarkus (quarkus-managed). In this case the channel can be configured using quarkus.grpc.clients.temporal-client.
+
+ifdef::add-copy-button-to-env-var[]
+Environment variable: env_var_with_copy_button:+++QUARKUS_TEMPORAL_CHANNEL_TYPE+++[]
+endif::add-copy-button-to-env-var[]
+ifndef::add-copy-button-to-env-var[]
+Environment variable: `+++QUARKUS_TEMPORAL_CHANNEL_TYPE+++`
+endif::add-copy-button-to-env-var[]
+-- a|
+`quarkus-managed`, `built-in`
+|`built-in`
+
+
a|icon:lock[title=Fixed at build time] [[quarkus-temporal_quarkus-temporal-health-enabled]]`link:#quarkus-temporal_quarkus-temporal-health-enabled[quarkus.temporal.health.enabled]`
diff --git a/extension/deployment/pom.xml b/extension/deployment/pom.xml
index a99dbe6..d26646c 100644
--- a/extension/deployment/pom.xml
+++ b/extension/deployment/pom.xml
@@ -21,6 +21,10 @@
io.quarkus
quarkus-grpc-common-deployment
+
+ io.quarkus
+ quarkus-grpc-deployment
+
io.quarkus
quarkus-smallrye-health-spi
diff --git a/extension/deployment/src/main/java/io/quarkiverse/temporal/deployment/TemporalProcessor.java b/extension/deployment/src/main/java/io/quarkiverse/temporal/deployment/TemporalProcessor.java
index 820fec7..6e585b4 100644
--- a/extension/deployment/src/main/java/io/quarkiverse/temporal/deployment/TemporalProcessor.java
+++ b/extension/deployment/src/main/java/io/quarkiverse/temporal/deployment/TemporalProcessor.java
@@ -2,6 +2,8 @@
import static io.quarkiverse.temporal.Constants.DEFAULT_WORKER_NAME;
import static io.quarkiverse.temporal.Constants.TEMPORAL_TESTING_CAPABILITY;
+import static io.quarkiverse.temporal.config.TemporalBuildtimeConfig.ChannelType.BUILT_IN;
+import static io.quarkiverse.temporal.config.TemporalBuildtimeConfig.ChannelType.QUARKUS_MANAGED;
import static io.quarkus.deployment.Capability.OPENTELEMETRY_TRACER;
import static io.quarkus.runtime.metrics.MetricsFactory.MICROMETER;
@@ -31,6 +33,7 @@
import org.jboss.jandex.DotName;
import org.jboss.jandex.ParameterizedType;
+import io.grpc.Channel;
import io.quarkiverse.temporal.OtelRecorder;
import io.quarkiverse.temporal.TemporalActivity;
import io.quarkiverse.temporal.TemporalHealthCheck;
@@ -60,6 +63,9 @@
import io.quarkus.deployment.builditem.ShutdownContextBuildItem;
import io.quarkus.deployment.metrics.MetricsCapabilityBuildItem;
import io.quarkus.deployment.pkg.builditem.ArtifactResultBuildItem;
+import io.quarkus.grpc.GrpcClient;
+import io.quarkus.grpc.deployment.GrpcClientBuildItem;
+import io.quarkus.grpc.deployment.GrpcDotNames;
import io.quarkus.info.GitInfo;
import io.quarkus.runtime.configuration.ConfigurationException;
import io.quarkus.smallrye.health.deployment.spi.HealthBuildItem;
@@ -313,38 +319,65 @@ void produceActivityBeans(
});
}
+ @BuildStep(onlyIf = EnableQuarkusManagedChannel.class)
+ GrpcClientBuildItem produceGrpcClient() {
+ GrpcClientBuildItem grpcClientBuildItem = new GrpcClientBuildItem("temporal-client");
+ grpcClientBuildItem.addClient(
+ new GrpcClientBuildItem.ClientInfo(GrpcDotNames.CHANNEL, GrpcClientBuildItem.ClientType.CHANNEL, Set.of()));
+ return grpcClientBuildItem;
+ }
+
@BuildStep(onlyIfNot = EnableMock.class)
@Record(ExecutionTime.RUNTIME_INIT)
- WorkflowClientBuildItem recordWorkflowClient(
- WorkflowServiceStubsRecorder recorder,
- WorkflowClientRecorder clientRecorder,
- Optional metricsCapability) {
+ SyntheticBeanBuildItem produceWorkflowServiceStubSyntheticBean(TemporalBuildtimeConfig config,
+ Optional metricsCapability,
+ WorkflowServiceStubsRecorder recorder) {
boolean micrometerSupported = metricsCapability.isPresent() && metricsCapability.get().metricsSupported(MICROMETER);
- WorkflowServiceStubs workflowServiceStubs = recorder.createWorkflowServiceStubs(micrometerSupported);
- return new WorkflowClientBuildItem(
- clientRecorder.createWorkflowClient(workflowServiceStubs));
+ if (BUILT_IN.equals(config.channelType())) {
+ return SyntheticBeanBuildItem
+ .configure(WorkflowServiceStubs.class)
+ .scope(ApplicationScoped.class)
+ .unremovable()
+ .defaultBean()
+ .createWith(recorder.createWorkflowServiceStubs(micrometerSupported))
+ .setRuntimeInit()
+ .done();
+ }
+
+ // QUARKUS_MANAGED
+ return SyntheticBeanBuildItem
+ .configure(WorkflowServiceStubs.class)
+ .scope(ApplicationScoped.class)
+ .unremovable()
+ .defaultBean()
+ .addInjectionPoint(ClassType.create(Channel.class),
+ AnnotationInstance.builder(GrpcClient.class).value("temporal-client").build())
+ .createWith(recorder.createQuarkusManagedWorkflowServiceStubs(micrometerSupported))
+ .setRuntimeInit()
+ .done();
+
}
- @BuildStep
- Optional produceWorkflowClientSyntheticBean(
- Optional workflowClientBuildItem) {
-
- return workflowClientBuildItem
- .map(buildItem -> SyntheticBeanBuildItem
- .configure(WorkflowClient.class)
- .scope(ApplicationScoped.class)
- .unremovable()
- .defaultBean()
- .addInjectionPoint(
- ParameterizedType.create(Instance.class, ClassType.create(WorkflowClientInterceptor.class)),
- AnnotationInstance.builder(Any.class).build())
- .addInjectionPoint(ParameterizedType.create(Instance.class, ClassType.create(ContextPropagator.class)),
- AnnotationInstance.builder(Any.class).build())
- .createWith(buildItem.workflowClient)
- .setRuntimeInit()
- .done());
+ @BuildStep(onlyIfNot = EnableMock.class)
+ @Record(ExecutionTime.RUNTIME_INIT)
+ SyntheticBeanBuildItem produceWorkflowClientSyntheticBean(WorkflowClientRecorder clientRecorder) {
+
+ return SyntheticBeanBuildItem
+ .configure(WorkflowClient.class)
+ .scope(ApplicationScoped.class)
+ .unremovable()
+ .defaultBean()
+ .addInjectionPoint(ClassType.create(WorkflowServiceStubs.class))
+ .addInjectionPoint(
+ ParameterizedType.create(Instance.class, ClassType.create(WorkflowClientInterceptor.class)),
+ AnnotationInstance.builder(Any.class).build())
+ .addInjectionPoint(ParameterizedType.create(Instance.class, ClassType.create(ContextPropagator.class)),
+ AnnotationInstance.builder(Any.class).build())
+ .createWith(clientRecorder.createWorkflowClient())
+ .setRuntimeInit()
+ .done();
}
@@ -489,6 +522,14 @@ Class> loadClass(ClassInfo classInfo) {
}
}
+ public static class EnableQuarkusManagedChannel implements BooleanSupplier {
+ TemporalBuildtimeConfig config;
+
+ public boolean getAsBoolean() {
+ return !config.enableMock() && config.channelType() == QUARKUS_MANAGED;
+ }
+ }
+
public static class EnableMock implements BooleanSupplier {
TemporalBuildtimeConfig config;
diff --git a/extension/deployment/src/test/java/io/quarkiverse/temporal/deployment/QuarkusManagedChannelConfigPriorityTest.java b/extension/deployment/src/test/java/io/quarkiverse/temporal/deployment/QuarkusManagedChannelConfigPriorityTest.java
new file mode 100644
index 0000000..08b140e
--- /dev/null
+++ b/extension/deployment/src/test/java/io/quarkiverse/temporal/deployment/QuarkusManagedChannelConfigPriorityTest.java
@@ -0,0 +1,36 @@
+package io.quarkiverse.temporal.deployment;
+
+import jakarta.inject.Inject;
+
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import io.quarkus.test.QuarkusUnitTest;
+import io.temporal.serviceclient.WorkflowServiceStubs;
+
+public class QuarkusManagedChannelConfigPriorityTest {
+
+ @RegisterExtension
+ static final QuarkusUnitTest unitTest = new QuarkusUnitTest()
+ .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
+ .addAsResource(
+ new StringAsset(
+ "quarkus.temporal.start-workers: false\n" +
+ "quarkus.temporal.channel-type: quarkus-managed\n" +
+ "quarkus.grpc.clients.temporal-client.host: grpcHost\n" +
+ "quarkus.temporal.connection.target: customTarget:1234\n"),
+ "application.properties"));
+
+ @Inject
+ WorkflowServiceStubs serviceStubs;
+
+ @Test
+ public void testQuarkusManagedChannel() {
+ Assertions.assertNull(serviceStubs.getOptions().getTarget());
+ Assertions.assertEquals("grpcHost:1234", serviceStubs.getOptions().getChannel().authority());
+ }
+}
diff --git a/extension/deployment/src/test/java/io/quarkiverse/temporal/deployment/QuarkusManagedChannelTest.java b/extension/deployment/src/test/java/io/quarkiverse/temporal/deployment/QuarkusManagedChannelTest.java
new file mode 100644
index 0000000..e4ee27c
--- /dev/null
+++ b/extension/deployment/src/test/java/io/quarkiverse/temporal/deployment/QuarkusManagedChannelTest.java
@@ -0,0 +1,35 @@
+package io.quarkiverse.temporal.deployment;
+
+import jakarta.inject.Inject;
+
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import io.quarkus.test.QuarkusUnitTest;
+import io.temporal.serviceclient.WorkflowServiceStubs;
+
+public class QuarkusManagedChannelTest {
+
+ @RegisterExtension
+ static final QuarkusUnitTest unitTest = new QuarkusUnitTest()
+ .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
+ .addAsResource(
+ new StringAsset(
+ "quarkus.temporal.start-workers: false\n" +
+ "quarkus.temporal.channel-type: quarkus-managed\n" +
+ "quarkus.temporal.connection.target: customTarget:1234\n"),
+ "application.properties"));
+
+ @Inject
+ WorkflowServiceStubs serviceStubs;
+
+ @Test
+ public void testQuarkusManagedChannel() {
+ Assertions.assertNull(serviceStubs.getOptions().getTarget());
+ Assertions.assertEquals("customTarget:1234", serviceStubs.getOptions().getChannel().authority());
+ }
+}
diff --git a/extension/runtime/pom.xml b/extension/runtime/pom.xml
index bc02114..1101b4c 100644
--- a/extension/runtime/pom.xml
+++ b/extension/runtime/pom.xml
@@ -21,6 +21,10 @@
io.quarkus
quarkus-grpc-common
+
+ io.quarkus
+ quarkus-grpc
+
io.quarkus
quarkus-smallrye-health
diff --git a/extension/runtime/src/main/java/io/quarkiverse/temporal/TemporalConfigRelocateInterceptor.java b/extension/runtime/src/main/java/io/quarkiverse/temporal/TemporalConfigRelocateInterceptor.java
new file mode 100644
index 0000000..4b81d09
--- /dev/null
+++ b/extension/runtime/src/main/java/io/quarkiverse/temporal/TemporalConfigRelocateInterceptor.java
@@ -0,0 +1,74 @@
+package io.quarkiverse.temporal;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import io.smallrye.config.ConfigSourceInterceptor;
+import io.smallrye.config.ConfigSourceInterceptorContext;
+import io.smallrye.config.ConfigValue;
+
+public class TemporalConfigRelocateInterceptor implements ConfigSourceInterceptor {
+
+ @Override
+ public ConfigValue getValue(ConfigSourceInterceptorContext context, String name) {
+
+ if (name.equals("quarkus.grpc.clients.temporal-client.host")) {
+
+ ConfigValue host = context.proceed("quarkus.grpc.clients.temporal-client.host");
+ ConfigValue target = context.proceed("quarkus.temporal.connection.target");
+ if (host == null && target != null) {
+ String[] split = target.getValue().split(":");
+ return target.from()
+ .withName("quarkus.grpc.clients.temporal-client.host")
+ .withValue(split[0])
+ .build();
+ }
+ return host;
+ }
+
+ if (name.equals("quarkus.grpc.clients.temporal-client.port")) {
+
+ ConfigValue port = context.proceed("quarkus.grpc.clients.temporal-client.port");
+ ConfigValue target = context.proceed("quarkus.temporal.connection.target");
+ if (port == null && target != null) {
+ String[] split = target.getValue().split(":");
+ return target.from()
+ .withName("quarkus.grpc.clients.temporal-client.port")
+ .withValue(split[1])
+ .build();
+ }
+ return port;
+ }
+
+ if (name.equals("quarkus.grpc.clients.temporal-client.test-port")) {
+
+ ConfigValue port = context.proceed("quarkus.grpc.clients.temporal-client.test-port");
+ ConfigValue target = context.proceed("quarkus.temporal.connection.target");
+ if (port == null && target != null) {
+ String[] split = target.getValue().split(":");
+ return target.from()
+ .withName("quarkus.grpc.clients.temporal-client.test-port")
+ .withValue(split[1])
+ .build();
+ }
+ return port;
+ }
+
+ return context.proceed(name);
+ }
+
+ @Override
+ public Iterator iterateNames(ConfigSourceInterceptorContext context) {
+ Set names = new HashSet<>();
+ Iterator iterator = context.iterateNames();
+ while (iterator.hasNext()) {
+ names.add(iterator.next());
+ }
+ names.add("quarkus.grpc.clients.temporal-client.host");
+ names.add("quarkus.grpc.clients.temporal-client.port");
+ names.add("quarkus.grpc.clients.temporal-client.test-port");
+ return names.iterator();
+ }
+
+}
diff --git a/extension/runtime/src/main/java/io/quarkiverse/temporal/WorkflowClientRecorder.java b/extension/runtime/src/main/java/io/quarkiverse/temporal/WorkflowClientRecorder.java
index beac999..cda2b65 100644
--- a/extension/runtime/src/main/java/io/quarkiverse/temporal/WorkflowClientRecorder.java
+++ b/extension/runtime/src/main/java/io/quarkiverse/temporal/WorkflowClientRecorder.java
@@ -92,12 +92,11 @@ public WorkflowClientOptions createWorkflowClientOptions(
* Creates a new instance of {@link WorkflowClient} using the provided {@link WorkflowServiceStubs},
* context propagators, and telemetry settings.
*
- * @param serviceStubs The {@link WorkflowServiceStubs} used to connect to the Temporal service.
* @return A configured {@link WorkflowClient} instance.
*/
- public Function, WorkflowClient> createWorkflowClient(
- WorkflowServiceStubs serviceStubs) {
- return context -> WorkflowClient.newInstance(serviceStubs, createWorkflowClientOptions(context));
+ public Function, WorkflowClient> createWorkflowClient() {
+ return context -> WorkflowClient.newInstance(context.getInjectedReference(WorkflowServiceStubs.class),
+ createWorkflowClientOptions(context));
}
}
diff --git a/extension/runtime/src/main/java/io/quarkiverse/temporal/WorkflowServiceStubsRecorder.java b/extension/runtime/src/main/java/io/quarkiverse/temporal/WorkflowServiceStubsRecorder.java
index 171f4d3..1b774fa 100644
--- a/extension/runtime/src/main/java/io/quarkiverse/temporal/WorkflowServiceStubsRecorder.java
+++ b/extension/runtime/src/main/java/io/quarkiverse/temporal/WorkflowServiceStubsRecorder.java
@@ -1,16 +1,21 @@
package io.quarkiverse.temporal;
import java.time.Duration;
+import java.util.function.Function;
import com.uber.m3.tally.RootScopeBuilder;
import com.uber.m3.tally.Scope;
import com.uber.m3.tally.StatsReporter;
+import io.grpc.Channel;
+import io.grpc.ManagedChannel;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Metrics;
import io.quarkiverse.temporal.config.ConnectionRuntimeConfig;
import io.quarkiverse.temporal.config.RpcRetryRuntimeConfig;
import io.quarkiverse.temporal.config.TemporalRuntimeConfig;
+import io.quarkus.arc.SyntheticCreationalContext;
+import io.quarkus.grpc.GrpcClient;
import io.quarkus.runtime.annotations.Recorder;
import io.temporal.common.reporter.MicrometerClientStatsReporter;
import io.temporal.serviceclient.RpcRetryOptions;
@@ -44,7 +49,8 @@ public RpcRetryOptions createRpcRetryOptions(RpcRetryRuntimeConfig rpcRetry) {
return builder.build();
}
- public WorkflowServiceStubsOptions createWorkflowServiceStubsOptions(ConnectionRuntimeConfig connection,
+ public WorkflowServiceStubsOptions createWorkflowServiceStubsOptions(
+ ConnectionRuntimeConfig connection,
boolean isMicrometerEnabled) {
if (connection == null) {
return WorkflowServiceStubsOptions.getDefaultInstance();
@@ -69,10 +75,45 @@ public WorkflowServiceStubsOptions createWorkflowServiceStubsOptions(ConnectionR
return builder.build();
}
- public WorkflowServiceStubs createWorkflowServiceStubs(boolean micrometerSupported) {
+ public Function, WorkflowServiceStubs> createWorkflowServiceStubs(
+ boolean micrometerSupported) {
boolean isMicrometerEnabled = micrometerSupported && runtimeConfig.metricsEnabled();
- return WorkflowServiceStubs
+ return context -> WorkflowServiceStubs
.newServiceStubs(createWorkflowServiceStubsOptions(runtimeConfig.connection(), isMicrometerEnabled));
}
-}
\ No newline at end of file
+ public WorkflowServiceStubsOptions createQuarkusManagedWorkflowServiceStubsOptions(
+ SyntheticCreationalContext context,
+ ConnectionRuntimeConfig connection,
+ boolean isMicrometerEnabled) {
+ if (connection == null) {
+ return WorkflowServiceStubsOptions.getDefaultInstance();
+ }
+
+ Duration reportDuration = runtimeConfig.metricsReportInterval();
+ Scope scope = null;
+ if (isMicrometerEnabled && reportDuration.getSeconds() > 0) {
+ MeterRegistry registry = Metrics.globalRegistry;
+ StatsReporter reporter = new MicrometerClientStatsReporter(registry);
+ // set up a new scope, report every N seconds
+ scope = new RootScopeBuilder()
+ .reporter(reporter)
+ .reportEvery(com.uber.m3.util.Duration.ofSeconds(reportDuration.getSeconds()));
+ }
+
+ WorkflowServiceStubsOptions.Builder builder = WorkflowServiceStubsOptions.newBuilder()
+ .setChannel(
+ (ManagedChannel) context.getInjectedReference(Channel.class, GrpcClient.Literal.of("temporal-client")))
+ .setMetricsScope(scope)
+ .setRpcRetryOptions(createRpcRetryOptions(connection.rpcRetry()));
+ return builder.build();
+ }
+
+ public Function, WorkflowServiceStubs> createQuarkusManagedWorkflowServiceStubs(
+ boolean micrometerSupported) {
+ boolean isMicrometerEnabled = micrometerSupported && runtimeConfig.metricsEnabled();
+ return context -> WorkflowServiceStubs
+ .newServiceStubs(createQuarkusManagedWorkflowServiceStubsOptions(context, runtimeConfig.connection(),
+ isMicrometerEnabled));
+ }
+}
diff --git a/extension/runtime/src/main/java/io/quarkiverse/temporal/config/TemporalBuildtimeConfig.java b/extension/runtime/src/main/java/io/quarkiverse/temporal/config/TemporalBuildtimeConfig.java
index 69f8232..7b01a40 100644
--- a/extension/runtime/src/main/java/io/quarkiverse/temporal/config/TemporalBuildtimeConfig.java
+++ b/extension/runtime/src/main/java/io/quarkiverse/temporal/config/TemporalBuildtimeConfig.java
@@ -15,12 +15,24 @@
@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED)
public interface TemporalBuildtimeConfig {
+ enum ChannelType {
+ QUARKUS_MANAGED,
+ BUILT_IN
+ }
+
/**
* enable mock for testing
*/
@WithDefault("false")
Boolean enableMock();
+ /**
+ * either use a channel managed by temporal client (built-in) or use a channel managed by quarkus (quarkus-managed).
+ * In this case the channel can be configured using quarkus.grpc.clients.temporal-client.
+ */
+ @WithDefault("BUILT_IN")
+ ChannelType channelType();
+
/**
* If Temporal registers in the health check by pinging the service.
*/
diff --git a/extension/runtime/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceInterceptor b/extension/runtime/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceInterceptor
new file mode 100644
index 0000000..0ee66a2
--- /dev/null
+++ b/extension/runtime/src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceInterceptor
@@ -0,0 +1 @@
+io.quarkiverse.temporal.TemporalConfigRelocateInterceptor
\ No newline at end of file
diff --git a/test-extension/deployment/src/main/java/io/quarkiverse/temporal/test/deployment/TemporalTestProcessor.java b/test-extension/deployment/src/main/java/io/quarkiverse/temporal/test/deployment/TemporalTestProcessor.java
index 752896c..7977a88 100644
--- a/test-extension/deployment/src/main/java/io/quarkiverse/temporal/test/deployment/TemporalTestProcessor.java
+++ b/test-extension/deployment/src/main/java/io/quarkiverse/temporal/test/deployment/TemporalTestProcessor.java
@@ -2,12 +2,16 @@
import static io.quarkiverse.temporal.Constants.TEMPORAL_TESTING_CAPABILITY;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.enterprise.inject.Any;
+import jakarta.enterprise.inject.Instance;
import jakarta.inject.Singleton;
+import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.ClassType;
+import org.jboss.jandex.ParameterizedType;
import io.quarkiverse.temporal.deployment.TemporalProcessor;
-import io.quarkiverse.temporal.deployment.WorkflowClientBuildItem;
import io.quarkiverse.temporal.test.TestWorkflowRecorder;
import io.quarkus.arc.deployment.SyntheticBeanBuildItem;
import io.quarkus.deployment.annotations.BuildProducer;
@@ -17,6 +21,8 @@
import io.quarkus.deployment.builditem.CapabilityBuildItem;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.temporal.client.WorkflowClient;
+import io.temporal.common.context.ContextPropagator;
+import io.temporal.common.interceptors.WorkflowClientInterceptor;
import io.temporal.testing.TestWorkflowEnvironment;
import io.temporal.worker.WorkerFactory;
@@ -44,12 +50,23 @@ TestWorkflowEnvironmentBuildItem recordTestEnvironment(
@Record(ExecutionTime.RUNTIME_INIT)
@BuildStep(onlyIf = TemporalProcessor.EnableMock.class)
- WorkflowClientBuildItem recordWorkflowClient(
+ SyntheticBeanBuildItem recordWorkflowClient(
TestWorkflowEnvironmentBuildItem testWorkflowEnvironmentBuildItem,
TestWorkflowRecorder recorder) {
- return new WorkflowClientBuildItem(
- recorder.createTestWorkflowClient(testWorkflowEnvironmentBuildItem.testWorkflowEnvironment));
+ return SyntheticBeanBuildItem
+ .configure(WorkflowClient.class)
+ .scope(ApplicationScoped.class)
+ .unremovable()
+ .defaultBean()
+ .addInjectionPoint(
+ ParameterizedType.create(Instance.class, ClassType.create(WorkflowClientInterceptor.class)),
+ AnnotationInstance.builder(Any.class).build())
+ .addInjectionPoint(ParameterizedType.create(Instance.class, ClassType.create(ContextPropagator.class)),
+ AnnotationInstance.builder(Any.class).build())
+ .createWith(recorder.createTestWorkflowClient(testWorkflowEnvironmentBuildItem.testWorkflowEnvironment))
+ .setRuntimeInit()
+ .done();
}
@BuildStep(onlyIf = TemporalProcessor.EnableMock.class)
@@ -67,4 +84,4 @@ SyntheticBeanBuildItem produceWorkerFactorySyntheticBean(
.setRuntimeInit()
.done();
}
-}
\ No newline at end of file
+}