0

I have the following workflow I am looking for a Rails app:

  • Parse incoming request
  • Construct 3rd party web service request
  • Send 3rd party request
  • Enqueue a worker to process the expected response
  • Process the response once it arrives Send the parsed result back as a response

  • What are the models needed besides the data objects I am working with? (e.g. queues, workers, etc?)

  • Which of the standard Rails controllers do I need to re implement to accomplish this?

All results are passed via JSON.

Andrew Lauer Barinov
  • 5,694
  • 10
  • 59
  • 83
  • If you're going through a web app, you could do ajax methods to go to your own controllers to control data and output. I've done something similar for an app the specifically required frontend javascript/ajax, but could be done for this. – Eric C Aug 22 '12 at 21:25
  • This Rails app will have no front end, it will be called by other Rails apps / other types of servers (no client apps / no browsers) so I'd avoid using any js if I could – Andrew Lauer Barinov Aug 22 '12 at 21:38
  • http://stackoverflow.com/questions/6643964/asynchronous-http-request-in-ruby Does this help? – Eric C Aug 22 '12 at 21:42

1 Answers1

0

That step #4 - Enqueue a worker to process the expected response is the difficult one. Why not just queue up the job when you get the response?

To process the response outside the web app, my recommendation would be to queue up the worker to process the job, after you receive the response. This seems like the best route.

The only other way I can think of doing this, is creating another application to process the responses, and sending the 3rd party response to that application, and then sending the computed results back to your webapp.

Solomon
  • 6,145
  • 3
  • 25
  • 34
  • I see your point, but how do I make sure that associated data is retained between request and response? Is it persisted by resque do I need to persist it myself? – Andrew Lauer Barinov Aug 23 '12 at 04:46
  • this really depends on your specific use case. Say you are updating a user record with some of the data you get back. First, update the user with the data not needed from the 3rd party, then have your background worker send the request, get the response, and update the other information you need for that user. – Solomon Aug 23 '12 at 18:39