微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Cadence ListOpenWorkflowExecutions始终返回零

如何解决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);

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。