friendsofhyperf / amqp-job
The amqp job for Hyperf.
Fund package maintenance!
huangdijia
hdj.me/sponsors
Requires
- friendsofhyperf/support: ~3.1.0
- hyperf/amqp: ~3.1.0
- hyperf/codec: ~3.1.0
- hyperf/conditionable: ~3.1.0
- hyperf/config: ~3.1.0
- hyperf/context: ~3.1.0
- hyperf/di: ~3.1.0
- hyperf/logger: ~3.1.0
- hyperf/redis: ~3.1.0
- hyperf/support: ~3.1.0
This package is auto-updated.
Last update: 2024-11-07 02:45:58 UTC
README
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 { // }