How can I list open workflows (Java)?

Greetings. Apologies if this is a trivial question. I cannot make WorkflowServiceStubs#listOpenWorkflowExecutions(…) return anything. I’m using the following:

ListOpenWorkflowExecutionsRequest request = ListOpenWorkflowExecutionsRequest.newBuilder()
    .setNamespace("default")
    .setStartTimeFilter(StartTimeFilter.newBuilder().setEarliestTime(0).build())
    .setTypeFilter(WorkflowTypeFilter.newBuilder().setName("TenantMigrationWorkflow"))
    .build();

ListOpenWorkflowExecutionsResponse response =
    WorkflowServiceStubs.newInstance(workflowServiceStubsOptions)
        .blockingStub()
        .listOpenWorkflowExecutions(request);

And attached is a console screenshot to prove that I have matching workflows.

I feel like I’ve done something stupid, but I can’t see it.

Any ideas?

Sean

1 Like

Hey some of these filters may not be compatible. We’re going to investigate on our side but can I ask if it works without any filters?

So Namespace and StartTimeFilter are required/mandated. If I try it without the StartTimeFilter, no workflow instances are returned (there were 3 running when I tried it).

I noticed that the UI is using http, should I just use that in the interim?

Sean

1 Like

What about without the type filter?

Temporal web does not yet support TLS.

The following worked for me while setting earliest time to 0 did not.

    ListOpenWorkflowExecutionsRequest request =
        ListOpenWorkflowExecutionsRequest.newBuilder()
            .setNamespace("default")
            .setStartTimeFilter(
                StartTimeFilter.newBuilder()
                    .setEarliestTime(
                        TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis() - 100000))
                    .setLatestTime(
                        TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis() + 10000))
                    .build())
            .setTypeFilter(WorkflowTypeFilter.newBuilder().setName("GreetingWorkflow"))
            .build();

Filed an issue to get this looked at.

1 Like

I tried a variation of that, setting to -1D and +1D and it didn’t work, I can try again. Thanks.