SlideShare a Scribd company logo
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 fun
Tai An Su
 
AngularJS for Java Developers
AngularJS for Java DevelopersAngularJS for Java Developers
AngularJS for Java Developers
Loc Nguyen
 
Rethinking Best Practices
Rethinking Best PracticesRethinking Best Practices
Rethinking Best Practices
floydophone
 
1時間で作るマッシュアップサービス(関西版)
1時間で作るマッシュアップサービス(関西版)1時間で作るマッシュアップサービス(関西版)
1時間で作るマッシュアップサービス(関西版)
Yuichiro MASUI
 
Reacting to the Isomorphic Buzz
Reacting to the Isomorphic BuzzReacting to the Isomorphic Buzz
Reacting to the Isomorphic Buzz
Bruce Coddington
 
Catalyst MVC
Catalyst MVCCatalyst MVC
Catalyst MVC
Sheeju Alex
 
Python for AngularJS
Python for AngularJSPython for AngularJS
Python for AngularJS
Jeff Schenck
 
Laravel Beginners Tutorial 2
Laravel Beginners Tutorial 2Laravel Beginners Tutorial 2
Laravel Beginners Tutorial 2
Vikas 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 Application
Ben Limmer
 
Great Developers Steal
Great Developers StealGreat Developers Steal
Great Developers Steal
Ben 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 Castles
Ben Scofield
 
Building Cloud Castles - LRUG
Building Cloud Castles - LRUGBuilding Cloud Castles - LRUG
Building Cloud Castles - LRUG
Ben 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 Debugging
Rami 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 websocketw
Luke Adamczewski
 
Przetwarzanie asynchroniczne w zastosowaniach webowych
Przetwarzanie asynchroniczne w zastosowaniach webowychPrzetwarzanie asynchroniczne w zastosowaniach webowych
Przetwarzanie asynchroniczne w zastosowaniach webowych
leafnode
 
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
Kirill Chebunin
 
30 Symfony Best Practices
30 Symfony Best Practices30 Symfony Best Practices
30 Symfony Best Practices
Nicolas Perriault
 
Golang for OO Programmers
Golang for OO ProgrammersGolang for OO Programmers
Golang for OO Programmers
khalid Nowaf Almutiri
 
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 golang
Bo-Yi Wu
 
Symfony tips and tricks
Symfony tips and tricksSymfony tips and tricks
Symfony tips and tricks
Javier 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

CakePHP
CakePHPCakePHP
CakePHP
Walther Lalk
 
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
bobmcwhirter
 
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
MongoDB
 
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
Jason Davies
 
Celery with python
Celery with pythonCelery with python
Celery with python
Alexandre González Rodríguez
 
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 Developers
cacois
 
Web Worker, Service Worker and Worklets
Web Worker, Service Worker and WorkletsWeb Worker, Service Worker and Worklets
Web Worker, Service Worker and Worklets
Keshav Gupta
 
Refactoring @ Mindvalley: Smells, Techniques and Patterns
Refactoring @ Mindvalley: Smells, Techniques and PatternsRefactoring @ Mindvalley: Smells, Techniques and Patterns
Refactoring @ Mindvalley: Smells, Techniques and Patterns
Tristan Gomez
 
COScheduler
COSchedulerCOScheduler
COScheduler
WO Community
 
Node.js
Node.jsNode.js
Node.js
Ian Oxley
 
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
Pavel Chunyayev
 
Rails 3 (beta) Roundup
Rails 3 (beta) RoundupRails 3 (beta) Roundup
Rails 3 (beta) Roundup
Wayne Carter
 
DjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling DisqusDjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling Disqus
zeeg
 
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
Yves Goeleven
 
Introduction to Apache Ant
Introduction to Apache AntIntroduction to Apache Ant
Introduction to Apache Ant
Shih-Hsiang Lin
 
Synchronize applications with akeneo/batch
Synchronize applications with akeneo/batchSynchronize applications with akeneo/batch
Synchronize applications with akeneo/batch
gplanchat
 
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

Eureka, I found it! - Special Libraries Association 2021 Presentation
Eureka, I found it! - Special Libraries Association 2021 PresentationEureka, I found it! - Special Libraries Association 2021 Presentation
Eureka, I found it! - Special Libraries Association 2021 Presentation
Access Innovations, Inc.
 
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdfBonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
khadija278284
 
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
OECD Directorate for Financial and Enterprise Affairs
 
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Sebastiano Panichella
 
Obesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditionsObesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditions
Faculty of Medicine And Health Sciences
 
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Sebastiano Panichella
 
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptxsomanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
Howard Spence
 
International Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software TestingInternational Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software Testing
Sebastiano Panichella
 
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
0x01 - Newton's Third Law:  Static vs. Dynamic Abusers0x01 - Newton's Third Law:  Static vs. Dynamic Abusers
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
OWASP Beja
 
Getting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control TowerGetting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control Tower
Vladimir Samoylov
 
Acorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutesAcorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutes
IP ServerOne
 
Bitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXOBitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXO
Matjaž Lipuš
 
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Orkestra
 

Recently uploaded (13)

Eureka, I found it! - Special Libraries Association 2021 Presentation
Eureka, I found it! - Special Libraries Association 2021 PresentationEureka, I found it! - Special Libraries Association 2021 Presentation
Eureka, I found it! - Special Libraries Association 2021 Presentation
 
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdfBonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
 
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
 
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
 
Obesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditionsObesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditions
 
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...
 
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptxsomanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
 
International Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software TestingInternational Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software Testing
 
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
0x01 - Newton's Third Law:  Static vs. Dynamic Abusers0x01 - Newton's Third Law:  Static vs. Dynamic Abusers
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
 
Getting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control TowerGetting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control Tower
 
Acorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutesAcorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutes
 
Bitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXOBitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXO
 
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
 

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/