SlideShare a Scribd company logo
1 of 19
Download to read offline
abc/job-bundle
Background job processing bundle for Symfony
Wojciech
Ciołko
About me
• Software Engineer (PayPal, Rocket
Internet, AxelSpringer, PostCon,
AboutCoders, OSEC)
• Agile oriented architect and project
leader focused on scalability,
maintainability and performance
• I always try to deliver the best
quality combined with most relevant
technologies
Contact
• Twitter @WCiolko
• https://github.com/aboutcoders
• https://aboutcoders.com/
• http://osec.pl/
www.aboutcoders.com
The problem
• Synchronous processing blocks the application
• Processing takes time and resources
• Job processing often needs scaling
• Processing logic mixed with application code
AbcJobBundle
• A Symfony bundle to process jobs asynchronously
by simply annotating a method and registering the
class within the service container.
• https://github.com/aboutcoders/job-bundle
www.aboutcoders.com
Tech Specs
Features
• Asynchronous execution of jobs
• Status information about jobs
• Functionality to cancel, update, restart a job
• Repeated execution of jobs with schedules
• cron based expressions
• JSON REST-Api
• Support for multiple message queue systems:
• Doctrine, RabbitMQ, InMemory, Redis, Amazon SQS, Iron MQ, Pheanstalk
How to use it
• Install and configure following the docs
https://github.com/aboutcoders/job-bundle
• Create job class
• Register job in container
• Execute a job adding to job manager
Create a job
• Job is a regular PHP class
use AbcBundleJobBundleAnnotationParamType;

use AbcBundleJobBundleAnnotationReturnType;

use PsrLogLoggerInterface;



class DemoJob

{

/**

* @ParamType("to", type="string")

* @ParamType("logger", type="@abc.logger")

* @ReturnType("string")

*/

public function sayHello($to, LoggerInterface $logger)

{

$message = 'Hello ' . $to;



$logger->info($message);



return $message;

}

}
Register job
• Simple registration by Container tags
demo_job:

class: AppBundleJobDemoJob

tags:

- { name: "abc.job", type: "say_hello", method: "sayHello" }
Execute job
• To execute a job you need to add it to the job manager
use AbcBundleJobBundleJobMailerMessage;

use AbcBundleJobBundleJobManagerInterface;



// retrieve job manager from the container

/** @var ManagerInterface $manager */

$manager = $container->get('abc.job.manager');



// create a message

$message = new Message();

$message->setTo('mail@domain.tld');

$message->setFrom('mail@domain.tld');

$message->setSubject('Hello World');



// add job to the queue

$manager->addJob('abc_mailer', [$message]);
Job status information
• You can get current status of a job
• You can get associated log messages
// get log messages of a job

$logs = $manager->getLogs($job->getTicket());
Serialization of parameters
• When a job is persisted to the database
• REST-Api
• The AbcJobBundle uses the JMS serializer by default for serialization
• You can configure serialization options for the parameters and return value of a job
/**

* @ParamType("entity", type="MyBundleExampleBundleEntityMyEntity",
options={"groups"={"primarykey"}, "version"="1"})

* @ReturnType("MyBundleExampleBundleModelSomeObject",
options={"groups"={"mygroup"}, "version"="2")

*/

public function doSomething($entity){
…
}
Scheduled jobs
• You can configure one or more schedules for a job in order to
configure repeated execution of a job.
• The bundle relies on the AbcSchedulerBundle to provide
this functionality.
//use builder

$job = JobBuilder::create('my_job')

->addSchedule('cron', '1 * * * *')

->addSchedule('cron', '30 * * * *')

->build();



//create schedule

$schedule = ScheduleBuilder::create('cron', '1 * * * *');



//remove schedule

$job->removeSchedule($schedule);
Consume messages
• Symfony command
• From your code
php bin/console abc:job:consume default
// retrieve job manager from the container

$consumer = $container->get('abc.job.consumer');



