267 lines
10 KiB
YAML
267 lines
10 KiB
YAML
name: Connection
|
|
class_comment: '# * An AMQP connection.
|
|
|
|
# *
|
|
|
|
# * @author Samuel Roze <samuel.roze@gmail.com>
|
|
|
|
# *
|
|
|
|
# * @final'
|
|
dependencies:
|
|
- name: InvalidArgumentException
|
|
type: class
|
|
source: Symfony\Component\Messenger\Exception\InvalidArgumentException
|
|
- name: LogicException
|
|
type: class
|
|
source: Symfony\Component\Messenger\Exception\LogicException
|
|
- name: TransportException
|
|
type: class
|
|
source: Symfony\Component\Messenger\Exception\TransportException
|
|
properties: []
|
|
methods:
|
|
- name: fromDsn
|
|
visibility: public
|
|
parameters:
|
|
- name: dsn
|
|
- name: options
|
|
default: '[]'
|
|
- name: amqpFactory
|
|
default: 'null'
|
|
comment: "# * An AMQP connection.\n# *\n# * @author Samuel Roze <samuel.roze@gmail.com>\n\
|
|
# *\n# * @final\n# */\n# class Connection\n# {\n# private const ARGUMENTS_AS_INTEGER\
|
|
\ = [\n# 'x-delay',\n# 'x-expires',\n# 'x-max-length',\n# 'x-max-length-bytes',\n\
|
|
# 'x-max-priority',\n# 'x-message-ttl',\n# ];\n# \n# /**\n# * @see https://github.com/php-amqp/php-amqp/blob/master/amqp_connection_resource.h\n\
|
|
# */\n# private const AVAILABLE_OPTIONS = [\n# 'host',\n# 'port',\n# 'vhost',\n\
|
|
# 'user',\n# 'login',\n# 'password',\n# 'queues',\n# 'exchange',\n# 'delay',\n\
|
|
# 'auto_setup',\n# 'retry',\n# 'persistent',\n# 'frame_max',\n# 'channel_max',\n\
|
|
# 'heartbeat',\n# 'read_timeout',\n# 'write_timeout',\n# 'confirm_timeout',\n\
|
|
# 'connect_timeout',\n# 'rpc_timeout',\n# 'cacert',\n# 'cert',\n# 'key',\n# 'verify',\n\
|
|
# 'sasl_method',\n# 'connection_name',\n# ];\n# \n# private const AVAILABLE_QUEUE_OPTIONS\
|
|
\ = [\n# 'binding_keys',\n# 'binding_arguments',\n# 'flags',\n# 'arguments',\n\
|
|
# ];\n# \n# private const AVAILABLE_EXCHANGE_OPTIONS = [\n# 'name',\n# 'type',\n\
|
|
# 'default_publish_routing_key',\n# 'flags',\n# 'arguments',\n# ];\n# \n# private\
|
|
\ AmqpFactory $amqpFactory;\n# private mixed $autoSetupExchange;\n# private mixed\
|
|
\ $autoSetupDelayExchange;\n# private \\AMQPChannel $amqpChannel;\n# private \\\
|
|
AMQPExchange $amqpExchange;\n# \n# /**\n# * @var \\AMQPQueue[]\n# */\n# private\
|
|
\ array $amqpQueues = [];\n# \n# private \\AMQPExchange $amqpDelayExchange;\n\
|
|
# private int $lastActivityTime = 0;\n# \n# public function __construct(\n# #[\\\
|
|
SensitiveParameter] private array $connectionOptions,\n# private array $exchangeOptions,\n\
|
|
# private array $queuesOptions,\n# ?AmqpFactory $amqpFactory = null,\n# ) {\n\
|
|
# if (!\\extension_loaded('amqp')) {\n# throw new LogicException(\\sprintf('You\
|
|
\ cannot use the \"%s\" as the \"amqp\" extension is not installed.', __CLASS__));\n\
|
|
# }\n# \n# $this->connectionOptions = array_replace_recursive([\n# 'delay' =>\
|
|
\ [\n# 'exchange_name' => 'delays',\n# 'queue_name_pattern' => 'delay_%exchange_name%_%routing_key%_%delay%',\n\
|
|
# ],\n# ], $connectionOptions);\n# $this->autoSetupExchange = $this->autoSetupDelayExchange\
|
|
\ = $connectionOptions['auto_setup'] ?? true;\n# $this->amqpFactory = $amqpFactory\
|
|
\ ?? new AmqpFactory();\n# }\n# \n# /**\n# * Creates a connection based on the\
|
|
\ DSN and options.\n# *\n# * Available options:\n# *\n# * * host: Hostname of\
|
|
\ the AMQP service\n# * * port: Port of the AMQP service\n# * * vhost: Virtual\
|
|
\ Host to use with the AMQP service\n# * * user|login: Username to use to connect\
|
|
\ the AMQP service\n# * * password: Password to use to connect to the AMQP service\n\
|
|
# * * read_timeout: Timeout in for income activity. Note: 0 or greater seconds.\
|
|
\ May be fractional.\n# * * write_timeout: Timeout in for outcome activity.\
|
|
\ Note: 0 or greater seconds. May be fractional.\n# * * connect_timeout: Connection\
|
|
\ timeout. Note: 0 or greater seconds. May be fractional.\n# * * confirm_timeout:\
|
|
\ Timeout in seconds for confirmation, if none specified transport will not wait\
|
|
\ for message confirmation. Note: 0 or greater seconds. May be fractional.\n#\
|
|
\ * * queues[name]: An array of queues, keyed by the name\n# * * binding_keys:\
|
|
\ The binding keys (if any) to bind to this queue\n# * * binding_arguments:\
|
|
\ Arguments to be used while binding the queue.\n# * * flags: Queue flags\
|
|
\ (Default: AMQP_DURABLE)\n# * * arguments: Extra arguments\n# * * exchange:\n\
|
|
# * * name: Name of the exchange\n# * * type: Type of exchange (Default:\
|
|
\ fanout)\n# * * default_publish_routing_key: Routing key to use when publishing,\
|
|
\ if none is specified on the message\n# * * flags: Exchange flags (Default:\
|
|
\ AMQP_DURABLE)\n# * * arguments: Extra arguments\n# * * delay:\n# * \
|
|
\ * queue_name_pattern: Pattern to use to create the queues (Default: \"delay_%exchange_name%_%routing_key%_%delay%\"\
|
|
)\n# * * exchange_name: Name of the exchange to be used for the delayed/retried\
|
|
\ messages (Default: \"delays\")\n# * * arguments: array of extra delay queue\
|
|
\ arguments (for example: ['x-queue-type' => 'classic', 'x-message-deduplication'\
|
|
\ => true,])\n# * * auto_setup: Enable or not the auto-setup of queues and exchanges\
|
|
\ (Default: true)\n# *\n# * * Connection tuning options (see http://www.rabbitmq.com/amqp-0-9-1-reference.html#connection.tune\
|
|
\ for details):\n# * * channel_max: Specifies highest channel number that\
|
|
\ the server permits. 0 means standard extension limit\n# * (see PHP_AMQP_MAX_CHANNELS\
|
|
\ constant)\n# * * frame_max: The largest frame size that the server proposes\
|
|
\ for the connection, including frame header\n# * and end-byte. 0 means\
|
|
\ standard extension limit (depends on librabbimq default frame size limit)\n\
|
|
# * * heartbeat: The delay, in seconds, of the connection heartbeat that the\
|
|
\ server wants.\n# * 0 means the server does not want a heartbeat. Note,\
|
|
\ librabbitmq has limited heartbeat support,\n# * which means heartbeats\
|
|
\ checked only during blocking calls.\n# *\n# * TLS support (see https://www.rabbitmq.com/ssl.html\
|
|
\ for details):\n# * * cacert: Path to the CA cert file in PEM format.\n#\
|
|
\ * * cert: Path to the client certificate in PEM format.\n# * * key:\
|
|
\ Path to the client key in PEM format.\n# * * verify: Enable or disable peer\
|
|
\ verification. If peer verification is enabled then the common name in the\n\
|
|
# * server certificate must match the server name. Peer verification is\
|
|
\ enabled by default."
|
|
- name: validateOptions
|
|
visibility: private
|
|
parameters:
|
|
- name: options
|
|
comment: null
|
|
- name: normalizeQueueArguments
|
|
visibility: private
|
|
parameters:
|
|
- name: arguments
|
|
comment: null
|
|
- name: hasCaCertConfigured
|
|
visibility: private
|
|
parameters:
|
|
- name: amqpOptions
|
|
comment: null
|
|
- name: publish
|
|
visibility: public
|
|
parameters:
|
|
- name: body
|
|
- name: headers
|
|
default: '[]'
|
|
- name: delayInMs
|
|
default: '0'
|
|
- name: amqpStamp
|
|
default: 'null'
|
|
comment: '# * @throws \AMQPException'
|
|
- name: countMessagesInQueues
|
|
visibility: public
|
|
parameters: []
|
|
comment: '# * Returns an approximate count of the messages in defined queues.'
|
|
- name: publishWithDelay
|
|
visibility: private
|
|
parameters:
|
|
- name: body
|
|
- name: headers
|
|
- name: delay
|
|
- name: amqpStamp
|
|
default: 'null'
|
|
comment: '# * @throws \AMQPException'
|
|
- name: publishOnExchange
|
|
visibility: private
|
|
parameters:
|
|
- name: exchange
|
|
- name: body
|
|
- name: routingKey
|
|
default: 'null'
|
|
- name: headers
|
|
default: '[]'
|
|
- name: amqpStamp
|
|
default: 'null'
|
|
comment: null
|
|
- name: setupDelay
|
|
visibility: private
|
|
parameters:
|
|
- name: delay
|
|
- name: routingKey
|
|
- name: isRetryAttempt
|
|
comment: null
|
|
- name: getDelayExchange
|
|
visibility: private
|
|
parameters: []
|
|
comment: null
|
|
- name: createDelayQueue
|
|
visibility: private
|
|
parameters:
|
|
- name: delay
|
|
- name: routingKey
|
|
- name: isRetryAttempt
|
|
comment: '# * Creates a delay queue that will delay for a certain amount of time.
|
|
|
|
# *
|
|
|
|
# * This works by setting message TTL for the delay and pointing
|
|
|
|
# * the dead letter exchange to the original exchange. The result
|
|
|
|
# * is that after the TTL, the message is sent to the dead-letter-exchange,
|
|
|
|
# * which is the original exchange, resulting on it being put back into
|
|
|
|
# * the original queue.'
|
|
- name: getRoutingKeyForDelay
|
|
visibility: private
|
|
parameters:
|
|
- name: delay
|
|
- name: finalRoutingKey
|
|
- name: isRetryAttempt
|
|
comment: null
|
|
- name: get
|
|
visibility: public
|
|
parameters:
|
|
- name: queueName
|
|
comment: '# * Gets a message from the specified queue.
|
|
|
|
# *
|
|
|
|
# * @throws \AMQPException'
|
|
- name: ack
|
|
visibility: public
|
|
parameters:
|
|
- name: message
|
|
- name: queueName
|
|
comment: null
|
|
- name: nack
|
|
visibility: public
|
|
parameters:
|
|
- name: message
|
|
- name: queueName
|
|
- name: flags
|
|
default: \AMQP_NOPARAM
|
|
comment: null
|
|
- name: setup
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: setupExchangeAndQueues
|
|
visibility: private
|
|
parameters: []
|
|
comment: null
|
|
- name: setupDelayExchange
|
|
visibility: private
|
|
parameters: []
|
|
comment: null
|
|
- name: getQueueNames
|
|
visibility: public
|
|
parameters: []
|
|
comment: '# * @return string[]'
|
|
- name: channel
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: queue
|
|
visibility: public
|
|
parameters:
|
|
- name: queueName
|
|
comment: null
|
|
- name: exchange
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: clearWhenDisconnected
|
|
visibility: private
|
|
parameters: []
|
|
comment: null
|
|
- name: clear
|
|
visibility: private
|
|
parameters: []
|
|
comment: null
|
|
- name: getDefaultPublishRoutingKey
|
|
visibility: private
|
|
parameters: []
|
|
comment: null
|
|
- name: purgeQueues
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: getRoutingKeyForMessage
|
|
visibility: private
|
|
parameters:
|
|
- name: amqpStamp
|
|
comment: null
|
|
- name: withConnectionExceptionRetry
|
|
visibility: private
|
|
parameters:
|
|
- name: callable
|
|
comment: null
|
|
traits:
|
|
- Symfony\Component\Messenger\Exception\InvalidArgumentException
|
|
- Symfony\Component\Messenger\Exception\LogicException
|
|
- Symfony\Component\Messenger\Exception\TransportException
|
|
interfaces: []
|