Class Processor
Constants
-
ACK ¶
'enqueue.ack'
Use this constant when the message is processed successfully and the message could be removed from the queue.
-
REJECT ¶
'enqueue.reject'
Use this constant when the message is not valid or could not be processed The message is removed from the queue.
-
REQUEUE ¶
'enqueue.requeue'
Use this constant when the message is not valid or could not be processed right now but we can try again later The original message is removed from the queue but a copy is published to the queue again.
Property Summary
-
$_eventClass protected
string
Default class name for new event objects.
-
$_eventManager protected
Cake\Event\EventManagerInterface|null
Instance of the Cake\Event\EventManager this object is using to dispatch inner events.
-
$container protected
Cake\Core\ContainerInterface|null
-
$logger protected
Psr\Log\LoggerInterface
Method Summary
-
__construct() public
Processor constructor
-
dispatchEvent() public
Wrapper for creating and dispatching events.
-
getEventManager() public
Returns the Cake\Event\EventManager manager instance for this object.
-
process() public
The method processes messages
-
processMessage() public
-
setEventManager() public
Returns the Cake\Event\EventManagerInterface instance for this object.
Method Detail
__construct() ¶ public
__construct(Psr\Log\LoggerInterface|null $logger = null, Cake\Core\ContainerInterface|null $container = null)
Processor constructor
Parameters
-
Psr\Log\LoggerInterface|null
$logger optional Logger instance.
-
Cake\Core\ContainerInterface|null
$container optional DI container instance
dispatchEvent() ¶ public
dispatchEvent(string $name, array $data = [], TSubject|null $subject = null): Cake\Event\EventInterface<TSubject>
Wrapper for creating and dispatching events.
Returns a dispatched event.
Parameters
-
string
$name Name of the event.
-
array
$data optional Any value you wish to be transported with this event to it can be read by listeners.
-
TSubject|null
$subject optional The object that this event applies to ($this by default).
Returns
Cake\Event\EventInterface<TSubject>
getEventManager() ¶ public
getEventManager(): Cake\Event\EventManagerInterface
Returns the Cake\Event\EventManager manager instance for this object.
You can use this instance to register any new listeners or callbacks to the object events, or create your own events and trigger them at will.
Returns
Cake\Event\EventManagerInterface
process() ¶ public
process(Interop\Queue\Message $message, Context $context): object|string
The method processes messages
The method also can return an object. It must implement __toString method and the method must return one of the constants from above.
Parameters
-
Interop\Queue\Message
$message Message.
-
Context
$context Context.
Returns
object|string
processMessage() ¶ public
processMessage(Cake\Queue\Job\Message $message): object|string
Parameters
-
Cake\Queue\Job\Message
$message Message.
Returns
object|string
setEventManager() ¶ public
setEventManager(Cake\Event\EventManagerInterface $eventManager): $this
Returns the Cake\Event\EventManagerInterface instance for this object.
You can use this instance to register any new listeners or callbacks to the object events, or create your own events and trigger them at will.
Parameters
-
Cake\Event\EventManagerInterface
$eventManager the eventManager to set
Returns
$this
Property Detail
$_eventManager ¶ protected
Instance of the Cake\Event\EventManager this object is using to dispatch inner events.
Type
Cake\Event\EventManagerInterface|null