Skip to content

Instantly share code, notes, and snippets.

@ericsmith66
Created May 25, 2011 12:52
Show Gist options
  • Save ericsmith66/990909 to your computer and use it in GitHub Desktop.
Save ericsmith66/990909 to your computer and use it in GitHub Desktop.
onit workflow participant
class OnitParticipant < Ruote::StorageParticipant
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
def get_corporation_id(workitem)
corp_id = RuoteKit.engine.process(workitem.wfid).root_expressions.last.attribute('corporation_id') if workitem
corp_id || -1
end
def consume (workitem)
WorkItem.transaction do
begin
Rails.logger.info "********Consuming #{self.class.name} participant********"
corporation_id = get_corporation_id(workitem)
WorkItem.pend_work_item_record(workitem,corporation_id)
UserMailer.deliver_workitem_mailer(workitem) if workitem.fields['params']['mailer'].present?
super(workitem)
onit_consume(workitem)
Rails.logger.info "********Consumed #{self.class.name} participant********"
rescue => e
Rails.logger.warn e.inspect
Rails.logger.warn e.backtrace.inspect
raise e
end
end
end
def cancel(fei, flavour)
WorkItem.transaction do
begin
Rails.logger.info "********Canceling #{self.class.name} participant********"
workitem = WorkItem.wf_find_by_sid(fei.sid)
corporation_id = get_corporation_id(workitem)
WorkItem.cancel_work_item_record(workitem,corporation_id)
super(fei, flavour)
onit_cancel(fei, flavour)
Rails.logger.info "********Canceled #{self.class.name} participant********"
rescue => e
Rails.logger.warn e.inspect
Rails.logger.warn e.backtrace.inspect
raise e
end
end
end
def onit_consume(workitem)
false
end
def onit_cancel(fei, flavour)
false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment