# Job Pipeline

Job Pipeline

The `JobPipeline` is a simple, yet **extremely powerful** class that lets you **convert any (series of) jobs into event listeners.** You may use a job pipeline like any other listener, so you can register it in the `EventServiceProvider` using the `$listen` array, or in any other place using `Event::listen()` — up to you. ## Creating job pipelines > These code snippets will use examples from [my multi-tenancy package](https://github.com/stancl/tenancy). To create a job pipeline, start by specifying the jobs you want to use: ```php send(function (TenantCreated $event) { return $event->tenant; }) ``` Next, decide if you want to queue the pipeline. By default, pipelines are synchronous (= not queued) by default. > 🔥 If you **do** want pipelines to be queued by default, you can do that by setting a static property: `\Stancl\JobPipeline\JobPipeline::$shouldBeQueuedByDefault = true;` ```php send(function (TenantCreated $event) { return $event->tenant; })->shouldBeQueued(true) ``` Finally, convert the pipeline to a listener and bind it to an event: ```php send(function (TenantCreated $event) { return $event->tenant; })->shouldBeQueued(true)->toListener()); ``` Note that you can use job pipelines even for converting single jobs to event listeners. That's useful if you have some logic in job classes and don't want to create listener classes just to be able to run these jobs as a result of an event being fired.