Just dumps the incoming workitem in a file as a YAML String.
By default, this participant will not reply to the engine once the workitem got dumped to its file, but you can set its reply_anyway field to true to make it reply anyway...
Methods
public class
public instance
protected instance
Included modules
Attributes
| reply_anyway | [RW] | |
| workdir | [RW] |
Public class methods
The constructor expects as a unique optional param either the application_context either the ‘output’ dir for the participant.
# File lib/openwfe/participants/participants.rb, line 54 54: def initialize (context_or_dir=nil) 55: 56: @workdir = get_work_directory(context_or_dir) + '/out/' 57: 58: @reply_anyway = false 59: end
Public instance methods
The method called by the engine for each incoming workitem.
# File lib/openwfe/participants/participants.rb, line 64 64: def consume (workitem) 65: 66: FileUtils.mkdir_p(@workdir) unless File.exist?(@workdir) 67: 68: file_name = @workdir + determine_file_name(workitem) 69: 70: dump_to_file(file_name, workitem) 71: 72: reply_to_engine(workitem) if @reply_anyway 73: end
You can override this method to control into which file (name) each workitem gets dumped. You could even have a unique file for all workitems transiting through this participant.
# File lib/openwfe/participants/participants.rb, line 93 93: def determine_file_name (workitem) 94: 95: fei = workitem.fei 96: 97: OpenWFE::ensure_for_filename( 98: "#{fei.wfid}_#{fei.expression_id}__" + 99: "#{fei.workflow_definition_name}__" + 100: "#{fei.workflow_definition_revision}__" + 101: "#{workitem.participant_name}.yaml") 102: end
This method does the actual job of dumping the workitem (as some YAML to a file). It can be easily overriden.
# File lib/openwfe/participants/participants.rb, line 80 80: def dump_to_file (file_name, workitem) 81: 82: File.open(file_name, 'w') do |file| 83: file.print(encode_workitem(workitem)) 84: end 85: end
Protected instance methods
By default, uses YAML to serialize the workitem (of course you can override this method).
# File lib/openwfe/participants/participants.rb, line 110 110: def encode_workitem (wi) 111: YAML.dump(wi) 112: end