On Thu, Jul 15, 2010 at 09:22:47AM +0100, David Greaves wrote:
> 
> Well, using Ruote in an AMQP setting my expected usage is a little different:
>   http://wiki.meego.com/BOSS/Presentation - FYI.
> so this is to clarify that the solution above doesn't conflict with
> a semi-dynamic AMQP participant registration (and eventually
> de-registration) solution.
> 
> I see an analogy with a production sql database. You don't want to
> stop the database server and restart it when a new database is
> created. You need a mechanism to "create table".
> 
> AMQP has the launchitem listener which takes different types of
> message; currently 'definition' and 'receive'
>
> I propose supplementing that with 'register'
> 
> http://github.com/lbt/ruote-amqp/blob/register/lib/ruote-amqp/receiver.rb#L112-116

Hello David,

thanks for sharing information about your use case.

ruote-amqp is about communicating between an engine and a participant. Engine 
meits work towards participant, later on, the participant may reply. There is 
also the case where a participant emits work towards an engine (launch).

These are "work" operations.

What you are asking about is adding "admin" operations over that channel. I'm a 
bit reluctant.

> Eg:
> A Ruote instance is running on system A using a storage engine
> It has some registered processes in flow which are connected using
> amqp to participants on systems B (a build engine) and C (a data
> warehouse)
> This moves into production state.
> 
> A new business process is required.
> Participants for system D (test system) and E (reporting application) are 
> developed.
> Participants D and E start and register on the engine.
> A workflow can now be started without changing A.

OK, let's explore two different classes of solutions to that.

Class A is about using the decoupling AMQP provides, so that registering 
participants is not necessary, while class B is the straightforward exploration 
of "let's add participants to that engine".


== class A

Since there is AMQP between your engines and its participants...

It should be easy to stop your AMQP handlers and update them while ruote keeps 
pushing to the queue.

That requires a bit of "planification" and "forward thinking".


=== A.0 'amqp-x'

Let's register a participant under a regex :

  engine.register_participant 'amqp-.+', RuoteAMQP::Participant, 'queue' => 'y'

All the workitems for a participant whose name begins with 'command-' will go 
there.

If, behind the AMQP fence, you add a participant that handles workitem for 
amqp-potato, you can immediately start launching processes that reference it, 
no need to add register a new participant.


=== A.1 command :variant => 'x'

  engine.register_participant 'amqp', RuoteAMQP::Participant, 'queue' => 'y'

then in your process definition

  participant 'amqp', :variant => 'x'
  participant 'amqp', :variant => 'y'

The code that does the real particpant work looks at 
workitem.fields['params']['variant'] to determine what to do.


== class B

OK, so you really need to add participant to the engine.


=== B.0 programmatically adding

You have access to the engine. You can register participants on the fly :

  require 'my_participant'
  engine.register_participant 'toto', MyParticipant, 'flavour' => 'vanilla', 
'position' => -2 

( maybe with some help from

  
http://groups.google.com/group/ruby-talk-google/browse_frm/thread/60ef4f8cff701e14/26ae883a7cc1da7f

and

  http://github.com/jmettraux/ruote/blob/ruote0.9/lib/openwfe/util/irb.rb )


=== B.1 ruote-kit

Order over http to ruote-kit to register a participant

  POST /_ruote/participants HTTP/1.0
  Content-Type: application/json

  [ "toto" [ "MyParticipant", { "flavour": "vanilla", "position": -2 } ] ]

The only problem is that Torsten and I still have to integrate that into 
ruote-kit... Sorry.


=== B.2 modifying the participant-list in the storage directly

  require 'rubygems'
  require 'ruote'
  storage = Ruote::FsStorage.new('/var/ruote_storage')
  doc = storage.get('configurations', 'participant_list')
  doc['list'].insert(
    -2,
    [ "^toto$", [
      "MyParticipant",
      { 'flavour' => 'vanilla',
        'position' => -2,
        'require_path' => 'my_participant.rb' } ] ])
  storage.put(doc)

Please note that the upcoming ruote 2.1.11 has methods that simplify that 
approach :

  
http://github.com/jmettraux/ruote/commit/7cca2c77a7fceb151f7a3fe787b388425fa804c3

as announced in :

  http://groups.google.com/group/openwferu-users/msg/4e90738f92e797d5


No need to restart the engine.


Kind regards,

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