Queue\AdapterFactory
ClassSource on GitHubMaps an adapter name to its ConnectionFactory. Mirrors Phalcon\Storage\AdapterFactory.
Phalcon\Factory\AbstractConfigFactoryPhalcon\Factory\AbstractFactoryPhalcon\Queue\AdapterFactory
Uses Phalcon\Contracts\Queue\ConnectionFactory · Phalcon\Factory\AbstractFactory
Method Summary
public__construct( array$services = [] )AdapterFactory constructor.publicConnectionFactoryInterfacenewInstance(string$name,array$options = [])Creates a new ConnectionFactory for the named adapter.protectedstringgetExceptionClass()protectedarraygetServices()Returns the available adapters.Methods
__construct()
public function __construct( array $services = [] );AdapterFactory constructor.
newInstance()
public function newInstance(
string $name,
array $options = []
): ConnectionFactoryInterface;Creates a new ConnectionFactory for the named adapter.
getExceptionClass()
protected function getExceptionClass(): string;getServices()
protected function getServices(): array;Returns the available adapters.
Queue\Adapter\AbstractConsumer
AbstractSource on GitHubShared consumer base. Implements the blocking receive() as a polling loop
on top of the abstract receiveNoWait(); concrete consumers provide the
transport-specific receiveNoWait, acknowledge and reject.
Transports with a native blocking receive (Redis BRPOP, Beanstalk reserve)
override receive() instead of polling.
Phalcon\Queue\Adapter\AbstractConsumer- implementsPhalcon\Contracts\Queue\Consumer
Uses Phalcon\Contracts\Queue\Consumer · Phalcon\Contracts\Queue\Message · Phalcon\Contracts\Queue\Queue
Method Summary
publicvoidacknowledge( MessageInterface$message )Acknowledges the message; the transport may then discard it.publicQueueInterfacegetQueue()Returns the queue this consumer reads from.publicMessageInterface|nullreceive( int$timeout = 0 )Receives a message, blocking up to timeout milliseconds (0 = blockpublicMessageInterface|nullreceiveNoWait()Receives a message without blocking, or null when none is ready.publicvoidreject(MessageInterface$message,bool$requeue = false)Rejects the message. When requeue is true the transport redelivers it.publicvoidsetPollInterval( int$pollInterval )Sets the poll interval (in milliseconds) used by receive().Properties
protectedint$pollInterval = 200Milliseconds slept between poll attempts.protectedQueueInterface$queueThe queue this consumer reads from.Methods
acknowledge()
abstract public function acknowledge( MessageInterface $message ): void;Acknowledges the message; the transport may then discard it.
getQueue()
public function getQueue(): QueueInterface;Returns the queue this consumer reads from.
receive()
public function receive( int $timeout = 0 ): MessageInterface|null;Receives a message, blocking up to timeout milliseconds (0 = block
until one is available), by polling receiveNoWait() every
pollInterval milliseconds. Returns null when none arrives in time.
receiveNoWait()
abstract public function receiveNoWait(): MessageInterface|null;Receives a message without blocking, or null when none is ready.
reject()
abstract public function reject(
MessageInterface $message,
bool $requeue = false
): void;Rejects the message. When requeue is true the transport redelivers it.
setPollInterval()
public function setPollInterval( int $pollInterval ): void;Sets the poll interval (in milliseconds) used by receive().
Queue\Adapter\AbstractContext
AbstractSource on GitHubShared transport-session base. Every transport builds the same destination value objects (GenericQueue / GenericTopic) and the same uniquely named temporary queue, so those factories live here once. Concrete contexts implement the transport-specific factories (consumer, producer, message, subscription consumer) and the storage operations.
Phalcon\Queue\Adapter\AbstractContext- implementsPhalcon\Contracts\Queue\Context
Uses Phalcon\Contracts\Queue\Context · Phalcon\Contracts\Queue\Queue · Phalcon\Contracts\Queue\Topic
Method Summary
publicQueueInterfacecreateQueue( string$queueName )Creates a queue destination by name.publicQueueInterfacecreateTemporaryQueue()Creates a uniquely named temporary queue.publicTopicInterfacecreateTopic( string$topicName )Creates a topic destination by name.Methods
createQueue()
public function createQueue( string $queueName ): QueueInterface;Creates a queue destination by name.
createTemporaryQueue()
public function createTemporaryQueue(): QueueInterface;Creates a uniquely named temporary queue.
createTopic()
public function createTopic( string $topicName ): TopicInterface;Creates a topic destination by name.
Queue\Adapter\AbstractMessage
AbstractSource on GitHubShared base for the concrete adapter messages.
@todo Remove in v7. Kept only for backwards compatibility; compose Phalcon\Queue\Adapter\Traits\MessageTrait directly instead of extending this.
Phalcon\Queue\Adapter\AbstractMessage- implementsPhalcon\Contracts\Queue\Message
Uses Phalcon\Contracts\Queue\Message · Phalcon\Queue\Adapter\Traits\MessageTrait
Queue\Adapter\AbstractProducer
AbstractSource on GitHubShared producer base. Defaults every optional capability (delivery delay,
priority, time to live) to “unsupported”: the getter returns null and the
setter throws the matching exception for any non-null value. A concrete
producer overrides only the capabilities its transport actually supports,
and implements send().
Phalcon\Queue\Adapter\AbstractProducer- implementsPhalcon\Contracts\Queue\Producer
Uses Phalcon\Contracts\Queue\Destination · Phalcon\Contracts\Queue\Message · Phalcon\Contracts\Queue\Producer · Phalcon\Queue\Exceptions\DeliveryDelayNotSupportedException · Phalcon\Queue\Exceptions\PriorityNotSupportedException · Phalcon\Queue\Exceptions\TimeToLiveNotSupportedException
Method Summary
publicint|nullgetDeliveryDelay()publicint|nullgetPriority()publicint|nullgetTimeToLive()publicvoidsend(DestinationInterface$destination,MessageInterface$message)publicProducerInterfacesetDeliveryDelay( mixed$deliveryDelay = null )publicProducerInterfacesetPriority( mixed$priority = null )publicProducerInterfacesetTimeToLive( mixed$timeToLive = null )Methods
getDeliveryDelay()
public function getDeliveryDelay(): int|null;getPriority()
public function getPriority(): int|null;getTimeToLive()
public function getTimeToLive(): int|null;send()
abstract public function send(
DestinationInterface $destination,
MessageInterface $message
): void;setDeliveryDelay()
public function setDeliveryDelay( mixed $deliveryDelay = null ): ProducerInterface;setPriority()
public function setPriority( mixed $priority = null ): ProducerInterface;setTimeToLive()
public function setTimeToLive( mixed $timeToLive = null ): ProducerInterface;Queue\Adapter\AbstractSubscriptionConsumer
AbstractSource on GitHubShared subscription-consumer base.
@todo Remove in v7. Kept only for backwards compatibility; compose Phalcon\Queue\Adapter\Traits\SubscriptionConsumerTrait directly instead of extending this.
Phalcon\Queue\Adapter\AbstractSubscriptionConsumer- implementsPhalcon\Contracts\Queue\SubscriptionConsumer
Uses Phalcon\Contracts\Queue\SubscriptionConsumer · Phalcon\Queue\Adapter\Traits\SubscriptionConsumerTrait
Queue\Adapter\Beanstalk\BeanstalkConnection
ClassSource on GitHubDependency-free socket client for the Beanstalkd work queue, implementing the subset of the 1.2 protocol the adapter needs (use/watch/ignore, put, reserve-with-timeout, delete/release/bury/touch). Recovered and trimmed from the original Phalcon\Queue\Beanstalk transport.
Phalcon\Queue\Adapter\Beanstalk\BeanstalkConnection
Uses Phalcon\Queue\Exceptions\Exception · Phalcon\Traits\Php\FileTrait
Method Summary
public__construct(string$host = "127.0.0.1",int$port = 11300,bool$persistent = false)publicboolburyJob(string$id,int$priority)Puts a reserved job into the "buried" state.publicresourceconnect()Opens the socket connection to the Beanstalkd server.publicbooldeleteJob( string$id )Removes a job from the server entirely.publicbooldisconnect()Closes the connection to the server.publicboolignoreTube( string$tube )Removes the named tube from the watch list for the connection.publicint|boolput(string$data,int$priority,int$delay,int$ttr)Puts a job on the queue using the currently used tube. Returns the newpublicbool|stringread( int$length = 0 )Reads a packet from the socket. Verifies the connection is availablepublicarrayreadStatus()Reads the latest status line and splits it into tokens.publicboolreleaseJob(string$id,int$priority,int$delay)Puts a reserved job back into the ready queue.publicarray|nullreserve( mixed$timeout = null )Reserves a ready job from a watched tube. A null timeout blocks until apublicarray|boolstatsTube( string$tube )Returns the Beanstalkd statistics for a tube as an associative array, orpublicbooltouchJob( string$id )Extends the time-to-run of a reserved job.publicbooluseTube( string$tube )Changes the tube new jobs are put on. By default this is "default".publicboolwatchTube( string$tube )Adds the named tube to the watch list for the connection.publicbool|intwrite( string$data )Writes data to the socket, connecting first when needed.Properties
protectedresource$connectionConnection resource.protectedstring$host = "127.0.0.1"protectedbool$persistent = falseprotectedint$port = 11300protectedstring$usedTube = "default"Tube currently selected with use. A fresh connection uses "default".protectedarray$watchedTubes = []Tubes currently on the watch list, keyed by tube name. A fresh connection watches "default".Methods
__construct()
public function __construct(
string $host = "127.0.0.1",
int $port = 11300,
bool $persistent = false
);buryJob()
public function buryJob(
string $id,
int $priority
): bool;Puts a reserved job into the “buried” state.
connect()
public function connect(): resource;Opens the socket connection to the Beanstalkd server.
deleteJob()
public function deleteJob( string $id ): bool;Removes a job from the server entirely.
disconnect()
public function disconnect(): bool;Closes the connection to the server.
ignoreTube()
public function ignoreTube( string $tube ): bool;Removes the named tube from the watch list for the connection.
put()
public function put(
string $data,
int $priority,
int $delay,
int $ttr
): int|bool;Puts a job on the queue using the currently used tube. Returns the new job id, or false when the server did not accept it.
read()
public function read( int $length = 0 ): bool|string;Reads a packet from the socket. Verifies the connection is available first.
readStatus()
public function readStatus(): array;Reads the latest status line and splits it into tokens.
releaseJob()
public function releaseJob(
string $id,
int $priority,
int $delay
): bool;Puts a reserved job back into the ready queue.
reserve()
public function reserve( mixed $timeout = null ): array|null;Reserves a ready job from a watched tube. A null timeout blocks until a job is available; otherwise it blocks up to timeout seconds. Returns [id, body] or null when none is reserved.
statsTube()
public function statsTube( string $tube ): array|bool;Returns the Beanstalkd statistics for a tube as an associative array, or false when the tube does not exist.
touchJob()
public function touchJob( string $id ): bool;Extends the time-to-run of a reserved job.
useTube()
public function useTube( string $tube ): bool;Changes the tube new jobs are put on. By default this is “default”.
watchTube()
public function watchTube( string $tube ): bool;Adds the named tube to the watch list for the connection.
write()
public function write( string $data ): bool|int;Writes data to the socket, connecting first when needed.
Queue\Adapter\Beanstalk\BeanstalkConnectionFactory
ClassSource on GitHubBuilds a BeanstalkContext.
Options:
- host: server host (default 127.0.0.1).
- port: server port (default 11300).
- persistent: use a persistent socket (default false).
- ttr: default time-to-run in seconds for every job (default 86400).
- pollInterval: milliseconds between subscription poll passes (default 200).
Phalcon\Queue\Adapter\Beanstalk\BeanstalkConnectionFactory- implementsPhalcon\Contracts\Queue\ConnectionFactory
Uses Phalcon\Contracts\Queue\ConnectionFactory · Phalcon\Contracts\Queue\Context
Method Summary
Properties
protectedarray$options = []Methods
__construct()
public function __construct( array $options = [] );createContext()
public function createContext(): ContextInterface;Queue\Adapter\Beanstalk\BeanstalkConsumer
ClassSource on GitHubReceives messages from a single Beanstalkd tube over its own connection.
receive() is overridden to use the native blocking reserve. Implements
VisibilityAware: a reserved job has a time-to-run window that touch()
extends; acknowledging deletes the job, rejecting releases it (requeue) or
buries it.
Phalcon\Queue\Adapter\AbstractConsumerPhalcon\Queue\Adapter\Beanstalk\BeanstalkConsumer- implementsPhalcon\Contracts\Queue\VisibilityAware
Uses Phalcon\Contracts\Queue\Message · Phalcon\Contracts\Queue\Queue · Phalcon\Contracts\Queue\VisibilityAware · Phalcon\Queue\Adapter\AbstractConsumer · Phalcon\Queue\Adapter\MessageEnvelope
Method Summary
public__construct(BeanstalkConnection$connection,QueueInterface$queue)publicvoidacknowledge( MessageInterface$message )publicMessageInterface|nullreceive( int$timeout = 0 )publicMessageInterface|nullreceiveNoWait()publicvoidreject(MessageInterface$message,bool$requeue = false)publicbooltouch( MessageInterface$message )Extends the time-to-run window of a reserved job (VisibilityAware).Constants
intDEFAULT_PRIORITY = 100Default Beanstalkd priority used when releasing or burying.Properties
protectedBeanstalkConnection$connectionMethods
__construct()
public function __construct(
BeanstalkConnection $connection,
QueueInterface $queue
);acknowledge()
public function acknowledge( MessageInterface $message ): void;receive()
public function receive( int $timeout = 0 ): MessageInterface|null;receiveNoWait()
public function receiveNoWait(): MessageInterface|null;reject()
public function reject(
MessageInterface $message,
bool $requeue = false
): void;touch()
public function touch( MessageInterface $message ): bool;Extends the time-to-run window of a reserved job (VisibilityAware).
Queue\Adapter\Beanstalk\BeanstalkContext
ClassSource on GitHubBeanstalkd transport session. A queue maps to a Beanstalkd tube. Producers
share the context connection (use + put); each consumer owns its own
connection, because Beanstalkd only lets the reserving connection delete,
release, bury or touch a job. The destination factories come from
AbstractContext.
Phalcon\Queue\Adapter\AbstractContextPhalcon\Queue\Adapter\Beanstalk\BeanstalkContext- implementsPhalcon\Contracts\Queue\Inspectable
Uses Phalcon\Contracts\Queue\Consumer · Phalcon\Contracts\Queue\Destination · Phalcon\Contracts\Queue\Inspectable · Phalcon\Contracts\Queue\Message · Phalcon\Contracts\Queue\Producer · Phalcon\Contracts\Queue\Queue · Phalcon\Contracts\Queue\SubscriptionConsumer · Phalcon\Queue\Adapter\AbstractContext · Phalcon\Queue\Adapter\QueueDestinationGuard
Method Summary
public__construct(string$host,int$port,bool$persistent = false,int$ttr = 86400,int$pollInterval = 200)publicvoidclose()publicConsumerInterfacecreateConsumer( DestinationInterface$destination )publicMessageInterfacecreateMessage(string$body = "",array$properties = [],array$headers = [])publicProducerInterfacecreateProducer()publicSubscriptionConsumerInterfacecreateSubscriptionConsumer()publicarraygetStats( QueueInterface$queue )Returns the Beanstalkd stats-tube fields for the queue's tube as anpublicintgetTtr()Default time-to-run (seconds) for new jobs. Used by BeanstalkProducer.publicvoidpurgeQueue( QueueInterface$queue )publicvoidputMessage(string$tube,string$payload,int$priority,int$delay,int$ttr)Puts a serialized payload on a tube via the shared connection.Properties
protectedBeanstalkConnection | null$connection = nullShared connection used by producers and purges.protectedstring$host = "127.0.0.1"protectedbool$persistent = falseprotectedint$pollInterval = 200Milliseconds slept between poll passes by a subscription consumer.protectedint$port = 11300protectedint$ttr = 86400Default time-to-run (seconds) applied to every put.Methods
__construct()
public function __construct(
string $host,
int $port,
bool $persistent = false,
int $ttr = 86400,
int $pollInterval = 200
);close()
public function close(): void;createConsumer()
public function createConsumer( DestinationInterface $destination ): ConsumerInterface;createMessage()
public function createMessage(
string $body = "",
array $properties = [],
array $headers = []
): MessageInterface;createProducer()
public function createProducer(): ProducerInterface;createSubscriptionConsumer()
public function createSubscriptionConsumer(): SubscriptionConsumerInterface;getStats()
public function getStats( QueueInterface $queue ): array;Returns the Beanstalkd stats-tube fields for the queue’s tube as an
associative array, with numeric values cast to int (the name field is
kept as a string). When the tube exists the result is the full Beanstalkd
stats-tube field set (current-jobs-*, total-jobs, the cmd-* counters and
tube-configuration fields).
The current-jobs-* backlog keys are always present: an unknown tube
(no jobs, not used or watched) has zero backlog, so those keys are
returned at zero. This keeps the backlog shape independent of transient
watcher state. Runs on a fresh short-lived connection (like purgeQueue)
so the read never shares the producer’s socket.
getTtr()
public function getTtr(): int;Default time-to-run (seconds) for new jobs. Used by BeanstalkProducer.
purgeQueue()
public function purgeQueue( QueueInterface $queue ): void;putMessage()
public function putMessage(
string $tube,
string $payload,
int $priority,
int $delay,
int $ttr
): void;Puts a serialized payload on a tube via the shared connection. Internal transport API used by BeanstalkProducer.
Queue\Adapter\Beanstalk\BeanstalkMessage
ClassSource on GitHubBeanstalkd-backed message. Carries the reserved job id so the consumer can delete, release, bury or touch it; all other behavior comes from MessageTrait.
Phalcon\Queue\Adapter\AbstractMessagePhalcon\Queue\Adapter\Beanstalk\BeanstalkMessage
Uses Phalcon\Queue\Adapter\AbstractMessage
Method Summary
Properties
protectedstring | null$jobId = nullThe reserved Beanstalkd job id, or null before it is reserved.Methods
getJobId()
public function getJobId(): string|null;setJobId()
public function setJobId( string $jobId ): void;Queue\Adapter\Beanstalk\BeanstalkProducer
ClassSource on GitHubSends messages to a Beanstalkd tube. Delivery delay (rounded down to whole seconds) and message priority are supported natively; Beanstalkd has no message expiry, so time to live is not (the default from AbstractProducer rejects it).
Phalcon\Queue\Adapter\AbstractProducerPhalcon\Queue\Adapter\Beanstalk\BeanstalkProducer
Uses Phalcon\Contracts\Queue\Destination · Phalcon\Contracts\Queue\Message · Phalcon\Contracts\Queue\Producer · Phalcon\Queue\Adapter\AbstractProducer · Phalcon\Queue\Adapter\MessageEnvelope · Phalcon\Queue\Adapter\QueueDestinationGuard
Method Summary
public__construct( BeanstalkContext$context )publicint|nullgetDeliveryDelay()publicint|nullgetPriority()publicvoidsend(DestinationInterface$destination,MessageInterface$message)publicProducerInterfacesetDeliveryDelay( mixed$deliveryDelay = null )publicProducerInterfacesetPriority( mixed$priority = null )Constants
intDEFAULT_PRIORITY = 100Default Beanstalkd priority (0 = most urgent).Properties
protectedBeanstalkContext$contextprotectedint | null$deliveryDelay = nullDelivery delay in milliseconds, or null when not set.protectedint | null$priority = nullJob priority, or null when not set.Methods
__construct()
public function __construct( BeanstalkContext $context );getDeliveryDelay()
public function getDeliveryDelay(): int|null;getPriority()
public function getPriority(): int|null;send()
public function send(
DestinationInterface $destination,
MessageInterface $message
): void;setDeliveryDelay()
public function setDeliveryDelay( mixed $deliveryDelay = null ): ProducerInterface;setPriority()
public function setPriority( mixed $priority = null ): ProducerInterface;Queue\Adapter\Beanstalk\BeanstalkSubscriptionConsumer
ClassSource on GitHubConsumes from several Beanstalkd tubes at once. The round-robin poll loop lives in SubscriptionConsumerTrait.
Phalcon\Queue\Adapter\AbstractSubscriptionConsumerPhalcon\Queue\Adapter\Beanstalk\BeanstalkSubscriptionConsumer
Uses Phalcon\Queue\Adapter\AbstractSubscriptionConsumer
Method Summary
Properties
protectedBeanstalkContext$contextRetained for transports that may later need it for a native multi-queue receive; the shared poll loop does not use it.Methods
__construct()
public function __construct(
BeanstalkContext $context,
int $pollInterval = 200
);Queue\Adapter\GenericQueue
ClassSource on GitHubA named queue destination shared by every transport. A queue name is the only knowledge a destination carries, so the adapters need no transport specific subclass.
Phalcon\Queue\Adapter\GenericQueue- implementsPhalcon\Contracts\Queue\Queue
Uses Phalcon\Contracts\Queue\Queue
Method Summary
public__construct( string$queueName )GenericQueue constructor.publicstringgetQueueName()Returns the queue name.Properties
protectedstring$queueName = ""Methods
__construct()
public function __construct( string $queueName );GenericQueue constructor.
getQueueName()
public function getQueueName(): string;Returns the queue name.
Queue\Adapter\GenericTopic
ClassSource on GitHubA named topic destination shared by every transport. A topic name is the only knowledge a destination carries, so the adapters need no transport specific subclass.
Phalcon\Queue\Adapter\GenericTopic- implementsPhalcon\Contracts\Queue\Topic
Uses Phalcon\Contracts\Queue\Topic
Method Summary
public__construct( string$topicName )GenericTopic constructor.publicstringgetTopicName()Returns the topic name.Properties
protectedstring$topicName = ""Methods
__construct()
public function __construct( string $topicName );GenericTopic constructor.
getTopicName()
public function getTopicName(): string;Returns the topic name.
Queue\Adapter\Memory\MemoryConnectionFactory
ClassSource on GitHubBuilds a MemoryContext. The Memory transport takes no options.
Phalcon\Queue\Adapter\Memory\MemoryConnectionFactory- implementsPhalcon\Contracts\Queue\ConnectionFactory
Uses Phalcon\Contracts\Queue\ConnectionFactory · Phalcon\Contracts\Queue\Context
Method Summary
public__construct( array$options = [] )MemoryConnectionFactory constructor.publicContextInterfacecreateContext()Creates a new in-process context.Properties
protectedarray$options = []Methods
__construct()
public function __construct( array $options = [] );MemoryConnectionFactory constructor.
createContext()
public function createContext(): ContextInterface;Creates a new in-process context.
Queue\Adapter\Memory\MemoryConsumer
ClassSource on GitHubReceives messages from a single in-process queue. receive() is the
polling loop inherited from AbstractConsumer.
Phalcon\Queue\Adapter\AbstractConsumerPhalcon\Queue\Adapter\Memory\MemoryConsumer
Uses Phalcon\Contracts\Queue\Message · Phalcon\Contracts\Queue\Queue · Phalcon\Queue\Adapter\AbstractConsumer
Method Summary
public__construct(MemoryContext$context,QueueInterface$queue)MemoryConsumer constructor.publicvoidacknowledge( MessageInterface$message )No-op: a received message has already been removed from the queue.publicMessageInterface|nullreceiveNoWait()Removes and returns the next message, or null when the queue is empty.publicvoidreject(MessageInterface$message,bool$requeue = false)Rejects the message. When requeue is true it is put back on the queue.Properties
protectedMemoryContext$contextMethods
__construct()
public function __construct(
MemoryContext $context,
QueueInterface $queue
);MemoryConsumer constructor.
acknowledge()
public function acknowledge( MessageInterface $message ): void;No-op: a received message has already been removed from the queue.
receiveNoWait()
public function receiveNoWait(): MessageInterface|null;Removes and returns the next message, or null when the queue is empty.
reject()
public function reject(
MessageInterface $message,
bool $requeue = false
): void;Rejects the message. When requeue is true it is put back on the queue.
Queue\Adapter\Memory\MemoryContext
ClassSource on GitHubIn-process transport session. Owns the named FIFO queues that this context’s producers and consumers share. The destination factories (createQueue / createTopic / createTemporaryQueue) come from AbstractContext.
Phalcon\Queue\Adapter\AbstractContextPhalcon\Queue\Adapter\Memory\MemoryContext
Uses Phalcon\Contracts\Queue\Consumer · Phalcon\Contracts\Queue\Destination · Phalcon\Contracts\Queue\Message · Phalcon\Contracts\Queue\Producer · Phalcon\Contracts\Queue\Queue · Phalcon\Contracts\Queue\SubscriptionConsumer · Phalcon\Queue\Adapter\AbstractContext · Phalcon\Queue\Adapter\QueueDestinationGuard
Method Summary
publicvoidclose()Closes the context and drops every stored message.publicConsumerInterfacecreateConsumer( DestinationInterface$destination )Creates a consumer for the given queue destination.publicMessageInterfacecreateMessage(string$body = "",array$properties = [],array$headers = [])Creates a message.publicProducerInterfacecreateProducer()Creates a producer.publicSubscriptionConsumerInterfacecreateSubscriptionConsumer()Creates a subscription consumer.publicMessageInterface|nullpopMessage( string$queueName )Removes the front message from a queue, or null when it is empty.publicvoidpurgeQueue( QueueInterface$queue )Removes all messages from the given queue.publicvoidpushMessage(string$queueName,MessageInterface$message)Appends a message to the back of a queue.Properties
protectedarray$queues = []Named queues: queue name => list of messages (FIFO).Methods
close()
public function close(): void;Closes the context and drops every stored message.
createConsumer()
public function createConsumer( DestinationInterface $destination ): ConsumerInterface;Creates a consumer for the given queue destination.
createMessage()
public function createMessage(
string $body = "",
array $properties = [],
array $headers = []
): MessageInterface;Creates a message.
createProducer()
public function createProducer(): ProducerInterface;Creates a producer.
createSubscriptionConsumer()
public function createSubscriptionConsumer(): SubscriptionConsumerInterface;Creates a subscription consumer.
popMessage()
public function popMessage( string $queueName ): MessageInterface|null;Removes the front message from a queue, or null when it is empty. Internal transport API used by MemoryConsumer.
purgeQueue()
public function purgeQueue( QueueInterface $queue ): void;Removes all messages from the given queue.
pushMessage()
public function pushMessage(
string $queueName,
MessageInterface $message
): void;Appends a message to the back of a queue. Internal transport API used by MemoryProducer.
Queue\Adapter\Memory\MemoryMessage
ClassSource on GitHubIn-process message. All behavior comes from MessageTrait.
Phalcon\Queue\Adapter\AbstractMessagePhalcon\Queue\Adapter\Memory\MemoryMessage
Uses Phalcon\Queue\Adapter\AbstractMessage
Queue\Adapter\Memory\MemoryProducer
ClassSource on GitHubSends messages into an in-process queue. The Memory transport delivers immediately and in-process, so delivery delay, priority and time to live are not supported (the defaults from AbstractProducer reject them).
Phalcon\Queue\Adapter\AbstractProducerPhalcon\Queue\Adapter\Memory\MemoryProducer
Uses Phalcon\Contracts\Queue\Destination · Phalcon\Contracts\Queue\Message · Phalcon\Queue\Adapter\AbstractProducer · Phalcon\Queue\Adapter\QueueDestinationGuard
Method Summary
public__construct( MemoryContext$context )publicvoidsend(DestinationInterface$destination,MessageInterface$message)Properties
protectedMemoryContext$contextMethods
__construct()
public function __construct( MemoryContext $context );send()
public function send(
DestinationInterface $destination,
MessageInterface $message
): void;Queue\Adapter\Memory\MemorySubscriptionConsumer
ClassSource on GitHubConsumes from several in-process queues at once. The round-robin poll loop lives in SubscriptionConsumerTrait.
Phalcon\Queue\Adapter\AbstractSubscriptionConsumerPhalcon\Queue\Adapter\Memory\MemorySubscriptionConsumer
Uses Phalcon\Queue\Adapter\AbstractSubscriptionConsumer
Method Summary
Properties
protectedMemoryContext$contextRetained for transports that may later need it for a native multi-queue receive; the shared poll loop does not use it.Methods
__construct()
public function __construct( MemoryContext $context );Queue\Adapter\MessageEnvelope
ClassSource on GitHubEncodes and decodes the {body, properties, headers} envelope shared by every
transport that persists a message as a serialized string (Stream, Redis,
Beanstalk). Centralizes the wire shape, the object-injection-safe
allowed_classes => false guard, and the missing-key defaults, so each
adapter only supplies its own concrete message factory around decode().
Phalcon\Queue\Adapter\MessageEnvelope
Uses Phalcon\Contracts\Queue\Message
Method Summary
publicarray|nulldecode( string$payload )Decodes a serialized payload into a normalized {body, properties,publicstringencode( MessageInterface$message )Serializes a message into its wire envelope.Methods
decode()
public static function decode( string $payload ): array|null;Decodes a serialized payload into a normalized {body, properties, headers} array, or null when the payload is not a valid envelope.
encode()
public static function encode( MessageInterface $message ): string;Serializes a message into its wire envelope.
Queue\Adapter\QueueDestinationGuard
ClassSource on GitHubShared “destination must be a queue” guard. Producers (on send) and contexts
(on createConsumer) both reject any non-queue destination with the same typed
exception; this keeps that single rule in one place. The action verb
(“send to”, “consume from”) tailors the message to the caller.
Phalcon\Queue\Adapter\QueueDestinationGuard
Uses Phalcon\Contracts\Queue\Destination · Phalcon\Contracts\Queue\Queue · Phalcon\Queue\Exceptions\InvalidDestinationException
Method Summary
Methods
assertQueue()
public static function assertQueue(
DestinationInterface $destination,
string $action
): void;Throws InvalidDestinationException unless the destination is a queue.
Queue\Adapter\Redis\RedisConnectionFactory
ClassSource on GitHubConnects to a Redis server (ext-redis) and builds a RedisContext. The connection (connect/pconnect, auth, database select) is delegated to Phalcon\Storage\Adapter\Redis so the queue reuses the framework’s hardened connection handling instead of re-implementing it.
Options:
- host: server host (default 127.0.0.1).
- port: server port (default 6379).
- timeout: connection timeout in seconds (default 0).
- persistent: use a persistent connection (default false).
- persistentId: identifier for the persistent connection.
- auth: password, or [user, password] for ACL auth.
- index: database index to SELECT (default 0).
- prefix: key prefix for every queue (default “phalcon_queue:”).
- pollInterval: milliseconds between subscription poll passes (default 200).
Phalcon\Queue\Adapter\Redis\RedisConnectionFactory- implementsPhalcon\Contracts\Queue\ConnectionFactory
Uses Phalcon\Contracts\Queue\ConnectionFactory · Phalcon\Contracts\Queue\Context · Phalcon\Queue\Exceptions\Exception · Phalcon\Storage\Adapter\Redis · Phalcon\Storage\Exception · Phalcon\Storage\SerializerFactory
Method Summary
Properties
protectedarray$options = []Methods
__construct()
public function __construct( array $options = [] );createContext()
public function createContext(): ContextInterface;Queue\Adapter\Redis\RedisConsumer
ClassSource on GitHubReceives messages from a single Redis queue. receive() is overridden to
use the native blocking BRPOP (in one-second chunks, so due delayed
messages keep getting promoted) instead of the inherited polling loop.
Phalcon\Queue\Adapter\AbstractConsumerPhalcon\Queue\Adapter\Redis\RedisConsumer
Uses Phalcon\Contracts\Queue\Message · Phalcon\Contracts\Queue\Queue · Phalcon\Queue\Adapter\AbstractConsumer
Method Summary
public__construct(RedisContext$context,QueueInterface$queue)publicvoidacknowledge( MessageInterface$message )No-op: a received message has already been removed from the queue.publicMessageInterface|nullreceive( int$timeout = 0 )publicMessageInterface|nullreceiveNoWait()publicvoidreject(MessageInterface$message,bool$requeue = false)Properties
protectedRedisContext$contextMethods
__construct()
public function __construct(
RedisContext $context,
QueueInterface $queue
);acknowledge()
public function acknowledge( MessageInterface $message ): void;No-op: a received message has already been removed from the queue.
receive()
public function receive( int $timeout = 0 ): MessageInterface|null;receiveNoWait()
public function receiveNoWait(): MessageInterface|null;reject()
public function reject(
MessageInterface $message,
bool $requeue = false
): void;Queue\Adapter\Redis\RedisContext
ClassSource on GitHubRedis transport session (ext-redis). Each queue is a Redis list; messages
are LPUSHed on send and RPOP/BRPOPed on receive, giving FIFO delivery.
Delayed messages live in a companion sorted set (<key>:delayed) scored by
their due time in milliseconds, and are promoted into the list once due. The
destination factories come from AbstractContext.
Phalcon\Queue\Adapter\AbstractContextPhalcon\Queue\Adapter\Redis\RedisContext
Uses Phalcon\Contracts\Queue\Consumer · Phalcon\Contracts\Queue\Destination · Phalcon\Contracts\Queue\Message · Phalcon\Contracts\Queue\Producer · Phalcon\Contracts\Queue\Queue · Phalcon\Contracts\Queue\SubscriptionConsumer · Phalcon\Queue\Adapter\AbstractContext · Phalcon\Queue\Adapter\MessageEnvelope · Phalcon\Queue\Adapter\QueueDestinationGuard
Method Summary
public__construct(mixed$redis,string$prefix = "phalcon_queue:",int$pollInterval = 200)publicMessageInterface|nullblockingPop(string$queueName,int$timeout)Blocking pop from the back of a queue list. Promotes any due delayedpublicvoidclose()publicConsumerInterfacecreateConsumer( DestinationInterface$destination )publicMessageInterfacecreateMessage(string$body = "",array$properties = [],array$headers = [])publicProducerInterfacecreateProducer()publicSubscriptionConsumerInterfacecreateSubscriptionConsumer()publicMessageInterface|nullpopMessage( string$queueName )Non-blocking pop from the back of a queue list, or null when empty.publicvoidpurgeQueue( QueueInterface$queue )publicvoidpushMessage(string$queueName,MessageInterface$message,int$delay = 0)Sends a message to a queue. With a positive delay (milliseconds) theProperties
protectedint$pollInterval = 200Milliseconds slept between poll passes by a subscription consumer.protectedstring$prefix = "phalcon_queue:"Key prefix applied to every queue (and its delayed companion set).protected\Redis$redisThe connected ext-redis client.Methods
__construct()
public function __construct(
mixed $redis,
string $prefix = "phalcon_queue:",
int $pollInterval = 200
);blockingPop()
public function blockingPop(
string $queueName,
int $timeout
): MessageInterface|null;Blocking pop from the back of a queue list. Promotes any due delayed messages first, then blocks up to timeout seconds. Internal transport API used by RedisConsumer.
close()
public function close(): void;createConsumer()
public function createConsumer( DestinationInterface $destination ): ConsumerInterface;createMessage()
public function createMessage(
string $body = "",
array $properties = [],
array $headers = []
): MessageInterface;createProducer()
public function createProducer(): ProducerInterface;createSubscriptionConsumer()
public function createSubscriptionConsumer(): SubscriptionConsumerInterface;popMessage()
public function popMessage( string $queueName ): MessageInterface|null;Non-blocking pop from the back of a queue list, or null when empty. Promotes any due delayed messages first. Internal transport API used by RedisConsumer.
purgeQueue()
public function purgeQueue( QueueInterface $queue ): void;pushMessage()
public function pushMessage(
string $queueName,
MessageInterface $message,
int $delay = 0
): void;Sends a message to a queue. With a positive delay (milliseconds) the message is parked in the delayed set; otherwise it is pushed onto the front of the list. Internal transport API used by RedisProducer.
Queue\Adapter\Redis\RedisMessage
ClassSource on GitHubRedis-backed message. All behavior comes from MessageTrait.
Phalcon\Queue\Adapter\AbstractMessagePhalcon\Queue\Adapter\Redis\RedisMessage
Uses Phalcon\Queue\Adapter\AbstractMessage
Queue\Adapter\Redis\RedisProducer
ClassSource on GitHubSends messages to a Redis queue. Delivery delay is supported (via the delayed sorted set); priority and time to live are not (the defaults from AbstractProducer reject them).
Phalcon\Queue\Adapter\AbstractProducerPhalcon\Queue\Adapter\Redis\RedisProducer
Uses Phalcon\Contracts\Queue\Destination · Phalcon\Contracts\Queue\Message · Phalcon\Contracts\Queue\Producer · Phalcon\Queue\Adapter\AbstractProducer · Phalcon\Queue\Adapter\QueueDestinationGuard
Method Summary
public__construct( RedisContext$context )publicint|nullgetDeliveryDelay()publicvoidsend(DestinationInterface$destination,MessageInterface$message)publicProducerInterfacesetDeliveryDelay( mixed$deliveryDelay = null )Properties
protectedRedisContext$contextprotectedint | null$deliveryDelay = nullDelivery delay in milliseconds, or null when not set.Methods
__construct()
public function __construct( RedisContext $context );getDeliveryDelay()
public function getDeliveryDelay(): int|null;send()
public function send(
DestinationInterface $destination,
MessageInterface $message
): void;setDeliveryDelay()
public function setDeliveryDelay( mixed $deliveryDelay = null ): ProducerInterface;Queue\Adapter\Redis\RedisSubscriptionConsumer
ClassSource on GitHubConsumes from several Redis queues at once. The round-robin poll loop lives in SubscriptionConsumerTrait.
Phalcon\Queue\Adapter\AbstractSubscriptionConsumerPhalcon\Queue\Adapter\Redis\RedisSubscriptionConsumer
Uses Phalcon\Queue\Adapter\AbstractSubscriptionConsumer
Method Summary
Properties
protectedRedisContext$contextRetained for transports that may later need it for a native multi-queue receive; the shared poll loop does not use it.Methods
__construct()
public function __construct(
RedisContext $context,
int $pollInterval = 200
);Queue\Adapter\Stream\StreamConnectionFactory
ClassSource on GitHubBuilds a StreamContext.
Options:
- storageDir: directory holding the queue files (default: system temp).
- pollInterval: milliseconds between consumer poll attempts (default 200).
Phalcon\Queue\Adapter\Stream\StreamConnectionFactory- implementsPhalcon\Contracts\Queue\ConnectionFactory
Uses Phalcon\Contracts\Queue\ConnectionFactory · Phalcon\Contracts\Queue\Context
Method Summary
Properties
protectedarray$options = []Methods
__construct()
public function __construct( array $options = [] );createContext()
public function createContext(): ContextInterface;Queue\Adapter\Stream\StreamConsumer
ClassSource on GitHubReceives messages from a single filesystem queue. receive() is the
polling loop inherited from AbstractConsumer.
Phalcon\Queue\Adapter\AbstractConsumerPhalcon\Queue\Adapter\Stream\StreamConsumer
Uses Phalcon\Contracts\Queue\Message · Phalcon\Contracts\Queue\Queue · Phalcon\Queue\Adapter\AbstractConsumer
Method Summary
public__construct(StreamContext$context,QueueInterface$queue,int$pollInterval = 200)publicvoidacknowledge( MessageInterface$message )No-op: a received message has already been removed from the queue file.publicMessageInterface|nullreceiveNoWait()publicvoidreject(MessageInterface$message,bool$requeue = false)Properties
protectedStreamContext$contextMethods
__construct()
public function __construct(
StreamContext $context,
QueueInterface $queue,
int $pollInterval = 200
);acknowledge()
public function acknowledge( MessageInterface $message ): void;No-op: a received message has already been removed from the queue file.
receiveNoWait()
public function receiveNoWait(): MessageInterface|null;reject()
public function reject(
MessageInterface $message,
bool $requeue = false
): void;Queue\Adapter\Stream\StreamContext
ClassSource on GitHubFilesystem transport session. Each queue is one append-only file under the configured directory; cross-process safety comes from flock. One message per line, stored as base64(serialize([…])) so bodies with newlines are safe. The destination factories come from AbstractContext.
Phalcon\Queue\Adapter\AbstractContextPhalcon\Queue\Adapter\Stream\StreamContext
Uses Phalcon\Contracts\Queue\Consumer · Phalcon\Contracts\Queue\Destination · Phalcon\Contracts\Queue\Message · Phalcon\Contracts\Queue\Producer · Phalcon\Contracts\Queue\Queue · Phalcon\Contracts\Queue\SubscriptionConsumer · Phalcon\Queue\Adapter\AbstractContext · Phalcon\Queue\Adapter\MessageEnvelope · Phalcon\Queue\Adapter\QueueDestinationGuard · Phalcon\Traits\Php\FileTrait
Method Summary
public__construct(string$storageDir,int$pollInterval = 200)publicvoidclose()publicConsumerInterfacecreateConsumer( DestinationInterface$destination )publicMessageInterfacecreateMessage(string$body = "",array$properties = [],array$headers = [])publicProducerInterfacecreateProducer()publicSubscriptionConsumerInterfacecreateSubscriptionConsumer()publicMessageInterface|nullpopMessage( string$queueName )Removes the front message from a queue file, or null when it is empty.publicvoidpurgeQueue( QueueInterface$queue )publicvoidpushMessage(string$queueName,MessageInterface$message)Appends a message to the back of a queue file.Properties
protectedint$pollInterval = 200Milliseconds slept between poll attempts by consumers.protectedstring$storageDir = ""Directory (with trailing separator) that holds the queue files.Methods
__construct()
public function __construct(
string $storageDir,
int $pollInterval = 200
);close()
public function close(): void;createConsumer()
public function createConsumer( DestinationInterface $destination ): ConsumerInterface;createMessage()
public function createMessage(
string $body = "",
array $properties = [],
array $headers = []
): MessageInterface;createProducer()
public function createProducer(): ProducerInterface;createSubscriptionConsumer()
public function createSubscriptionConsumer(): SubscriptionConsumerInterface;popMessage()
public function popMessage( string $queueName ): MessageInterface|null;Removes the front message from a queue file, or null when it is empty. Internal transport API used by StreamConsumer.
purgeQueue()
public function purgeQueue( QueueInterface $queue ): void;pushMessage()
public function pushMessage(
string $queueName,
MessageInterface $message
): void;Appends a message to the back of a queue file. Internal transport API used by StreamProducer.
Queue\Adapter\Stream\StreamMessage
ClassSource on GitHubFilesystem-backed message. All behavior comes from MessageTrait.
Phalcon\Queue\Adapter\AbstractMessagePhalcon\Queue\Adapter\Stream\StreamMessage
Uses Phalcon\Queue\Adapter\AbstractMessage
Queue\Adapter\Stream\StreamProducer
ClassSource on GitHubAppends messages to a filesystem queue. The Stream transport delivers in insertion order with no scheduling, so delivery delay, priority and time to live are not supported (the defaults from AbstractProducer reject them).
Phalcon\Queue\Adapter\AbstractProducerPhalcon\Queue\Adapter\Stream\StreamProducer
Uses Phalcon\Contracts\Queue\Destination · Phalcon\Contracts\Queue\Message · Phalcon\Queue\Adapter\AbstractProducer · Phalcon\Queue\Adapter\QueueDestinationGuard
Method Summary
public__construct( StreamContext$context )publicvoidsend(DestinationInterface$destination,MessageInterface$message)Properties
protectedStreamContext$contextMethods
__construct()
public function __construct( StreamContext $context );send()
public function send(
DestinationInterface $destination,
MessageInterface $message
): void;Queue\Adapter\Stream\StreamSubscriptionConsumer
ClassSource on GitHubConsumes from several filesystem queues at once. The round-robin poll loop lives in SubscriptionConsumerTrait.
Phalcon\Queue\Adapter\AbstractSubscriptionConsumerPhalcon\Queue\Adapter\Stream\StreamSubscriptionConsumer
Uses Phalcon\Queue\Adapter\AbstractSubscriptionConsumer
Method Summary
Properties
protectedStreamContext$contextRetained for transports that may later need it for a native multi-queue receive; the shared poll loop does not use it.Methods
__construct()
public function __construct(
StreamContext $context,
int $pollInterval = 200
);Queue\Cli\ConsumerTask
ClassSource on GitHubOptional CLI runner for a queue worker - the only class coupled to
Phalcon\Cli. A thin adapter: it resolves the context from the queueFactory
service, binds one queue to one processor (both given as command arguments),
and runs a Worker whose lifetime bounds come from CLI options. Users not on
Phalcon\Cli use Worker directly.
Usage:
<task> <queueName> <processorServiceId>
[–max-messages=N] [–max-time=SECONDS]
[–max-memory=MB] [–jitter=SECONDS]
Register it in your own Phalcon\Cli\Console; it is not auto-wired into FactoryDefault.
stdClassPhalcon\Di\InjectablePhalcon\Cli\TaskPhalcon\Queue\Cli\ConsumerTask
Uses Phalcon\Cli\Task · Phalcon\Di\DiInterface · Phalcon\Queue\Consumer\QueueConsumer · Phalcon\Queue\Consumer\Worker · Phalcon\Queue\Consumer\WorkerOptions
Method Summary
Methods
mainAction()
public function mainAction(): int;Queue\Consumer\BoundProcessor
ClassSource on GitHubBinds a processor to a queue, together with the consumer that reads it.
Phalcon\Queue\Consumer\BoundProcessor
Uses Phalcon\Contracts\Queue\Consumer · Phalcon\Contracts\Queue\Processor · Phalcon\Contracts\Queue\Queue
Method Summary
public__construct(QueueInterface$queue,ProcessorInterface$processor,ConsumerInterface$consumer)publicConsumerInterfacegetConsumer()publicProcessorInterfacegetProcessor()publicQueueInterfacegetQueue()Properties
protectedConsumerInterface$consumerprotectedProcessorInterface$processorprotectedQueueInterface$queueMethods
__construct()
public function __construct(
QueueInterface $queue,
ProcessorInterface $processor,
ConsumerInterface $consumer
);getConsumer()
public function getConsumer(): ConsumerInterface;getProcessor()
public function getProcessor(): ProcessorInterface;getQueue()
public function getQueue(): QueueInterface;Queue\Consumer\Events
ClassSource on GitHubLifecycle event names fired by the queue consumer through Phalcon\Events\Manager. One public constant per event.
Phalcon\Queue\Consumer\Events
Constants
stringAFTER_END = "queue:afterEnd"stringAFTER_PROCESS = "queue:afterProcess"stringAFTER_RECEIVE = "queue:afterReceive"stringBEFORE_PROCESS = "queue:beforeProcess"stringBEFORE_RECEIVE = "queue:beforeReceive"stringBEFORE_START = "queue:beforeStart"stringPROCESSOR_EXCEPTION = "queue:processorException"Queue\Consumer\QueueConsumer
ClassSource on GitHubLean consumption runner. Binds processors to queues, polls each bound queue
round-robin, and dispatches messages to their processors while firing the
lifecycle events on Phalcon\Queue\Consumer\Events through the events
manager. The long-running operational shell (lifetime, signals) lives in
Phalcon\Queue\Consumer\Worker, which drives consumeOnce() and shares the
stop signal through stop() / isStopRequested().
Phalcon\Events\AbstractEventsAwarePhalcon\Queue\Consumer\QueueConsumer- implementsPhalcon\Events\EventsAwareInterface
Uses Phalcon\Contracts\Queue\Context · Phalcon\Contracts\Queue\Message · Phalcon\Contracts\Queue\Processor · Phalcon\Contracts\Queue\Queue · Phalcon\Events\AbstractEventsAware · Phalcon\Events\EventsAwareInterface
Method Summary
public__construct( ContextInterface$context )publicQueueConsumerbind(QueueInterface$queue,ProcessorInterface$processor)Binds a processor to a queue. Returns self for chaining.publicvoidconsume( int$timeout = 0 )Runs the consumption loop, blocking up to timeout milliseconds (0 =publicboolconsumeOnce()Polls every bound queue once, processing up to one message from each.publicvoidend()Fires the queue:afterEnd event. Called once the loop exits.publicboolisStopRequested()Whether a stop has been requested (by a signal, stop(), or anpublicvoidsetPollInterval( int$pollInterval )Sets the poll interval (in milliseconds).publicboolstart()Resets the stop flag and fires queue:beforeStart. Returns false when apublicvoidstop()Requests the consumption loop to stop after the current message.Properties
protectedarray$bindings = []Bound processors keyed by queue name.protectedContextInterface$contextprotectedint$pollInterval = 200Milliseconds slept between poll passes when nothing was received.protectedbool$shouldStop = falseMethods
__construct()
public function __construct( ContextInterface $context );bind()
public function bind(
QueueInterface $queue,
ProcessorInterface $processor
): QueueConsumer;Binds a processor to a queue. Returns self for chaining.
consume()
public function consume( int $timeout = 0 ): void;Runs the consumption loop, blocking up to timeout milliseconds (0 = block until stopped). The simple loop; production setups use Worker.
consumeOnce()
public function consumeOnce(): bool;Polls every bound queue once, processing up to one message from each. Returns true if any message was handled. Sleeps the poll interval when nothing was received so callers can loop tightly.
end()
public function end(): void;Fires the queue:afterEnd event. Called once the loop exits.
isStopRequested()
public function isStopRequested(): bool;Whether a stop has been requested (by a signal, stop(), or an
afterReceive listener returning false).
setPollInterval()
public function setPollInterval( int $pollInterval ): void;Sets the poll interval (in milliseconds).
start()
public function start(): bool;Resets the stop flag and fires queue:beforeStart. Returns false when a
listener cancels the start.
stop()
public function stop(): void;Requests the consumption loop to stop after the current message.
Queue\Consumer\Worker
ClassSource on GitHubLong-running operational shell around a QueueConsumer. Owns the outer loop, the bounded lifetime (max messages / seconds / memory, plus jitter) and - when ext-pcntl is available - graceful shutdown on SIGTERM/SIGINT/SIGQUIT. The current message always finishes before the loop stops (drain, not guillotine), because the stop flag is only checked between iterations.
Phalcon\Queue\Consumer\Worker
Uses Phalcon\Traits\Php\InfoTrait
Method Summary
public__construct(QueueConsumer$consumer,WorkerOptions$options = null)publicvoidhandleSignal( int$signal )Signal handler: requests a graceful stop.publicintrun()Runs the worker until a lifetime bound trips or a stop is requested.Properties
protectedQueueConsumer$consumerprotectedWorkerOptions$optionsMethods
__construct()
public function __construct(
QueueConsumer $consumer,
WorkerOptions $options = null
);handleSignal()
public function handleSignal( int $signal ): void;Signal handler: requests a graceful stop.
run()
public function run(): int;Runs the worker until a lifetime bound trips or a stop is requested. Returns the number of messages processed.
Queue\Consumer\WorkerOptions
ClassSource on GitHubImmutable lifetime bounds for a Worker. A value of 0 means “no limit”. The worker stops on whichever bound trips first.
Phalcon\Queue\Consumer\WorkerOptions
Method Summary
public__construct(int$maxMessages = 0,int$maxSeconds = 0,int$maxMemory = 0,int$jitter = 0)publicintgetJitter()publicintgetMaxMemory()publicintgetMaxMessages()publicintgetMaxSeconds()Properties
protectedint$jitter = 0Seconds added to maxSeconds (randomised per worker) so a pool does not restart in lockstep.protectedint$maxMemory = 0Memory ceiling in megabytes.protectedint$maxMessages = 0Maximum number of messages to process.protectedint$maxSeconds = 0Maximum run time in seconds.Methods
__construct()
public function __construct(
int $maxMessages = 0,
int $maxSeconds = 0,
int $maxMemory = 0,
int $jitter = 0
);getJitter()
public function getJitter(): int;getMaxMemory()
public function getMaxMemory(): int;getMaxMessages()
public function getMaxMessages(): int;getMaxSeconds()
public function getMaxSeconds(): int;Queue\Exceptions\DeliveryDelayNotSupportedException
ClassSource on GitHubThrown when the transport does not support a delivery delay.
BaseExceptionPhalcon\Queue\Exceptions\ExceptionPhalcon\Queue\Exceptions\DeliveryDelayNotSupportedException
Method Summary
Methods
__construct()
public function __construct();Queue\Exceptions\Exception
ClassSource on GitHubGeneric exception for the Queue component, and the base for every typed queue exception.
BaseExceptionPhalcon\Queue\Exceptions\Exception- implementsPhalcon\Queue\Exceptions\QueueThrowablePhalcon\Queue\Exceptions\DeliveryDelayNotSupportedExceptionPhalcon\Queue\Exceptions\InvalidDestinationExceptionPhalcon\Queue\Exceptions\InvalidMessageExceptionPhalcon\Queue\Exceptions\PriorityNotSupportedExceptionPhalcon\Queue\Exceptions\PurgeQueueNotSupportedExceptionPhalcon\Queue\Exceptions\SubscriptionConsumerNotSupportedExceptionPhalcon\Queue\Exceptions\TemporaryQueueNotSupportedExceptionPhalcon\Queue\Exceptions\TimeToLiveNotSupportedException
Uses Exception
Queue\Exceptions\InvalidDestinationException
ClassSource on GitHubThrown when a destination is not valid for the operation, for example a Topic passed where a Queue is required. The action verb (“send to”, “consume from”) tailors the message to the failing operation.
BaseExceptionPhalcon\Queue\Exceptions\ExceptionPhalcon\Queue\Exceptions\InvalidDestinationException
Method Summary
Methods
__construct()
public function __construct( string $action );Queue\Exceptions\InvalidMessageException
ClassSource on GitHubThrown when a message is not valid for the operation.
BaseExceptionPhalcon\Queue\Exceptions\ExceptionPhalcon\Queue\Exceptions\InvalidMessageException
Method Summary
Methods
__construct()
public function __construct();Queue\Exceptions\PriorityNotSupportedException
ClassSource on GitHubThrown when the transport does not support message priority.
BaseExceptionPhalcon\Queue\Exceptions\ExceptionPhalcon\Queue\Exceptions\PriorityNotSupportedException
Method Summary
Methods
__construct()
public function __construct();Queue\Exceptions\PurgeQueueNotSupportedException
ClassSource on GitHubThrown when the transport does not support purging a queue.
BaseExceptionPhalcon\Queue\Exceptions\ExceptionPhalcon\Queue\Exceptions\PurgeQueueNotSupportedException
Method Summary
Methods
__construct()
public function __construct();Queue\Exceptions\QueueThrowable
InterfaceSource on GitHubBase throwable contract for the Queue component. Every queue exception implements it, so callers can catch all queue errors with a single type.
\ThrowablePhalcon\Queue\Exceptions\QueueThrowable
Queue\Exceptions\SubscriptionConsumerNotSupportedException
ClassSource on GitHubThrown when the transport does not support subscription consumers.
BaseExceptionPhalcon\Queue\Exceptions\ExceptionPhalcon\Queue\Exceptions\SubscriptionConsumerNotSupportedException
Method Summary
Methods
__construct()
public function __construct();Queue\Exceptions\TemporaryQueueNotSupportedException
ClassSource on GitHubThrown when the transport does not support temporary queues.
BaseExceptionPhalcon\Queue\Exceptions\ExceptionPhalcon\Queue\Exceptions\TemporaryQueueNotSupportedException
Method Summary
Methods
__construct()
public function __construct();Queue\Exceptions\TimeToLiveNotSupportedException
ClassSource on GitHubThrown when the transport does not support a message time to live.
BaseExceptionPhalcon\Queue\Exceptions\ExceptionPhalcon\Queue\Exceptions\TimeToLiveNotSupportedException
Method Summary
Methods
__construct()
public function __construct();Queue\QueueFactory
ClassSource on GitHubBuilds a queue Context from the standard Phalcon config shape. Mirrors Phalcon\Cache\CacheFactory.
Phalcon\Factory\AbstractConfigFactoryPhalcon\Queue\QueueFactory
Uses Phalcon\Contracts\Queue\Context · Phalcon\Factory\AbstractConfigFactory
Method Summary
public__construct( AdapterFactory$factory = null )QueueFactory constructor. A default AdapterFactory is created when nonepublicContextInterfaceload( mixed$config )Builds a Context from a config array/object.publicContextInterfacenewInstance(string$name,array$options = [])Builds a Context for the named adapter.protectedstringgetExceptionClass()Properties
protectedAdapterFactory$adapterFactoryMethods
__construct()
public function __construct( AdapterFactory $factory = null );QueueFactory constructor. A default AdapterFactory is created when none is supplied, so the factory is usable straight from the DI container.
load()
public function load( mixed $config ): ContextInterface;Builds a Context from a config array/object.
newInstance()
public function newInstance(
string $name,
array $options = []
): ContextInterface;Builds a Context for the named adapter.
getExceptionClass()
protected function getExceptionClass(): string;