You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class RabbitMQConnector implements ConnectorInterface
11
16
{
12
-
/** @var AMQPStreamConnection */
13
-
private$connection;
17
+
/**
18
+
* @var Dispatcher
19
+
*/
20
+
private$dispatcher;
21
+
22
+
publicfunction__construct(Dispatcher$dispatcher)
23
+
{
24
+
$this->dispatcher = $dispatcher;
25
+
}
14
26
15
27
/**
16
28
* Establish a queue connection.
@@ -21,23 +33,41 @@ class RabbitMQConnector implements ConnectorInterface
21
33
*/
22
34
publicfunctionconnect(array$config): Queue
23
35
{
24
-
// create connection with AMQP
25
-
$this->connection = newAMQPStreamConnection(
26
-
$config['host'],
27
-
$config['port'],
28
-
$config['login'],
29
-
$config['password'],
30
-
$config['vhost']
31
-
);
32
-
33
-
returnnewRabbitMQQueue(
34
-
$this->connection,
35
-
$config
36
-
);
37
-
}
36
+
if (false == array_key_exists('factory_class', $config)) {
37
+
thrownew \LogicException('The factory_class option is missing though it is required.');
38
+
}
38
39
39
-
publicfunctionconnection()
40
-
{
41
-
return$this->connection;
40
+
$factoryClass = $config['factory_class'];
41
+
if (false == class_exists($factoryClass) || false == (new \ReflectionClass($factoryClass))->implementsInterface(InteropAmqpConnectionFactory::class)) {
42
+
thrownew \LogicException(sprintf('The factory_class option has to be valid class that implements "%s"', InteropAmqpConnectionFactory::class));
0 commit comments