Hi again,

In our project I'm launching processes via AMQP messages. We have placed the 
following in ruote-amqp/receiver.rb:

     # It is a launchitem if:
      #
      #  1. { "definition" : "Ruote.process_definition :name => 'test' 
do..." }
      #     or
      #  2. { "fields" : { "command" : 23, bike_id : 4e45340b563a } }
      #
      # Note there is NO "fei" key in 2. 
      #
      not_li = !(item.has_key?('definition') || 
(item['fields'].has_key?('command') if (item.has_key?('fields') && 
!item.has_key?('fei'))))

      return if @launchitems == :only && not_li
      return unless @launchitems || not_li

      if not_li
        receive(item) # workitem resumes in its process instance
      else
        launch(item) # new process instance launch
      end

and then...

    def launch(hash)
      # If key "command" is found within "fields", then its value is
      # used as process definition.
      #
      # Ruote::Engine#launch should be modified in order to check wheather a 
process definition
      # is just a number. In this case, it will read and launch a process 
definition stored in
      # a file.
      #
      # The following launchitem:
      #
      # { "fields" : { "command" : 11 } }
      #
      # should start process definition "/pdefs/11-lend-a-bike.rb"
      #
      # Process definitions should be named with the following pattern:
      #
      # <command_number>-<text_description>.rb
      #
      command = hash['fields']['command'].to_i if hash['fields']
      
      super(hash['definition'] || command, hash['fields'] || {}, 
hash['variables'] || {})
      
      #super(hash['definition'], hash['fields'] || {}, hash['variables'] || 
{})
    end

finally, in ruote/lib/ruote/parser.rb:

    def parse (definition)
      # If definition is just a number, search for it in pdefs directory and 
launch it.
      # e.g. definition = 11, launch process definition that is named 
'11-do-something.rb'
      #
      if definition.is_a? Integer
        puts "Definition: #{definition}"
        puts "Process: #{Dir.entries("../pdefs/").select {|i| 
i.match("^#{definition}-.*$")}[0]}"
        return parse(open("../pdefs/#{Dir.entries("../pdefs/").select {|i| 
i.match("^#{definition}-.*$")}[0]}").read)
      end

Now, I got as far as this point (since I got the Definition: and Process: 
messages). However, I now try to look at the web interface at 
http://magrathea:9292/_ruote/processes and I get the following stack trace:

NoMethodError: undefined method `attribute' for nil:NilClass
        /home/devel/Workflow/ruote/lib/ruote/engine/process_status.rb:165:in 
`definition_name'
       
 /home/devel/Workflow/ruote-kit/lib/ruote-kit/views/processes.html.haml:34:in 
`__tilt_a4bc8a60ab830dd037e1ccea1e18f6c0'
       
 /home/devel/Workflow/ruote-kit/lib/ruote-kit/views/processes.html.haml:29:in 
`each'
       
 /home/devel/Workflow/ruote-kit/lib/ruote-kit/views/processes.html.haml:29:in 
`__tilt_a4bc8a60ab830dd037e1ccea1e18f6c0'
       
 
/home/devel/.rvm/gems/jruby-1.5.2@gyokuro/gems/sinatra-1.0/lib/sinatra/tilt.rb:195:in
 
`evaluate'
       
 
/home/devel/.rvm/gems/jruby-1.5.2@gyokuro/gems/sinatra-1.0/lib/sinatra/tilt.rb:449:in
 
`evaluate'
       
 
/home/devel/.rvm/gems/jruby-1.5.2@gyokuro/gems/sinatra-1.0/lib/sinatra/tilt.rb:131:in
 
`render'
       
 
/home/devel/.rvm/gems/jruby-1.5.2@gyokuro/gems/sinatra-1.0/lib/sinatra/base.rb:343:in
 
`render'
(and so on and so forth... I assume the rest of the stack trace is 
pointless?)

Looking at process_status.rb, the offending line is:

root_expression.attribute('name') || root_expression.attribute_text

and if I look at root_expression I find:

    # Returns the expression at the root of the process instance.
    #
    def root_expression

      #@expressions.find { |e| e.fei.expid == '0' && e.fei.sub_wfid == nil }
        # vanilla implementation

      root_expressions.first
    end

    # Returns a list of all the expressions that have no parent expression.
    # The list is sorted with the deeper (closer to the original root) 
first.
    #
    def root_expressions
      roots = @expressions.select { |e| e.h.parent_id == nil }

      roots = roots.inject({}) { |h, e|
        h["#{e.h.fei['expid']}__#{e.h.fei['sub_wfid']}"] = e; h
      }

      roots.keys.sort.collect { |k| roots[k] }
    end

and doing a pp of the return value of root_expressions I see it's an empty 
list. So I guess something got messed up at some point, but now I don't know 
how to debug it further, or how to get Ruote working again. Any ideas?

Thanks!
-Mario.

-- 
you received this message because you are subscribed to the "ruote users" group.
to post : send email to [email protected]
to unsubscribe : send email to [email protected]
more options : http://groups.google.com/group/openwferu-users?hl=en

Reply via email to