0

我正在尝试使用 WorkflowServiceTChannel 查询 ListOpenWorkflowExecutions。我总是得到 0 的 ListOpenWorkflowExecutionsResponse 大小。我无法弄清楚我哪里出错了。以下是我正在使用的 java 代码。

            IWorkflowService cadenceService = new WorkflowServiceTChannel(ipAddress, 7933); 
            
            // Start Window
            Calendar startCal = Calendar.getInstance();
            startCal.add(Calendar.HOUR_OF_DAY, -24);

            // End Window
            Calendar endCal = Calendar.getInstance();

            StartTimeFilter timeFilter = new StartTimeFilter();
            timeFilter.setEarliestTime(startCal.getTimeInMillis());
            timeFilter.setLatestTime(endCal.getTimeInMillis());
            ListOpenWorkflowExecutionsRequest request = new ListOpenWorkflowExecutionsRequest();
            request.setStartTimeFilter(timeFilter);
            request.setDomain("staging");
            ListOpenWorkflowExecutionsResponse response = 
            cadenceService.ListOpenWorkflowExecutions(request);
            System.out.println(response.getExecutionsSize());
4

1 回答 1

0

我想出了一个办法。时间戳应以纳米为单位,而不是以米尔为单位。以下代码对我有用。

感谢 Maxim 在 Cadence slack 频道上帮助我。

StartTimeFilter timeFilter = new StartTimeFilter();
            timeFilter.setEarliestTime(TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis() - 100000));
            timeFilter.setLatestTime(TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis() + 100000));
            ListOpenWorkflowExecutionsRequest request = new ListOpenWorkflowExecutionsRequest();
            request.setStartTimeFilter(timeFilter);
            request.setDomain(domain);
            ListOpenWorkflowExecutionsResponse response = cadenceService.ListOpenWorkflowExecutions(request);
            int openWorkflows = response.getExecutionsSize();
            LOG.info("open workflows - {}, domain - {}", openWorkflows, domain);

于 2020-09-11T02:38:13.660 回答