Hi,
I am trying to query the status of a workflow from another workflow for logging purposes. It is a production environment where one Temporal server and one temporal worker are run in separate container in a kubernetes environment. Using the examples
[samples-java/core/src/main/java/io/temporal/samples/hello/HelloSearchAttributes.java at main · temporalio/samples-java · GitHub](https://temporal sample code)
How can I get a workflow state/status from an external application in java?
I wrote the following snippet
WorkflowServiceStubs service = WorkflowServiceStubs.newInstance();
WorkflowServiceGrpc.WorkflowServiceBlockingStub stub = service.blockingStub();
DescribeWorkflowExecutionRequest request = DescribeWorkflowExecutionRequest.newBuilder()
.setExecution(WorkflowExecution.newBuilder().setWorkflowId(workflowId))
.build();
DescribeWorkflowExecutionResponse response = stub.describeWorkflowExecution(request);
WorkflowExecutionStatus workflowstatus = response.getWorkflowExecutionInfo().getStatus();
But when i run the code it gives a connection exception that says 127.0.0.1:7223 connection refused error.
Then i went through the temporal code and realized that its the default temporal option and that probably we need to give temporal server IP/Port to query. Then i wrote the following code
WorkflowServiceStubs service = new WorkflowServiceStubsImpl(null,
WorkflowServiceStubsOptions.newBuilder().setTarget(<TemporalServerIP> + ":" + <temporalPort>).build());
WorkflowServiceGrpc.WorkflowServiceBlockingStub stub = service.blockingStub();
DescribeWorkflowExecutionRequest request = DescribeWorkflowExecutionRequest.newBuilder()
.setExecution(WorkflowExecution.newBuilder().setWorkflowId(workflowId))
.setNamespace("default")
.build();
DescribeWorkflowExecutionResponse response = stub.describeWorkflowExecution(request);
workflowstatus = response.getWorkflowExecutionInfo().getStatus();
The above code works. But the question is
- Even if all the other workflows are running in the same worker, do we still need to provide the temporal server IP/Port for doing the status query? Since this code is executed from a workflow, my assumption, the temporal server details would be available to it already and there is no need to send it separately(like in second snippet). We do not set the temporal IP/PORT when we trigger child workflow from the parent workflow. Why this API requires it?
- Is there a problem with the first approach or it works only in the test environment? Did i make any mistake in the first block of code?