Last active
October 28, 2015 08:13
-
-
Save farconada/d59445416bafd6a73b27 to your computer and use it in GitHub Desktop.
Async HTTP integration with PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
As a way to integrate microservices I want to use HTTP calls and avoid the use of a MQ (Message Queue). | |
If the app is small and contained in one host you could avoid the use of MQ. | |
Description of the scenario: | |
I have one app (made with Symfony. Call it MainApp) and one microservice (made with Sylex. Call MicroApp), both served using PHP-FPM NGINX | |
1) MainApp calls an URL POST /api/internal/do-something with Guzzle, | |
2) then MicroAPP do its work (it takes long) | |
3) MicroApp calls an URL from /api/internal/i-have-finished | |
To avoid keep MainApp waiting in 1). I've configured a very small guzzle timeout and it catches the exception. With this trick I have an Async HTTP call. | |
Are there any way to 2) in background without a MQ (and without anykind of worker proccess). | |
I'm tempted to use threads for 2) but I've read that they are only suitable for CLI (https://github.com/krakjoe/pthreads). | |
I've heard that Spring have async REST. | |
What's the best way to solve this scenario and avoid waiting for 2) ? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Silex after() isn't the solution but $app->finish() do the work pretty well