Class: Camunda::ExternalTask
- Includes:
- VariableSerialization
- Defined in:
- lib/camunda/external_task.rb
Class Method Summary collapse
- .fetch_and_lock(topics, lock_duration: nil, long_polling_duration: nil) ⇒ Object
- .lock_duration ⇒ Object
- .long_polling_duration ⇒ Object
- .max_polling_tasks ⇒ Object
Instance Method Summary collapse
- #bpmn_error(bpmn_exception) ⇒ Object
- #collection_path ⇒ Object
- #complete(variables = {}) ⇒ Object
- #failure(exception, input_variables) ⇒ Object
- #queue_task ⇒ Object
- #run_now ⇒ Object
- #task_class ⇒ Object
- #task_class_name ⇒ Object
- #variables ⇒ Object
- #worker_id ⇒ Object
Methods included from VariableSerialization
Methods inherited from Model
Class Method Details
.fetch_and_lock(topics, lock_duration: nil, long_polling_duration: nil) ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/camunda/external_task.rb', line 64 def self.fetch_and_lock(topics, lock_duration: nil, long_polling_duration: nil) long_polling_duration ||= long_polling_duration() lock_duration ||= lock_duration() topic_details = Array(topics).map do |topic| { topicName: topic, lockDuration: lock_duration } end fetchAndLock workerId: worker_id, maxTasks: max_polling_tasks, asyncResponseTimeout: long_polling_duration, topics: topic_details end |
.lock_duration ⇒ Object
16 17 18 |
# File 'lib/camunda/external_task.rb', line 16 def self.lock_duration Camunda::Workflow.configuration.lock_duration.in_milliseconds end |
.long_polling_duration ⇒ Object
8 9 10 |
# File 'lib/camunda/external_task.rb', line 8 def self.long_polling_duration Camunda::Workflow.configuration.long_polling_duration.in_milliseconds end |
.max_polling_tasks ⇒ Object
12 13 14 |
# File 'lib/camunda/external_task.rb', line 12 def self.max_polling_tasks Camunda::Workflow.configuration.max_polling_tasks end |
Instance Method Details
#bpmn_error(bpmn_exception) ⇒ Object
27 28 29 30 31 |
# File 'lib/camunda/external_task.rb', line 27 def bpmn_error(bpmn_exception) self.class.post_raw("#{collection_path}/#{id}/bpmnError", workerId: worker_id, variables: serialize_variables(bpmn_exception.variables), errorCode: bpmn_exception.error_code, errorMessage: bpmn_exception.)[:response] end |
#collection_path ⇒ Object
42 43 44 |
# File 'lib/camunda/external_task.rb', line 42 def collection_path self.class.collection_path end |
#complete(variables = {}) ⇒ Object
33 34 35 36 |
# File 'lib/camunda/external_task.rb', line 33 def complete(variables={}) self.class.post_raw("#{collection_path}/#{id}/complete", workerId: worker_id, variables: serialize_variables(variables))[:response] end |
#failure(exception, input_variables) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/camunda/external_task.rb', line 20 def failure(exception, input_variables) variables_information = "Input variables are #{input_variables.inspect}\n\n" self.class.post_raw("#{collection_path}/#{id}/failure", workerId: worker_id, errorMessage: exception., errorDetails: variables_information + exception.)[:response] end |
#queue_task ⇒ Object
56 57 58 |
# File 'lib/camunda/external_task.rb', line 56 def queue_task task_class.perform_later(id, variables) end |
#run_now ⇒ Object
60 61 62 |
# File 'lib/camunda/external_task.rb', line 60 def run_now task_class_name.safe_constantize.perform_now id, variables end |
#task_class ⇒ Object
78 79 80 81 82 |
# File 'lib/camunda/external_task.rb', line 78 def task_class task_class_name.safe_constantize.tap do |klass| raise Camunda::MissingImplementationClass, task_class_name unless klass end end |
#task_class_name ⇒ Object
74 75 76 |
# File 'lib/camunda/external_task.rb', line 74 def task_class_name "#{process_definition_key}::#{activity_id}" end |
#variables ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/camunda/external_task.rb', line 46 def variables super.transform_values do |details| if details['type'] == 'Json' JSON.parse(details['value']) else details['value'] end end end |
#worker_id ⇒ Object
38 39 40 |
# File 'lib/camunda/external_task.rb', line 38 def worker_id self.class.worker_id end |