$consumer->consume('default', [

'max-iterations' => 250

]);
REST-API
The AbcJobBundle ships with a JSON REST-API
Clustered Environment
• AbcJobBundle integrates concept of a resource
lock.
• This feature is disabled by default. In order to
enable it you have to install the
AbcResourceLockBundle
Demo
https://github.com/aboutcoders/job-bundle-skeleton-app
Contact
• Twitter @WCiolko
• https://github.com/aboutcoders
• https://aboutcoders.com/
• http://osec.pl/
www.aboutcoders.com
Contact
• Twitter @WCiolko
• https://github.com/aboutcoders
• https://aboutcoders.com/
• http://osec.pl/

More Related Content

What's hot

Your first sinatra app
Your first sinatra appYour first sinatra app
Your first sinatra appRubyc Slides
 
정오의 데이트 for iOS 코드 정리
정오의 데이트 for iOS 코드 정리정오의 데이트 for iOS 코드 정리
정오의 데이트 for iOS 코드 정리태준 김
 
Phoenix demysitify, with fun
Phoenix demysitify, with funPhoenix demysitify, with fun
Phoenix demysitify, with funTai An Su
 
AngularJS for Java Developers
AngularJS for Java DevelopersAngularJS for Java Developers
AngularJS for Java DevelopersLoc Nguyen
 
Rethinking Best Practices
Rethinking Best PracticesRethinking Best Practices
Rethinking Best Practicesfloydophone
 
1時間で作るマッシュアップサービス(関西版)
1時間で作るマッシュアップサービス(関西版)1時間で作るマッシュアップサービス(関西版)
1時間で作るマッシュアップサービス(関西版)Yuichiro MASUI
 
Reacting to the Isomorphic Buzz
Reacting to the Isomorphic BuzzReacting to the Isomorphic Buzz
Reacting to the Isomorphic BuzzBruce Coddington
 
Python for AngularJS
Python for AngularJSPython for AngularJS
Python for AngularJSJeff Schenck
 
Laravel Beginners Tutorial 2
Laravel Beginners Tutorial 2Laravel Beginners Tutorial 2
Laravel Beginners Tutorial 2Vikas Chauhan
 
Xcode Server & Xcode 7 Bots
Xcode Server & Xcode 7 Bots Xcode Server & Xcode 7 Bots
Xcode Server & Xcode 7 Bots Steven Forbes
 
[JCConf 2020] 用 Kotlin 跨入 Serverless 世代
[JCConf 2020] 用 Kotlin 跨入 Serverless 世代[JCConf 2020] 用 Kotlin 跨入 Serverless 世代
[JCConf 2020] 用 Kotlin 跨入 Serverless 世代Shengyou Fan
 
Deploying a Location-Aware Ember Application
Deploying a Location-Aware Ember ApplicationDeploying a Location-Aware Ember Application
Deploying a Location-Aware Ember ApplicationBen Limmer
 
Great Developers Steal
Great Developers StealGreat Developers Steal
Great Developers StealBen Scofield
 
REST Web Service? No, GraphQL please!
REST Web Service? No, GraphQL please!REST Web Service? No, GraphQL please!
REST Web Service? No, GraphQL please!Dimitri Gielis
 
Building Cloud Castles
Building Cloud CastlesBuilding Cloud Castles
Building Cloud CastlesBen Scofield
 
Building Cloud Castles - LRUG
Building Cloud Castles - LRUGBuilding Cloud Castles - LRUG
Building Cloud Castles - LRUGBen Scofield
 
FITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript DebuggingFITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript DebuggingRami Sayar
 

What's hot (20)

Your first sinatra app
Your first sinatra appYour first sinatra app
Your first sinatra app
 
정오의 데이트 for iOS 코드 정리
정오의 데이트 for iOS 코드 정리정오의 데이트 for iOS 코드 정리
정오의 데이트 for iOS 코드 정리
 
