[Catalyst] May be asynchronous communication between Catalyst applications

James R. Leu jleu at mindspring.com
Sun Feb 24 16:16:20 GMT 2013


I do not have any suggestions about the App1 to App2 hand off
but perhaps my technique for handling async/long running requests
will help.

I solved my async requirements by using Catalyst::Plugin::Cache
and Catalyst::Plugin::RunAfterRequest.

First off, I have my catalyst apps setup to run as FCGI with many
children (50-100) depending on the app.  All the clients are implemented
in javascript and make periodic ajax requests.

In my catalyst actions that need to be async:
- check if the request contains a job id
- if so check the cache for the status of the job id
    - if the job is done, then return the results, and clear the cache
    - else return a response telling the client to come back later
- otherwise create a new cache entry and immediately return a job id
  to the client, and tell it to come back later
    - after the response is sent, using RunAfterRequest I start the
      long running action (in essence consuming this FCGI child
      for the duration of the long running action)
    - at the end of the RunAfterRequest action I update the cache
      with the results

You will need to choose a Catalyst::Plugin::Cache backend that
meets your need.

On Sun, Feb 24, 2013 at 10:41:16AM +0530, linuxsupport wrote:
> any other idea on this?
> 
> On Sat, Feb 23, 2013 at 12:31 PM, Francisco Obispo <fobispo at isc.org> wrote:
> 
> > I would probably use a message queue.
> >
> > Have you looked into RabbitMQ ?
> >
> > App 1 would be the producer, and you would have a consumer, responsible
> > for performing the operation on App 2.
> >
> >
> >
> >
> >
> > On Feb 22, 2013, at 10:40 PM, linuxsupport <lin.support at gmail.com> wrote:
> >
> > > Hi All,
> > >
> > > I need your help on the following scenario.
> > >
> > > I have 2 Catalyst apps, say App 1 and App 2
> > >
> > > Now, User access the App 1 and request something, App 1 then connect to
> > App 2 for the information but getting that information takes sometime lets
> > say 15 minutes.
> > >
> > > What I want to implement is that, App 1 checks the status of request
> > which was sent to App 2 every 2 minutes and once completed it gets the
> > response.
> > >
> > > Checking the status every 2 minutes can be controlled from the browser
> > using Ajax, client side code can send status request to App 1, App 1 can
> > forward this request to App 2, but how App2 will maintain the state and
> > keep the job running even if App 1 gets disconnect from App 2.
> > >
> > > Is there something similar to Ajax for Catalyst to Catalyst
> > communication?
> > >
> > > I can create a table on App 2 and store the request, and run a cron
> > script to process the request and update table with result, App 1 can then
> > pull the information from that table but looking for more elegant way to do
> > it.
> > >
> > > Thanks
> > >
> > > _______________________________________________
> > > List: Catalyst at lists.scsys.co.uk
> > > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> > > Searchable archive:
> > http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> > > Dev site: http://dev.catalyst.perl.org/
> >
> > Francisco Obispo
> > Director of Applications and Services - ISC
> > email: fobispo at isc.org
> > Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
> > PGP KeyID = B38DB1BE
> >
> >
> > _______________________________________________
> > List: Catalyst at lists.scsys.co.uk
> > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> > Searchable archive:
> > http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> > Dev site: http://dev.catalyst.perl.org/
> >


-- 
James R. Leu
jleu at mindspring.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20130224/7e8761cc/attachment.pgp


More information about the Catalyst mailing list