Architecture of complex web applications by Adel F
Author:Adel F [Adel F]
Language: eng
Format: epub
Publisher: leanpub.com
Published: 2019-03-12T00:00:00+00:00
Queues
Second problem - request execution time. Application should respond as fast as possible. Poll creation contains some heavy operations like sitemap update and external API calling. Common solution - postpone some actions using queues. Instead of executing some heavy action in the web request, the application can create a task to execute this action and put it to a queue. A queue can be a database table, Redis list or special queue solutions, like RabbitMQ. Laravel suggests several ways to work with queues. One of them: jobs. As I said before, usually there is one main action and some secondary actions. The main action here is creating a Poll object and it canât be executed without filtering texts. All post-actions can be executed later. Actually, in some rare cases when it takes too long, the whole application layer action can be executed in a queued job. But this is not our case.
final class SitemapGenerationJob implements ShouldQueue { public function handle() { // Call sitemap generator } } final class NotifyExternalApiJob implements ShouldQueue {} use Illuminate\Contracts\Bus\Dispatcher; final class PollService { /** @var Dispatcher */ private $dispatcher; public function __construct(..., Dispatcher $dispatcher) { ... $this->dispatcher = $dispatcher; } public function create(PollCreateDto $request) { $filteredRequest = $this->filterRequest($request); $poll = new Poll(); $this->connection->transaction(...); $this->dispatcher->dispatch( new SitemapGenerationJob()); $this->dispatcher->dispatch( new NotifyExternalApiJob($poll->id)); } }
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7807)
Grails in Action by Glen Smith Peter Ledbrook(7719)
Azure Containers Explained by Wesley Haakman & Richard Hooper(6804)
Configuring Windows Server Hybrid Advanced Services Exam Ref AZ-801 by Chris Gill(6801)
Running Windows Containers on AWS by Marcio Morales(6321)
Kotlin in Action by Dmitry Jemerov(5089)
Microsoft 365 Identity and Services Exam Guide MS-100 by Aaron Guilmette(5048)
Combating Crime on the Dark Web by Nearchos Nearchou(4621)
Microsoft Cybersecurity Architect Exam Ref SC-100 by Dwayne Natwick(4573)
Management Strategies for the Cloud Revolution: How Cloud Computing Is Transforming Business and Why You Can't Afford to Be Left Behind by Charles Babcock(4437)
The Ruby Workshop by Akshat Paul Peter Philips Dániel Szabó and Cheyne Wallace(4312)
The Age of Surveillance Capitalism by Shoshana Zuboff(3977)
Python for Security and Networking - Third Edition by José Manuel Ortega(3875)
The Ultimate Docker Container Book by Schenker Gabriel N.;(3533)
Learn Windows PowerShell in a Month of Lunches by Don Jones(3528)
Learn Wireshark by Lisa Bock(3491)
Mastering Python for Networking and Security by José Manuel Ortega(3376)
Mastering Azure Security by Mustafa Toroman and Tom Janetscheck(3353)
Blockchain Basics by Daniel Drescher(3322)