Phoenix demysitify, with fun
Phoenix demysitify, with funPhoenix demysitify, with fun
Phoenix demysitify, with fun
 
Rack
RackRack
Rack
 
AngularJS for Java Developers
AngularJS for Java DevelopersAngularJS for Java Developers
AngularJS for Java Developers
 
Rethinking Best Practices
Rethinking Best PracticesRethinking Best Practices
Rethinking Best Practices
 
1時間で作るマッシュアップサービス(関西版)
1時間で作るマッシュアップサービス(関西版)1時間で作るマッシュアップサービス(関西版)
1時間で作るマッシュアップサービス(関西版)
 
Reacting to the Isomorphic Buzz
Reacting to the Isomorphic BuzzReacting to the Isomorphic Buzz
Reacting to the Isomorphic Buzz
 
Catalyst MVC
Catalyst MVCCatalyst MVC
Catalyst MVC
 
Python for AngularJS
Python for AngularJSPython for AngularJS
Python for AngularJS
 
Laravel Beginners Tutorial 2
Laravel Beginners Tutorial 2Laravel Beginners Tutorial 2
Laravel Beginners Tutorial 2
 
webworkers
webworkerswebworkers
webworkers
 
Xcode Server & Xcode 7 Bots
Xcode Server & Xcode 7 Bots Xcode Server & Xcode 7 Bots
Xcode Server & Xcode 7 Bots
 
[JCConf 2020] 用 Kotlin 跨入 Serverless 世代
[JCConf 2020] 用 Kotlin 跨入 Serverless 世代[JCConf 2020] 用 Kotlin 跨入 Serverless 世代
[JCConf 2020] 用 Kotlin 跨入 Serverless 世代
 
Deploying a Location-Aware Ember Application
Deploying a Location-Aware Ember ApplicationDeploying a Location-Aware Ember Application
Deploying a Location-Aware Ember Application
 
Great Developers Steal
Great Developers StealGreat Developers Steal
Great Developers Steal
 
REST Web Service? No, GraphQL please!
REST Web Service? No, GraphQL please!REST Web Service? No, GraphQL please!
REST Web Service? No, GraphQL please!
 
Building Cloud Castles
Building Cloud CastlesBuilding Cloud Castles
Building Cloud Castles
 
Building Cloud Castles - LRUG
Building Cloud Castles - LRUGBuilding Cloud Castles - LRUG
Building Cloud Castles - LRUG
 
FITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript DebuggingFITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript Debugging
 

Viewers also liked

Asynchroniczny PHP i komunikacja czasu rzeczywistego z wykorzystaniem websocketw
Asynchroniczny PHP i komunikacja czasu rzeczywistego z wykorzystaniem websocketwAsynchroniczny PHP i komunikacja czasu rzeczywistego z wykorzystaniem websocketw
Asynchroniczny PHP i komunikacja czasu rzeczywistego z wykorzystaniem websocketwLuke Adamczewski
 
Przetwarzanie asynchroniczne w zastosowaniach webowych
Przetwarzanie asynchroniczne w zastosowaniach webowychPrzetwarzanie asynchroniczne w zastosowaniach webowych
Przetwarzanie asynchroniczne w zastosowaniach webowychleafnode
 
Asynchronous processing with PHP and Symfony2. Do it simple
Asynchronous processing with PHP and Symfony2. Do it simpleAsynchronous processing with PHP and Symfony2. Do it simple
Asynchronous processing with PHP and Symfony2. Do it simpleKirill Chebunin
 
New Symfony Tips & Tricks (SymfonyCon Paris 2015)
New Symfony Tips & Tricks (SymfonyCon Paris 2015)New Symfony Tips & Tricks (SymfonyCon Paris 2015)
New Symfony Tips & Tricks (SymfonyCon Paris 2015)Javier Eguiluz
 
Write microservice in golang
Write microservice in golangWrite microservice in golang
Write microservice in golangBo-Yi Wu
 
