Sha256: 072076f63a4587c82c1a019cbea9f8c546f4f2596f621f0adee76fd7211031be

Contents?: true

Size: 1.32 KB

Versions: 4

Compression:

Stored size: 1.32 KB

Contents

# The poller will run as an infinite loop with long polling to fetch tasks, queue, and run them.
# Topic is the process definition key. Below will run the poller to fetch, lock, and queue a task for the
# example process definition with an id of CamundaWorkflow.
# @example
#   Camunda::Poller.fetch_and_queue %w[CamundaWorkflow]
class Camunda::Poller
  # @deprecated Please use {#fetch_and_queue} instead
  def self.fetch_and_execute(topics, lock_duration: nil, long_polling_duration: nil)
    warn "[DEPRECATION] `fetch_and_execute` is deprecated.  Please use `fetch_and_queue` instead."
    fetch_and_queue(topics, lock_duration: lock_duration, long_polling_duration: long_polling_duration)
  end

  # @param topics [Array] process definition keys
  # @param lock_duration [Integer] lock duration time, default time is set in Camunda::Workflow.configuration
  # @param long_polling_duration [Integer] long polling time, default is set to Camunda::Workflow.configuration
  def self.fetch_and_queue(topics, lock_duration: nil, long_polling_duration: nil)
    loop do
      Camunda::ExternalTask
        .fetch_and_lock(topics, lock_duration: lock_duration, long_polling_duration: long_polling_duration).each do |task|
        task.queue_task
      rescue Camunda::MissingImplementationClass => e
        task.failure(e)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
camunda-workflow-0.2.3 lib/camunda/poller.rb
camunda-workflow-0.2.2 lib/camunda/poller.rb
camunda-workflow-0.2.1 lib/camunda/poller.rb
camunda-workflow-0.2.0 lib/camunda/poller.rb