How to get Temporal client and service with TemporalProperties configuration

Hi,
the class TemporalProperties loads the configuration from application.yaml correctly.
however, when getting the client and service in order to query for running workflows as follows, those properties are not loaded to them (flor example, the host property):

val service = WorkflowServiceStubs.newInstance()
val client = WorkflowClient.newInstance(service)
...
...
val wfExecutionResponse = service.blockingStub().listWorkflowExecutions(listWorkflowExecutionRequest) // not working!!!
...
eventWorkflow = client.newWorkflowStub(EventBulkActionsMgr::class.java, workflowOptions) // not working!!!
....

What should I do in order to have service and client which load the TemporalProperties?

Thanks,
Shai

Can you give more info? Which TemporalProperties class are you referring to?
By default, if you don’t specify WorkflowServiceStubsOptions when you create your service it will use target 127.0.0.1:7233 for frontend service, see this sample for more info if you need to configure your client to point to your custom frontend service endpoint or set up mTLS.

// not working!!!

what are the errors you are getting in your code? Hard to tell without having more info.

Thanks for the fast response.

class TemporalServices:

package ai.applica.spring.boot.starter.temporal.config;
...
@ConfigurationProperties(
    prefix = "spring.temporal"
)
public class TemporalProperties {
    private String host;
    private Integer port;
    private Boolean useSsl;

The error that I get:

Caused by: io.grpc.netty.shaded.io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: /127.0.0.1:7233

the host configuration is:

spring:
  temporal:
    host: temporal.db-eks.dev.bizzabo.com
    port: 7233
    useSsl: false

With spring boot you typically would want to create a singleton or application scoped producer for your service and client that you can inject when you need to use them.

In your producers you would need to create WorkflowServiceStubsOptions and WorkflowClientOptions based on your application properties, again see this sample for more info.

val service = WorkflowServiceStubs.newInstance()
val client = WorkflowClient.newInstance(service)

This just uses the defaults (127.0.0.1:7233) as mentioned and it seems you have to set target to “temporal.db-eks.dev.bizzabo.com:7233” as described.

thanks!

will try and update

Shai

Hi,
Managed to create the service as follows:

               grpcChannel = ManagedChannelBuilder.forAddress(temporalProperties.host, temporalProperties.port)
                    .usePlaintext()
                    .build()
                val options = WorkflowServiceStubsOptions.newBuilder()
                    .setChannel(grpcChannel)
                    .build()
                val service = WorkflowServiceStubs.newInstance(options)

and still getting this error:

io.grpc.StatusRuntimeException: UNKNOWN: channel closed

why would the channel be closed?

Thanks,
Shai

the question is actually:
is there a way to get all parent executions, equivalent to the following API which is for child flows only?

public static Promise<WorkflowExecution> getWorkflowExecution(Object childWorkflowStub) 

Thanks,
Shai

grpcChannel = ManagedChannelBuilder.forAddress(temporalProperties.host, temporalProperties.port)
                    .usePlaintext()
                    .build()

Shouldn’t have to create ManagedChannelBuilder, you can do:

WorkflowServiceStubs service = WorkflowServiceStubs.newServiceStubs(
            WorkflowServiceStubsOptions.newBuilder()
                    .setTarget(temporalProperties.host + ":" + temporalProperties.port)
                    .build()
    );

The javadoc for Workflow.getWorkflowExecution says it should work for both childworkflow and external workflow stubs but seems it only atm works for childworkflow stubs. Opened issue here.