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

PDF
Intro to Rack
PDF
Introduction to AJAX In WordPress
PDF
CouchDB: A NoSQL database
PDF
Adventurous Merb
PDF
Put a Button on It: Removing Barriers to Going Fast
PPTX
Brief Introduction to Ember
PDF
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
PDF
Ruby on Rails - Introduction
Intro to Rack
Introduction to AJAX In WordPress
CouchDB: A NoSQL database
Adventurous Merb
Put a Button on It: Removing Barriers to Going Fast
Brief Introduction to Ember
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
Ruby on Rails - Introduction

What's hot (20)

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

Viewers also liked (8)

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

Similar to Symfony bundle fo asynchronous job processing (20)

PPT
Task Scheduling and Asynchronous Processing Evolved. Zend Server Job Queue
PPT
Job Queue - web is more than request and response
PDF
Queue your work
ODP
Deferred Processing in Ruby - Philly rb - August 2011
PDF
Working with Asynchronous Events
PDF
2015 ZendCon - Do you queue
PDF
Gearman jobqueue
ODP
Introduction to Python Celery
PDF
Introducing Symfony Messenger Monitoring
PDF
Job Queue Presentation - OSSCamp 2014
PDF
No Hugging, No Learning
PDF
Faster PHP apps using Queues and Workers
KEY
Cooking a rabbit pie
PDF
The Current State of Asynchronous Processing With Ruby
PPTX
Do you queue (updated)
ODP
Drupal course - batch API
PDF
BatchJobService
PPTX
Message Queues & Offline Processing with PHP
PPTX
Magento's Imagine eCommerce Conference: Do You Queue?
PPTX
Grokking TechTalk #24: Thiết kế hệ thống Background Job Queue bằng Ruby & Pos...
Task Scheduling and Asynchronous Processing Evolved. Zend Server Job Queue
Job Queue - web is more than request and response
Queue your work
Deferred Processing in Ruby - Philly rb - August 2011
Working with Asynchronous Events
2015 ZendCon - Do you queue
Gearman jobqueue
Introduction to Python Celery
Introducing Symfony Messenger Monitoring
Job Queue Presentation - OSSCamp 2014
No Hugging, No Learning
Faster PHP apps using Queues and Workers
Cooking a rabbit pie
The Current State of Asynchronous Processing With Ruby
Do you queue (updated)
Drupal course - batch API
BatchJobService
Message Queues & Offline Processing with PHP
Magento's Imagine eCommerce Conference: Do You Queue?
Grokking TechTalk #24: Thiết kế hệ thống Background Job Queue bằng Ruby & Pos...

Recently uploaded (20)

PPTX
fundraisepro pitch deck elegant and modern
PPTX
2025-08-10 Joseph 02 (shared slides).pptx
PPTX
BIOLOGY TISSUE PPT CLASS 9 PROJECT PUBLIC
PPTX
worship songs, in any order, compilation
PPTX
chapter8-180915055454bycuufucdghrwtrt.pptx
PDF
Presentation1 [Autosaved].pdf diagnosiss
PPTX
Project and change Managment: short video sequences for IBA
PDF
Instagram's Product Secrets Unveiled with this PPT
PPTX
The Effect of Human Resource Management Practice on Organizational Performanc...
PPTX
Hydrogel Based delivery Cancer Treatment
DOC
学位双硕士UTAS毕业证,墨尔本理工学院毕业证留学硕士毕业证
PPTX
Emphasizing It's Not The End 08 06 2025.pptx
PPTX
INTERNATIONAL LABOUR ORAGNISATION PPT ON SOCIAL SCIENCE
PPTX
Presentation for DGJV QMS (PQP)_12.03.2025.pptx
PPTX
nose tajweed for the arabic alphabets for the responsive
PDF
Tunisia's Founding Father(s) Pitch-Deck 2022.pdf
PDF
Nykaa-Strategy-Case-Fixing-Retention-UX-and-D2C-Engagement (1).pdf
DOCX
"Project Management: Ultimate Guide to Tools, Techniques, and Strategies (2025)"
PPTX
Introduction-to-Food-Packaging-and-packaging -materials.pptx
PPTX
Tablets And Capsule Preformulation Of Paracetamol
fundraisepro pitch deck elegant and modern
2025-08-10 Joseph 02 (shared slides).pptx
BIOLOGY TISSUE PPT CLASS 9 PROJECT PUBLIC
worship songs, in any order, compilation
chapter8-180915055454bycuufucdghrwtrt.pptx
Presentation1 [Autosaved].pdf diagnosiss
Project and change Managment: short video sequences for IBA
Instagram's Product Secrets Unveiled with this PPT
The Effect of Human Resource Management Practice on Organizational Performanc...
Hydrogel Based delivery Cancer Treatment
学位双硕士UTAS毕业证,墨尔本理工学院毕业证留学硕士毕业证
Emphasizing It's Not The End 08 06 2025.pptx
INTERNATIONAL LABOUR ORAGNISATION PPT ON SOCIAL SCIENCE
Presentation for DGJV QMS (PQP)_12.03.2025.pptx
nose tajweed for the arabic alphabets for the responsive
Tunisia's Founding Father(s) Pitch-Deck 2022.pdf
Nykaa-Strategy-Case-Fixing-Retention-UX-and-D2C-Engagement (1).pdf
"Project Management: Ultimate Guide to Tools, Techniques, and Strategies (2025)"
Introduction-to-Food-Packaging-and-packaging -materials.pptx
Tablets And Capsule Preformulation Of Paracetamol

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/