@@ -31,6 +31,27 @@ The `createJob()` function takes three arguments.
3131
3232> ` priority ` is sorted ascending, therefore a task with priority 1 will be executed before a task with priority 5
3333
34+ You can use the ` Priority ` enum for better readability:
35+ ``` php
36+ use Queue\Model\Enum\Priority;
37+
38+ $queuedJobsTable->createJob('MyTask', $data, ['priority' => Priority::High]);
39+ // or using JobConfig
40+ $config = $queuedJobsTable->newConfig()->setPriority(Priority::High);
41+ ```
42+
43+ Available priority levels (1 = highest, 10 = lowest):
44+ - ` Priority::Critical ` (1)
45+ - ` Priority::Urgent ` (2)
46+ - ` Priority::High ` (3)
47+ - ` Priority::MediumHigh ` (4)
48+ - ` Priority::Medium ` (5) - default
49+ - ` Priority::MediumLow ` (6)
50+ - ` Priority::Low ` (7)
51+ - ` Priority::VeryLow ` (8)
52+ - ` Priority::Deferred ` (9)
53+ - ` Priority::Idle ` (10)
54+
3455For sending emails, for example:
3556
3657``` php
@@ -96,13 +117,15 @@ This can be useful when more dynamically adding certain jobs of different types.
96117
97118It allows a more speaking API, which already has maximum IDE and Stan support:
98119``` php
120+ use Queue\Model\Enum\Priority;
121+
99122$dataDto = OrderUpdateNotificationQueueDataDto::createFromArray([
100123 OrderUpdateNotificationQueueDataDto::FIELD_ORDER_ID => $order->id,
101124 OrderUpdateNotificationQueueDataDto::FIELD_MAILER => 'CustomerRequest',
102125 OrderUpdateNotificationQueueDataDto::FIELD_TYPE => 'request',
103126]);
104127$config = $queuedJobsTable->newConfig()
105- ->setPriority(2 )
128+ ->setPriority(Priority::Urgent )
106129 ->setReference('foo')
107130 ->setNotBefore('+1 hour');
108131$queuedJobsTable->createJob('OrderUpdateNotification', $dataDto, $config);
0 commit comments