model/modx/registry/moddbregister.class.php
- package
- modx
- subpackage
- registry
- Classes
- modDbRegister
Description
This file contains a simple database implementation of modRegister.
\modDbRegister
- Extends from
- \modRegister
- package
- modx
- Properties
- $_queue
- Methods
- __construct
- _initQueue
- _readMessage
- close
- connect
- read
- send
Description
A simple, file-based implementation of modRegister.
This implementation does not address transactional conflicts and should be used in non-critical processes that are easily recoverable.
Properties
$_queue
\modDbRegisterQueue $_queue = 'null'
The queue object representing this modRegister instance.
Details
-
\modDbRegisterQueue
- visibility
- protected
- default
- null
- final
- false
- static
- false
- access
- protected
Methods
__construct
__construct(
\modX $modx, string $key, array $options
=
array
)
:
Construct a new modDbRegister instance.
Arguments
- $modx
- \modX
&$modx A reference to the modX instance - $key
- string
The key of the registry to load - $options
- array
An array of options to set
Details
- visibility
- public
- final
- false
- static
- false
_initQueue
_initQueue(
string $key, array $options
)
:
\modDbRegisterQueue
Initialize a new queue
Arguments
- $key
- string
The new name of the queue - $options
- array
An array of options
Output
- \modDbRegisterQueue
- A reference to the new Queue object
Details
- visibility
- protected
- final
- false
- static
- false
_readMessage
_readMessage(
object $obj, boolean $remove
=
true
)
:
mixed
Read a message record from the queue topic.
Arguments
- $obj
- object
The message data to read. - $remove
- boolean
Indicates if the message should be deleted once it is read.
Output
- mixed
- The message returned
Details
- visibility
- protected
- final
- false
- static
- false
- todo
- Implement support for reading various message types, other than executable PHP format.
close
close(
)
:
boolean
Close the connection to the register service implementation.
Output
- boolean
- Indicates if the connection was closed successfully.
Details
- visibility
- public
- final
- false
- static
- false
connect
connect(
array $attributes
=
array
)
:
boolean
Connect to the register service implementation. If we made it here, we connected fine.
Arguments
- $attributes
- array
A collection of attributes required for connection to the register.
Output
- boolean
- Indicates if the connection was successful.
Details
- visibility
- public
- final
- false
- static
- false
read
read(
array $options
=
array
)
:
mixed
This implementation supports the following options and default behavior: <ul> <li>msg_limit: Only poll until the specified limit of messages has been digested. Default is 5 messages.</li> <li>time_limit: Poll for new messages for a specified number of seconds. Default is the result of the php time_limit system variable.</li> <li>poll_limit: Only poll for new subscriptions a specified number of times. Default is unlimited.</li> <li>poll_interval: Wait a specified number of seconds between each additional polling iteration, after the initial one. Default is no interval.</li> <li>remove_read: Remove the message immediately upon digesting it.
Default is true.
Arguments
- $options
- array
An array of general or protocol specific options.
Output
- mixed
- The resulting message from the register.
Details
- visibility
- public
- final
- false
- static
- false
send
send(
string $topic, mixed $message, array $options
=
array
)
:
boolean
This implementation provides support for sending messages using either time-based indexes so they are consumed in the order they are produced, or named indexes typically used when consumers want to subscribe to a specific, unique message. Individual messages or message collections passed in numerically indexed arrays are treated as time-based messages and message collections passed in associative arrays are treated as named messages. e.g., to send a single message as named, wrap it in an array with the intended message name as the key.
This implementation also supports a message_type option to indicate the format of the message being sent to the register. Currently only supports executable PHP format.
Other implementation specific options include:
- delay: Number of seconds to delay the message. This option is only supported for time-based messages.
- ttl: Number of seconds the message is valid in the queue. Default is forever or 0.
- kill: Tells a message consumer to stop consuming any more messages after reading any message sent with this option.
Arguments
- $topic
- string
A topic container in which to broadcast the message. - $message
- mixed
A message, or collection of messages to be sent to the register. - $options
- array
An optional array of general or protocol specific message properties.
Output
- boolean
- Indicates if the message was recorded.
Details
- visibility
- public
- final
- false
- static
- false
- todo
- Implement support for sending various message types, other than executable PHP format.