Symfony tips and tricks
Symfony tips and tricksSymfony tips and tricks
Symfony tips and tricksJavier Eguiluz
 

Viewers also liked (8)

Asynchroniczny PHP i komunikacja czasu rzeczywistego z wykorzystaniem websocketw
Asynchroniczny PHP i komunikacja czasu rzeczywistego z wykorzystaniem websocketwAsynchroniczny PHP i komunikacja czasu rzeczywistego z wykorzystaniem websocketw
Asynchroniczny PHP i komunikacja czasu rzeczywistego z wykorzystaniem websocketw
 
Przetwarzanie asynchroniczne w zastosowaniach webowych
Przetwarzanie asynchroniczne w zastosowaniach webowychPrzetwarzanie asynchroniczne w zastosowaniach webowych
Przetwarzanie asynchroniczne w zastosowaniach webowych
 
Asynchronous processing with PHP and Symfony2. Do it simple
Asynchronous processing with PHP and Symfony2. Do it simpleAsynchronous processing with PHP and Symfony2. Do it simple
Asynchronous processing with PHP and Symfony2. Do it simple
 
30 Symfony Best Practices
30 Symfony Best Practices30 Symfony Best Practices
30 Symfony Best Practices
 
Golang for OO Programmers
Golang for OO ProgrammersGolang for OO Programmers
Golang for OO Programmers
 
New Symfony Tips & Tricks (SymfonyCon Paris 2015)
New Symfony Tips & Tricks (SymfonyCon Paris 2015)New Symfony Tips & Tricks (SymfonyCon Paris 2015)
New Symfony Tips & Tricks (SymfonyCon Paris 2015)
 
Write microservice in golang
Write microservice in golangWrite microservice in golang
Write microservice in golang
 
Symfony tips and tricks
Symfony tips and tricksSymfony tips and tricks
Symfony tips and tricks
 

Similar to Symfony bundle fo asynchronous job processing

Complex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBoxComplex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBoxbobmcwhirter
 
Webinar: What's new in the .NET Driver
Webinar: What's new in the .NET DriverWebinar: What's new in the .NET Driver
Webinar: What's new in the .NET DriverMongoDB
 
CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009Jason Davies
 
Concurrency at the Database Layer
Concurrency at the Database Layer Concurrency at the Database Layer
Concurrency at the Database Layer mcwilson1
 
Node.js Patterns for Discerning Developers
Node.js Patterns for Discerning DevelopersNode.js Patterns for Discerning Developers
Node.js Patterns for Discerning Developerscacois
 
Web Worker, Service Worker and Worklets
Web Worker, Service Worker and WorkletsWeb Worker, Service Worker and Worklets
Web Worker, Service Worker and WorkletsKeshav Gupta
 
Refactoring @ Mindvalley: Smells, Techniques and Patterns
Refactoring @ Mindvalley: Smells, Techniques and PatternsRefactoring @ Mindvalley: Smells, Techniques and Patterns
Refactoring @ Mindvalley: Smells, Techniques and PatternsTristan Gomez
 
Ansible benelux meetup - Amsterdam 27-5-2015
Ansible benelux meetup - Amsterdam 27-5-2015Ansible benelux meetup - Amsterdam 27-5-2015
Ansible benelux meetup - Amsterdam 27-5-2015Pavel Chunyayev
 
Rails 3 (beta) Roundup
Rails 3 (beta) RoundupRails 3 (beta) Roundup
Rails 3 (beta) RoundupWayne Carter
 
DjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling DisqusDjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling Disquszeeg
 
Back to the 90s' - Revenge of the static website
Back to the 90s' - Revenge of the static websiteBack to the 90s' - Revenge of the static website
Back to the 90s' - Revenge of the static websiteYves Goeleven
 
Introduction to Apache Ant
Introduction to Apache AntIntroduction to Apache Ant
Introduction to Apache AntShih-Hsiang Lin
 
