Java sdk can't list workflows just like cli without elastic search

  • I am using mysql as database without elastic search

  • I am able to list workflows using “workflow list” command in cli where as "workflow list --query “workflowType=‘xyz’” fails with INVALID_ARGUMENT: Operation not support. Please use on ElasticSearch

  • But in java sdk, ListWorkflowExecutionsRequest api without query fails with same exception INVALID_ARGUMENT: Operation not support. Please use on ElasticSearch

  • So, my question is If we don’t use elasticSearch, ‘workflow list’ command works in cli without query , then why does it does not work with java sdk without query? I believe query parameter in ListWorkflowExecutionsRequest is non-nullable and by default an empty string, so it always fails if ES is not there. Can this be corrected if it is a bug??

  • How can I get list of all workflows without elastic search in java?

cli list without --query uses either ListOpenWorkflowExecutions or ListClosedWorkflowExecutions service APIs. Use these APIs from Java as well if you don’t have ES integration enabled.

I tried querying open workflows. I am not getting any results. can you tell me what wrong am I doing?

ListOpenWorkflowExecutionsResponse listOpenWorkflowExecutionsResponse = stub.listOpenWorkflowExecutions(ListOpenWorkflowExecutionsRequest.newBuilder()
                        .setNamespace(describeNamespaceResponse.getNamespaceInfo().getName())
                        .setStartTimeFilter(StartTimeFilter.newBuilder().setEarliestTime(Timestamps.fromMillis(
                                System.currentTimeMillis() - TimeUnit.DAYS.toMillis(14)) )
                                .setLatestTime(Timestamps.fromMillis(
                                System.currentTimeMillis()))
                                .build())
                        .setExecutionFilter(WorkflowExecutionFilter.getDefaultInstance()).build());

I believe time is in microseconds, not milliseconds.

Hi Maxim, I am using Timestamps.fromMillis() which is coverting milliseconds to Timestamp data type provided by google protobuff which is accepted by the function. So, if I am passing correct parameters, I am not sure if it would work!

You are right. I confused this with Cadence API that we improved by moving to protobuf.Timestamp.

It looks like you are setting WorkflowExecutionFilter without setting workflow instance. So it filters out all workflows. I removed it and it started to return results.

ListOpenWorkflowExecutionsResponse listOpenWorkflowExecutionsResponse = stub.listOpenWorkflowExecutions(ListOpenWorkflowExecutionsRequest.newBuilder()
                        .setNamespace(describeNamespaceResponse.getNamespaceInfo().getName())
                        .setStartTimeFilter(StartTimeFilter.newBuilder().setEarliestTime(Timestamps.fromMillis(
                                System.currentTimeMillis() - TimeUnit.DAYS.toMillis(14)) )
                                .setLatestTime(Timestamps.fromMillis(
                                System.currentTimeMillis()))
                                .build())).build());