The difference between workitem and stored_workitem

44 views
Skip to first unread message

ddeng

unread,
Jun 19, 2012, 2:38:13 PM6/19/12
to openwfe...@googlegroups.com
Hi, In the ProcessStatus class, there are two methods: workitems and stored_workitems

What is the difference?

John Mettraux

unread,
Jun 19, 2012, 2:45:03 PM6/19/12
to openwfe...@googlegroups.com
Hello,

copying the rdoc...

---8<---
# An array of the workitems currently in the storage participant for this
# process instance.
#
# Do not confuse with #workitems
#
attr_reader :stored_workitems

# Returns a list of the workitems currently 'out' to participants
#
# For example, with an instance of
#
# Ruote.process_definition do
# concurrence do
# alpha :task => 'clean car'
# bravo :task => 'sell car'
# end
# end
#
# calling engine.process(wfid).workitems will yield two workitems
# (alpha and bravo).
#
# Warning : do not confuse the workitems here with the workitems held
# in a storage participant or equivalent.
#
def workitems
--->8---


Best regards,

--
John Mettraux - http://lambda.io/jmettraux

ddeng

unread,
Jun 19, 2012, 2:49:08 PM6/19/12
to openwfe...@googlegroups.com
I tried this example, but in this case, stored_workitems will also returns 2 wokitems. Doesn't it?

John Mettraux

unread,
Jun 19, 2012, 2:53:16 PM6/19/12
to openwfe...@googlegroups.com

On Tue, Jun 19, 2012 at 11:49:08AM -0700, ddeng wrote:
>
> I tried this example, but in this case, stored_workitems will also returns
> 2 wokitems. Doesn't it?

What example, what case?

ddeng

unread,
Jun 19, 2012, 3:06:36 PM6/19/12
to openwfe...@googlegroups.com
def test_misc
      pdef = Ruote.process_definition do
         concurrence do
           alpha :task => 'clean car'
           bravo :task => 'sell car'
         end
      end

    @dashboard.register_participant ".+", Ruote::StorageParticipant
    wfid=@dashboard.launch(pdef)
    sleep(3)
    puts @dashboard.process(wfid).workitems.inspect
    puts "-----------"
    puts @dashboard.process(wfid).stored_workitems.inspect

  end

I this example, stored_workitems and workitems will both return two workitems

John Mettraux

unread,
Jun 19, 2012, 3:12:38 PM6/19/12
to openwfe...@googlegroups.com

On Tue, Jun 19, 2012 at 12:06:36PM -0700, ddeng wrote:
>
> def test_misc
> pdef = Ruote.process_definition do
> concurrence do
> alpha :task => 'clean car'
> bravo :task => 'sell car'
> end
> end
>
> @dashboard.register_participant ".+", Ruote::StorageParticipant
> wfid=@dashboard.launch(pdef)
> sleep(3)
> puts @dashboard.process(wfid).workitems.inspect
> puts "-----------"
> puts @dashboard.process(wfid).stored_workitems.inspect
>
> end
>
> I this example, stored_workitems and workitems will both return two
> workitems

Yes, since stored_workitems returns all the workitems for the process
instance that are "in the storage participant" and workitems returns all the
workitems that are currently being handled by participants (that include
storage participants).

If you have participants that, for example, dispatch work over AMQP and then
wait for an answer to come, the stored_workitems count will be lesser than
the workitems count (actually the stored_workitems count is always inferior
or equal to the workitems count).

If your participants are all storage participants, then the two counts are
equal.


Best regards,
Reply all
Reply to author
Forward
0 new messages