Synchronize applications with akeneo/batch
Synchronize applications with akeneo/batchSynchronize applications with akeneo/batch
Synchronize applications with akeneo/batchgplanchat
 
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...bobmcwhirter
 

Similar to Symfony bundle fo asynchronous job processing (20)

CakePHP
CakePHPCakePHP
CakePHP
 
Complex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBoxComplex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBox
 
Webinar: What's new in the .NET Driver
Webinar: What's new in the .NET DriverWebinar: What's new in the .NET Driver
Webinar: What's new in the .NET Driver
 
JS Essence
JS EssenceJS Essence
JS Essence
 
CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009
 
Wider than rails
Wider than railsWider than rails
Wider than rails
 
Celery with python
Celery with pythonCelery with python
Celery with python
 
Concurrency at the Database Layer
Concurrency at the Database Layer Concurrency at the Database Layer
Concurrency at the Database Layer
 
Node.js Patterns for Discerning Developers
Node.js Patterns for Discerning DevelopersNode.js Patterns for Discerning Developers
Node.js Patterns for Discerning Developers
 
Web Worker, Service Worker and Worklets
Web Worker, Service Worker and WorkletsWeb Worker, Service Worker and Worklets
Web Worker, Service Worker and Worklets
 
Refactoring @ Mindvalley: Smells, Techniques and Patterns
Refactoring @ Mindvalley: Smells, Techniques and PatternsRefactoring @ Mindvalley: Smells, Techniques and Patterns
Refactoring @ Mindvalley: Smells, Techniques and Patterns
 
COScheduler
COSchedulerCOScheduler
COScheduler
 
Node.js
Node.jsNode.js
Node.js
 
Ansible benelux meetup - Amsterdam 27-5-2015
Ansible benelux meetup - Amsterdam 27-5-2015Ansible benelux meetup - Amsterdam 27-5-2015
Ansible benelux meetup - Amsterdam 27-5-2015
 
Rails 3 (beta) Roundup
Rails 3 (beta) RoundupRails 3 (beta) Roundup
Rails 3 (beta) Roundup
 
DjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling DisqusDjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling Disqus
 
Back to the 90s' - Revenge of the static website
Back to the 90s' - Revenge of the static websiteBack to the 90s' - Revenge of the static website
Back to the 90s' - Revenge of the static website
 
Introduction to Apache Ant
Introduction to Apache AntIntroduction to Apache Ant
Introduction to Apache Ant
 
Synchronize applications with akeneo/batch
Synchronize applications with akeneo/batchSynchronize applications with akeneo/batch
Synchronize applications with akeneo/batch
 
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
 

Recently uploaded

Genshin Impact PPT Template by EaTemp.pptx
Genshin Impact PPT Template by EaTemp.pptxGenshin Impact PPT Template by EaTemp.pptx
Genshin Impact PPT Template by EaTemp.pptxJohnree4
 
SBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation TrackSBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation TrackSebastiano Panichella
 
SaaStr Workshop Wednesday w/ Kyle Norton, Owner.com
SaaStr Workshop Wednesday w/ Kyle Norton, Owner.comSaaStr Workshop Wednesday w/ Kyle Norton, Owner.com
SaaStr Workshop Wednesday w/ Kyle Norton, Owner.comsaastr
 
RACHEL-ANN M. TENIBRO PRODUCT RESEARCH PRESENTATION
RACHEL-ANN M. TENIBRO PRODUCT RESEARCH PRESENTATIONRACHEL-ANN M. TENIBRO PRODUCT RESEARCH PRESENTATION
RACHEL-ANN M. TENIBRO PRODUCT RESEARCH PRESENTATIONRachelAnnTenibroAmaz
 
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...Krijn Poppe
 
