Cadence ListOpenWorkflowExecutions始终返回零

问题描述

我正在尝试使用WorkflowServiceTChannel查询ListOpenWorkflowExecutions。我总是将ListOpenWorkflowExecutionsResponse的大小设为0。我无法弄清楚哪里出了问题。以下是我正在使用的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());

解决方法

我想出了办法。时间戳记应以毫微秒为单位,而不是米。以下代码对我有用。

感谢Maxim帮助我在Cadence闲暇频道上演出。

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);

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...