-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AmqpAgentParameters.php
166 lines (141 loc) · 4.51 KB
/
AmqpAgentParameters.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php
/**
* @author Marwan Al-Soltany <[email protected]>
* @copyright Marwan Al-Soltany 2020
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace MAKS\AmqpAgent\Config;
use PhpAmqpLib\Message\AMQPMessage;
use PhpAmqpLib\Exchange\AMQPExchangeType;
use MAKS\AmqpAgent\Config\AbstractParameters;
/**
* A class that contains all AMQP Agent parameters as constants.
* @since 1.2.0
*/
final class AmqpAgentParameters extends AbstractParameters
{
public const PREFIX = 'maks.amqp.agent.';
public const COMMAND_PREFIX = '__COMMAND__';
public const COMMAND_SYNTAX = [
self::COMMAND_PREFIX => [
'ACTION' => 'OBJECT',
'PARAMS' => [
'NAME' => 'VALUE'
]
]
];
public const CONNECTION_OPTIONS = [
'host' => 'localhost',
'port' => 5672,
'user' => 'guest',
'password' => 'guest',
'vhost' => '/',
'insist' => false,
'login_method' => 'AMQPLAIN',
'login_response' => null,
'locale' => 'en_US',
'connection_timeout' => 120,
'read_write_timeout' => 120,
'context' => null,
'keepalive' => true,
'heartbeat' => 60,
'channel_rpc_timeout' => 120,
'ssl_protocol' => null
];
public const CHANNEL_OPTIONS = [
'channel_id' => null
];
public const QUEUE_OPTIONS = [
'queue' => self::PREFIX . 'queue',
'passive' => false,
'durable' => true,
'exclusive' => false,
'auto_delete' => false,
'nowait' => false,
'arguments' => [],
'ticket' => null
];
public const EXCHANGE_OPTIONS = [
'exchange' => self::PREFIX . 'exchange',
'type' => AMQPExchangeType::HEADERS,
'passive' => false,
'durable' => true,
'auto_delete' => false,
'internal' => false,
'nowait' => false,
'arguments' => [],
'ticket' => null
];
public const BIND_OPTIONS = [
'queue' => self::PREFIX . 'queue',
'exchange' => self::PREFIX . 'exchange',
'routing_key' => self::PREFIX . 'routing',
'nowait' => false,
'arguments' => [],
'ticket' => null
];
public const MESSAGE_OPTIONS = [
'body' => '{}',
'properties' => [
'content_type' => 'application/json',
'content_encoding' => 'UTF-8',
'delivery_mode' => AMQPMessage::DELIVERY_MODE_PERSISTENT
]
];
public const PUBLISH_OPTIONS = [
'msg' => null,
'exchange' => self::PREFIX . 'exchange',
'routing_key' => self::PREFIX . 'routing',
'mandatory' => false,
'immediate' => false,
'ticket' => null
];
public const QOS_OPTIONS = [
'prefetch_size' => null,
'prefetch_count' => 5,
'a_global' => null
];
public const WAIT_OPTIONS = [
'allowed_methods' => null,
'non_blocking' => true,
'timeout' => 3600
];
public const CONSUME_OPTIONS = [
'queue' => self::PREFIX . 'queue',
'consumer_tag' => self::PREFIX . 'consumer',
'no_local' => false,
'no_ack' => false,
'exclusive' => false,
'nowait' => false,
'callback' => 'MAKS\AmqpAgent\Helper\Example::callback',
'ticket' => null,
'arguments' => []
];
public const ACK_OPTIONS = [
'multiple' => false
];
public const NACK_OPTIONS = [
'multiple' => false,
'requeue' => true
];
public const GET_OPTIONS = [
'queue' => self::PREFIX . 'queue',
'no_ack' => false,
'ticket' => null
];
public const CANCEL_OPTIONS = [
'consumer_tag' => self::PREFIX . 'consumer',
'nowait' => false,
'noreturn' => false
];
public const RECOVER_OPTIONS = [
'requeue' => true,
];
public const REJECT_OPTIONS = [
'requeue' => true,
];
public const RPC_CONNECTION_OPTIONS = self::CONNECTION_OPTIONS;
public const RPC_QUEUE_NAME = self::PREFIX . 'maks.amqp.agent.rpc.queue';
}