INDIAN GCP GUIDELINE. for Regulatory affair 1st sem CRR
INDIAN GCP GUIDELINE. for Regulatory  affair 1st sem CRRINDIAN GCP GUIDELINE. for Regulatory  affair 1st sem CRR
INDIAN GCP GUIDELINE. for Regulatory affair 1st sem CRRsarwankumar4524
 
Work Remotely with Confluence ACE 2.pptx
Work Remotely with Confluence ACE 2.pptxWork Remotely with Confluence ACE 2.pptx
Work Remotely with Confluence ACE 2.pptxmavinoikein
 
Simulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with AerialistSimulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with AerialistSebastiano Panichella
 
PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.
PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.
PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.KathleenAnnCordero2
 
Quality by design.. ppt for RA (1ST SEM
Quality by design.. ppt for  RA (1ST SEMQuality by design.. ppt for  RA (1ST SEM
Quality by design.. ppt for RA (1ST SEMCharmi13
 
The 3rd Intl. Workshop on NL-based Software Engineering
The 3rd Intl. Workshop on NL-based Software EngineeringThe 3rd Intl. Workshop on NL-based Software Engineering
The 3rd Intl. Workshop on NL-based Software EngineeringSebastiano Panichella
 
Anne Frank A Beacon of Hope amidst darkness ppt.pptx
Anne Frank A Beacon of Hope amidst darkness ppt.pptxAnne Frank A Beacon of Hope amidst darkness ppt.pptx
Anne Frank A Beacon of Hope amidst darkness ppt.pptxnoorehahmad
 
Mathan flower ppt.pptx slide orchids ✨🌸
Mathan flower ppt.pptx slide orchids ✨🌸Mathan flower ppt.pptx slide orchids ✨🌸
Mathan flower ppt.pptx slide orchids ✨🌸mathanramanathan2005
 
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...marjmae69
 
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...漢銘 謝
 
Event 4 Introduction to Open Source.pptx
Event 4 Introduction to Open Source.pptxEvent 4 Introduction to Open Source.pptx
Event 4 Introduction to Open Source.pptxaryanv1753
 
Call Girls In Aerocity 🤳 Call Us +919599264170
Call Girls In Aerocity 🤳 Call Us +919599264170Call Girls In Aerocity 🤳 Call Us +919599264170
Call Girls In Aerocity 🤳 Call Us +919599264170Escort Service
 
Dutch Power - 26 maart 2024 - Henk Kras - Circular Plastics
Dutch Power - 26 maart 2024 - Henk Kras - Circular PlasticsDutch Power - 26 maart 2024 - Henk Kras - Circular Plastics
Dutch Power - 26 maart 2024 - Henk Kras - Circular PlasticsDutch Power
 
The Ten Facts About People With Autism Presentation
The Ten Facts About People With Autism PresentationThe Ten Facts About People With Autism Presentation
The Ten Facts About People With Autism PresentationNathan Young
 
PHYSICS PROJECT BY MSC - NANOTECHNOLOGY
PHYSICS PROJECT BY MSC  - NANOTECHNOLOGYPHYSICS PROJECT BY MSC  - NANOTECHNOLOGY
PHYSICS PROJECT BY MSC - NANOTECHNOLOGYpruthirajnayak525
 

Recently uploaded (20)

Genshin Impact PPT Template by EaTemp.pptx
Genshin Impact PPT Template by EaTemp.pptxGenshin Impact PPT Template by EaTemp.pptx
Genshin Impact PPT Template by EaTemp.pptx
 
SBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation TrackSBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation Track
 
SaaStr Workshop Wednesday w/ Kyle Norton, Owner.com
SaaStr Workshop Wednesday w/ Kyle Norton, Owner.comSaaStr Workshop Wednesday w/ Kyle Norton, Owner.com
SaaStr Workshop Wednesday w/ Kyle Norton, Owner.com
 
RACHEL-ANN M. TENIBRO PRODUCT RESEARCH PRESENTATION
RACHEL-ANN M. TENIBRO PRODUCT RESEARCH PRESENTATIONRACHEL-ANN M. TENIBRO PRODUCT RESEARCH PRESENTATION
RACHEL-ANN M. TENIBRO PRODUCT RESEARCH PRESENTATION
 
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
 
INDIAN GCP GUIDELINE. for Regulatory affair 1st sem CRR
INDIAN GCP GUIDELINE. for Regulatory  affair 1st sem CRRINDIAN GCP GUIDELINE. for Regulatory  affair 1st sem CRR
INDIAN GCP GUIDELINE. for Regulatory affair 1st sem CRR
 
Work Remotely with Confluence ACE 2.pptx
Work Remotely with Confluence ACE 2.pptxWork Remotely with Confluence ACE 2.pptx
Work Remotely with Confluence ACE 2.pptx
 
Simulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with AerialistSimulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with Aerialist
 
PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.
PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.
PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.
 
Quality by design.. ppt for RA (1ST SEM
Quality by design.. ppt for  RA (1ST SEMQuality by design.. ppt for  RA (1ST SEM
Quality by design.. ppt for RA (1ST SEM
 
The 3rd Intl. Workshop on NL-based Software Engineering
The 3rd Intl. Workshop on NL-based Software EngineeringThe 3rd Intl. Workshop on NL-based Software Engineering
The 3rd Intl. Workshop on NL-based Software Engineering
 
Anne Frank A Beacon of Hope amidst darkness ppt.pptx
Anne Frank A Beacon of Hope amidst darkness ppt.pptxAnne Frank A Beacon of Hope amidst darkness ppt.pptx
Anne Frank A Beacon of Hope amidst darkness ppt.pptx
 
Mathan flower ppt.pptx slide orchids ✨🌸
Mathan flower ppt.pptx slide orchids ✨🌸Mathan flower ppt.pptx slide orchids ✨🌸
Mathan flower ppt.pptx slide orchids ✨🌸
 
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...
 
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...
 
Event 4 Introduction to Open Source.pptx
Event 4 Introduction to Open Source.pptxEvent 4 Introduction to Open Source.pptx
Event 4 Introduction to Open Source.pptx
 
Call Girls In Aerocity 🤳 Call Us +919599264170
Call Girls In Aerocity 🤳 Call Us +919599264170Call Girls In Aerocity 🤳 Call Us +919599264170
Call Girls In Aerocity 🤳 Call Us +919599264170
 
Dutch Power - 26 maart 2024 - Henk Kras - Circular Plastics
Dutch Power - 26 maart 2024 - Henk Kras - Circular PlasticsDutch Power - 26 maart 2024 - Henk Kras - Circular Plastics
Dutch Power - 26 maart 2024 - Henk Kras - Circular Plastics
 
The Ten Facts About People With Autism Presentation
The Ten Facts About People With Autism PresentationThe Ten Facts About People With Autism Presentation
The Ten Facts About People With Autism Presentation
 
PHYSICS PROJECT BY MSC - NANOTECHNOLOGY
PHYSICS PROJECT BY MSC  - NANOTECHNOLOGYPHYSICS PROJECT BY MSC  - NANOTECHNOLOGY
PHYSICS PROJECT BY MSC - NANOTECHNOLOGY
 

Symfony bundle fo asynchronous job processing

  • 2. Wojciech Ciołko About me • Software Engineer (PayPal, Rocket Internet, AxelSpringer, PostCon, AboutCoders, OSEC) • Agile oriented architect and project leader focused on scalability, maintainability and performance • I always try to deliver the best quality combined with most relevant technologies
  • 3. Contact • Twitter @WCiolko • https://github.com/aboutcoders • https://aboutcoders.com/ • http://osec.pl/ www.aboutcoders.com
  • 4. The problem • Synchronous processing blocks the application • Processing takes time and resources • Job processing often needs scaling • Processing logic mixed with application code
  • 5. AbcJobBundle • A Symfony bundle to process jobs asynchronously by simply annotating a method and registering the class within the service container. • https://github.com/aboutcoders/job-bundle www.aboutcoders.com
  • 7. Features • Asynchronous execution of jobs • Status information about jobs • Functionality to cancel, update, restart a job • Repeated execution of jobs with schedules • cron based expressions • JSON REST-Api • Support for multiple message queue systems: • Doctrine, RabbitMQ, InMemory, Redis, Amazon SQS, Iron MQ, Pheanstalk
  • 8. How to use it • Install and configure following the docs https://github.com/aboutcoders/job-bundle • Create job class • Register job in container • Execute a job adding to job manager
  • 9. Create a job • Job is a regular PHP class use AbcBundleJobBundleAnnotationParamType;
 use AbcBundleJobBundleAnnotationReturnType;
 use PsrLogLoggerInterface;
 
 class DemoJob
 {
 /**
 * @ParamType("to", type="string")
 * @ParamType("logger", type="@abc.logger")
 * @ReturnType("string")
 */
 public function sayHello($to, LoggerInterface $logger)
 {
 $message = 'Hello ' . $to;
 
 $logger->info($message);
 
 return $message;
 }
 }
  • 10. Register job • Simple registration by Container tags demo_job:
 class: AppBundleJobDemoJob
 tags:
 - { name: "abc.job", type: "say_hello", method: "sayHello" }
  • 11. Execute job • To execute a job you need to add it to the job manager use AbcBundleJobBundleJobMailerMessage;
 use AbcBundleJobBundleJobManagerInterface;
 
 // retrieve job manager from the container
 /** @var ManagerInterface $manager */
 $manager = $container->get('abc.job.manager');
 
 // create a message
 $message = new Message();
 $message->setTo('mail@domain.tld');
 $message->setFrom('mail@domain.tld');
 $message->setSubject('Hello World');
 
 // add job to the queue
 $manager->addJob('abc_mailer', [$message]);
  • 12. Job status information • You can get current status of a job • You can get associated log messages // get log messages of a job
 $logs = $manager->getLogs($job->getTicket());
  • 13. Serialization of parameters • When a job is persisted to the database • REST-Api • The AbcJobBundle uses the JMS serializer by default for serialization • You can configure serialization options for the parameters and return value of a job /**
 * @ParamType("entity", type="MyBundleExampleBundleEntityMyEntity", options={"groups"={"primarykey"}, "version"="1"})
 * @ReturnType("MyBundleExampleBundleModelSomeObject", options={"groups"={"mygroup"}, "version"="2")
 */
 public function doSomething($entity){ … }
  • 14. Scheduled jobs • You can configure one or more schedules for a job in order to configure repeated execution of a job. • The bundle relies on the AbcSchedulerBundle to provide this functionality. //use builder
 $job = JobBuilder::create('my_job')
 ->addSchedule('cron', '1 * * * *')
 ->addSchedule('cron', '30 * * * *')
 ->build();
 
 //create schedule
 $schedule = ScheduleBuilder::create('cron', '1 * * * *');
 
 //remove schedule
 $job->removeSchedule($schedule);
  • 15. Consume messages • Symfony command • From your code php bin/console abc:job:consume default // retrieve job manager from the container
 $consumer = $container->get('abc.job.consumer');
 
 $consumer->consume('default', [
 'max-iterations' => 250
 ]);
  • 16. REST-API The AbcJobBundle ships with a JSON REST-API
  • 17. Clustered Environment • AbcJobBundle integrates concept of a resource lock. • This feature is disabled by default. In order to enable it you have to install the AbcResourceLockBundle
  • 19. Contact • Twitter @WCiolko • https://github.com/aboutcoders • https://aboutcoders.com/ • http://osec.pl/ www.aboutcoders.com Contact • Twitter @WCiolko • https://github.com/aboutcoders • https://aboutcoders.com/ • http://osec.pl/