0
7
Login
Code
Issues
Pull requests
Events
Packages
1fc75ca3c7d73e80873785a0fa72acb8526c5706
1fc75ca3c7d73e80873785a0fa72acb8526c5706

Amqp Job

Latest Stable Version Total Downloads License

The amqp job component for Hyperf.

Installation

composer require friendsofhyperf/amqp-job

Usage

Dispatch

use FriendsOfHyperf\AmqpJob\Job;
use FriendsOfHyperf\AmqpJob\Annotations\AmqpJob;

use function FriendsOfHyperf\AmqpJob\dispatch;

#[AmqpJob(
    exchange: 'hyperf.exchange',
    routingKey: 'hyperf.routing.key',
    pool: 'default',
    queue: 'hyperf.queue',
)]
class FooJob extends Job
{
    public function handle()
    {
        var_dump('foo');
    }
}

dispatch(new FooJob());

Register Consumer[Optional]


namespace App\Amqp\Consumer;

use FriendsOfHyperf\AmqpJob\JobConsumer;
use Hyperf\Amqp\Annotation\Consumer;

#[Consumer(
    exchange: 'hyperf.exchange',
    routingKey: 'hyperf.routing.key',
    queue: 'hyperf.queue',
    name: 'MyConsumer',
    nums: 4

)]
class MyConsumer extends \FriendsOfHyperf\AmqpJob\JobConsumer
{
    //
}

Contact

License

MIT