On Mon, Feb 07, 2011 at 10:21:21AM -0800, hcadavid wrote:
> 
> I'm looking for workflow engine alternatives, having the RESTFul
> approach in mind, and that's why I'm trying to understand how Route
> (OpenWFE) and related tools like Route-Kit/Route-Rest works. Such
> tools sounds very promising, but, despite the huge amount of
> documentation I've been reading over the net, I still have some
> questions to solve... (I'm a Ruby beginner too, so, please excuse me
> if my questions are too elemental)...

Hello Héctor,

don't make too long jumps.

> 1. Is it possible to use a RESTful service from a Ruote process,
> without such wrappers (route-kit/route-rest)?... if it is so, where
> can I find related documentation?

Sorry there is no documentation from that, once you know your Ruby tools and a 
bit of ruote you can work your way around.

Warning "RESTful" is a big word (see last answer).

Here is an example that interacts with a "REST" service, gets data from it and 
prints it out.

It's a self-contained example, you can save it to x.rb and do "ruby x.rb", it 
should work. The core part is the two participant implementations. As you can 
see it doesn't use ruote-kit.

  https://gist.github.com/815574

---8<---
require 'rubygems'
require 'open-uri'
require 'json'
require 'ruote'
require 'ruote/storage/fs_storage'

# An engine with a unique worker, operating with a FsStorage placed in
# the ruote_work/ dir.
#
engine = Ruote::Engine.new(
  Ruote::Worker.new(
    Ruote::FsStorage.new(
      'ruote_work')))

# Our initial process definition.
#
process_definition = Ruote.process_definition do
  get_last_tweets
  print_last_tweets
end

# Given a list of usernames in the incoming workitems, this participant
# GETs the last tweet for each of them and stores them in a 'messages'
# field.
#
class GetLastTweets
  include Ruote::LocalParticipant

  def consume(workitem)

    messages = workitem.fields['usernames'].collect do |username|

      data = open("http://twitter.com/users/#{username}.json";)
      json = Rufus::Json.decode(data)

      json['status']['text']
    end

    workitem.fields['messages'] = messages

    reply_to_engine(workitem)
  end
end

# Upon receiving a workitem, this participant prints the usernames and
# the messages gathered.
# Once could imagine emitting a PDF report or something like that.
#
class PrintLastTweets
  include Ruote::LocalParticipant

  def consume(workitem)

    puts '=' * 80
    workitem.fields['usernames'].each_with_index do |username, i|
      puts " - #{username} : #{workitem.fields['messages'][i]}"
    end
    puts '=' * 80

    reply_to_engine(workitem)
  end
end

# Registering the participants (linking participant names to
# participant implementations).
#
engine.register_participant 'get_last_tweets', GetLastTweets
engine.register_participant 'print_last_tweets', PrintLastTweets

engine.noisy = true
  # when true, the worker activity is displayed in the console
  # only useful in development and test mode.

# Launching 1 instance of our process definition
#
wfid = engine.launch(
  process_definition,
  'usernames' => [ 'jmettraux', 'radlepunktde' ]) # initial workitem fields

engine.wait_for(wfid)
  # prevent this ruby script from exiting before the process instance
  # is terminated (or encountered an error)
--->8---

There are lots of Ruby HTTP clients :

  https://github.com/nahi/httpclient
  https://github.com/archiloque/rest-client
  ...

The library used in this example is "open-uri" which is very handy for quickly 
GETting an HTTP resource representation.

If you know your Ruby and find libraries you like, you can quickly build what 
you need.


> 2. Is it possible to integrate human-related activities to the
> process, when such activities will be performed via web-application?,

Sorry, this depends on your requirements.

If you look at the example at

  http://ruote.rubyforge.org/implementing_participants.html#cancel

you will notice it places workitems in files. Nothing prevents you from passing 
files to human participants, or sending them emails, or printing faxes...

> ¿it could be done only via ruby-on-rails?

No, you are totally free to integrate ruote in your favourite web application 
platform.

Ruote-on-rails is an example Rails application based on ruote + ruote-kit.


> 3. I'm confusing about operating system-related limitations of Ruote.
> Which is the suugested OS, Windows/Linux, or it should work well on
> any of them?...

Ruote is developed mainly on MacOSX and GNU/Linux (Ubuntu), the Continuous 
Integration happens (http://ruote-ci.s3.amazonaws.com/ci.html) happens on 
Debian GNU/Linux.

Soon I hope to add JRuby to the continuous integration.

Windows should be OK. If you encounter issue, then please report it

  http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

People who deploy ruby servers on Windows are rare (or not talking much).


> some documents tells about a file-locking problems on
> Windows that limits the number of human interactions to a single
> actor.

This is a misinterpretation.

  http://ruote.rubyforge.org/configuration.html#storage

The Ruote::FsStorage implementation uses file locks. The ruby implementation 
used has no effect on Windows, so multiple workers are not possible (they would 
steal files from each other since they are not locked)

In a ruote technical context, "worker" means a software element that pulls 
piece of work and executes them (the sum of these pieces is the workflow 
execution). It doesn't mean "human participant" or "human actor".


> 4. Are there any book or website with additional information on how to
> start with Ruote and a RESTful approach?

The RESTful approach is a big thing. I suggest you take a look at those two 
books :

  http://oreilly.com/catalog/9780596529260/
  http://oreilly.com/catalog/9781449394943/

The second one is very good.

This might be shorter :

  http://martinfowler.com/articles/richardsonMaturityModel.html

How to start with ruote ? Increase your Ruby knowledge and then re-take a look 
at ruote maybe.


Best regards and welcome to ruote (and Ruby),

-- 
John Mettraux - http://jmettraux.wordpress.com

-- 
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