【问题标题】:Cadence ListOpenWorkflowExecutions always returns zeroCadence ListOpenWorkflowExecutions 始终返回零
【发布时间】:2020-09-11 15:16:12
【问题描述】:

我正在尝试使用 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());

【问题讨论】:

    标签: java cadence-workflow


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-24
      • 2019-09-10
      • 2020-09-10
      相关资源
      最近更新 更多