Module: Camunda::ExternalTaskJob

Included in:
CamundaJob
Defined in:
lib/camunda/external_task_job.rb

Instance Method Summary collapse

Instance Method Details

#bpmn_perform(_variables) ⇒ Object

Raises:

  • (StandardError)


35
36
37
# File 'lib/camunda/external_task_job.rb', line 35

def bpmn_perform(_variables)
  raise StandardError, "Please define this method which takes a hash of variables and returns a hash of variables"
end

#perform(id, input_variables) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/camunda/external_task_job.rb', line 2

def perform(id, input_variables)
  output_variables = bpmn_perform(input_variables)
  output_variables = {} if output_variables.nil?
  raise ArgumentError, "Expected a hash, got #{output_variables}" unless output_variables.is_a?(Hash)

  report_completion id, output_variables
rescue Camunda::BpmnError => e
  report_bpmn_error id, e
rescue Camunda::ExternalTask::SubmissionError => e
  # We re-raise this so it is not rescued below
  raise e
rescue StandardError => e
  report_failure id, e, input_variables
end

#report_bpmn_error(id, exception) ⇒ Object



29
30
31
32
33
# File 'lib/camunda/external_task_job.rb', line 29

def report_bpmn_error(id, exception)
  # Submit bpmn error state to Camunda using
  # POST /external-task/{id}/bpmnError
  Camunda::ExternalTask.new(id: id).bpmn_error(exception)
end

#report_completion(id, variables) ⇒ Object



17
18
19
20
21
# File 'lib/camunda/external_task_job.rb', line 17

def report_completion(id, variables)
  # Submit to Camunda using
  # POST /external-task/{id}/complete
  Camunda::ExternalTask.new(id: id).complete(variables)
end

#report_failure(id, exception, input_variables) ⇒ Object



23
24
25
26
27
# File 'lib/camunda/external_task_job.rb', line 23

def report_failure(id, exception, input_variables)
  # Submit error state to Camunda using
  # POST /external-task/{id}/failure
  Camunda::ExternalTask.new(id: id).failure(exception, input_variables)
end