Skip to content

Commit 07fffc3

Browse files
Merge pull request #168 from magento-commerce/MCLOUD-13771
MCLOUD-13771: Add support of Active MQ
2 parents 3b9f1ad + bd37bb7 commit 07fffc3

File tree

10 files changed

+355
-32
lines changed

10 files changed

+355
-32
lines changed

config/services.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
<argument type="service" id="Magento\CloudDocker\Compose\ProductionBuilder\Service\Build" />
3939
<argument type="service" id="Magento\CloudDocker\Compose\ProductionBuilder\Service\Deploy" />
4040
<argument type="service" id="Magento\CloudDocker\Compose\ProductionBuilder\Service\RabbitMq" />
41+
<argument type="service" id="Magento\CloudDocker\Compose\ProductionBuilder\Service\ActiveMqArtemis" />
4142
<argument type="service" id="Magento\CloudDocker\Compose\ProductionBuilder\Service\Node" />
4243
<argument type="service" id="Magento\CloudDocker\Compose\ProductionBuilder\Service\Mailhog" />
4344
<argument type="service" id="Magento\CloudDocker\Compose\ProductionBuilder\Service\Blackfire" />

src/Compose/BuilderInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ interface BuilderInterface
2828
public const SERVICE_SELENIUM = ServiceInterface::SERVICE_SELENIUM;
2929
public const SERVICE_TLS = ServiceInterface::SERVICE_TLS;
3030
public const SERVICE_RABBITMQ = ServiceInterface::SERVICE_RABBITMQ;
31+
public const SERVICE_ACTIVEMQ_ARTEMIS = ServiceInterface::SERVICE_ACTIVEMQ_ARTEMIS;
3132
public const SERVICE_REDIS = ServiceInterface::SERVICE_REDIS;
3233
public const SERVICE_VALKEY = ServiceInterface::SERVICE_VALKEY;
3334
public const SERVICE_ELASTICSEARCH = ServiceInterface::SERVICE_ELASTICSEARCH;
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CloudDocker\Compose\ProductionBuilder\Service;
9+
10+
use Magento\CloudDocker\Compose\BuilderInterface;
11+
use Magento\CloudDocker\Compose\ProductionBuilder\ServiceBuilderInterface;
12+
use Magento\CloudDocker\Config\Config;
13+
use Magento\CloudDocker\Service\ServiceFactory;
14+
15+
/**
16+
* Returns ActiveMq Artemis service configuration
17+
*/
18+
class ActiveMqArtemis implements ServiceBuilderInterface
19+
{
20+
/**
21+
* @var ServiceFactory
22+
*/
23+
private ServiceFactory $serviceFactory;
24+
25+
/**
26+
* @param ServiceFactory $serviceFactory
27+
*/
28+
public function __construct(ServiceFactory $serviceFactory)
29+
{
30+
$this->serviceFactory = $serviceFactory;
31+
}
32+
33+
/**
34+
* @inheritDoc
35+
*/
36+
public function getName(): string
37+
{
38+
return BuilderInterface::SERVICE_ACTIVEMQ_ARTEMIS;
39+
}
40+
41+
/**
42+
* @inheritDoc
43+
*/
44+
public function getServiceName(): string
45+
{
46+
return $this->getName();
47+
}
48+
49+
/**
50+
* @inheritDoc
51+
*/
52+
public function getConfig(Config $config): array
53+
{
54+
return $this->serviceFactory->create(
55+
$this->getServiceName(),
56+
$config->getServiceVersion($this->getServiceName()),
57+
[],
58+
$config->getServiceImage($this->getServiceName()),
59+
$config->getCustomRegistry()
60+
);
61+
}
62+
63+
/**
64+
* @inheritDoc
65+
*/
66+
public function getNetworks(): array
67+
{
68+
return [BuilderInterface::NETWORK_MAGENTO];
69+
}
70+
71+
/**
72+
* @inheritDoc
73+
*/
74+
public function getDependsOn(Config $config): array
75+
{
76+
return [];
77+
}
78+
}

src/Config/Relationship.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ class Relationship
8181
'password' => 'guest',
8282
]
8383
],
84+
'activemq-artemis' => [
85+
[
86+
'host' => 'activemq-artemis',
87+
'port' => '61616',
88+
'username' => 'admin',
89+
'password' => 'admin',
90+
'web_console_port' => '8161',
91+
]
92+
],
8493
'zookeeper' => [
8594
[
8695
'host' => 'zookeeper',

src/Config/Source/CloudSource.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,31 @@ class CloudSource implements SourceInterface
2525
/**
2626
* @var FileList
2727
*/
28-
private $fileList;
28+
private FileList $fileList;
2929

3030
/**
3131
* @var Filesystem
3232
*/
33-
private $filesystem;
33+
private Filesystem $filesystem;
3434

3535
/**
3636
* @var ServiceFactory
3737
*/
38-
private $serviceFactory;
38+
private ServiceFactory $serviceFactory;
3939

4040
/**
4141
* @var array
4242
*/
43-
private static $map = [
43+
private static array $map = [
4444
ServiceInterface::SERVICE_DB => ['db', 'database', 'mysql'],
4545
ServiceInterface::SERVICE_DB_QUOTE => ['mysql-quote'],
4646
ServiceInterface::SERVICE_DB_SALES => ['mysql-sales'],
4747
ServiceInterface::SERVICE_ELASTICSEARCH => ['elasticsearch', 'es'],
4848
ServiceInterface::SERVICE_OPENSEARCH => ['opensearch', 'os'],
4949
ServiceInterface::SERVICE_REDIS => ['redis'],
5050
ServiceInterface::SERVICE_VALKEY => ['cache','valkey'],
51-
ServiceInterface::SERVICE_RABBITMQ => ['rmq', 'rabbitmq']
51+
ServiceInterface::SERVICE_RABBITMQ => ['rmq', 'rabbitmq'],
52+
ServiceInterface::SERVICE_ACTIVEMQ_ARTEMIS => ['activemq', 'artemis', 'activemq-artemis']
5253
];
5354

5455
/**
@@ -66,9 +67,10 @@ public function __construct(
6667
$this->serviceFactory = $serviceFactory;
6768
}
6869

69-
/**
70-
* @inheritDoc
71-
*/
70+
/**
71+
* @inheritDoc
72+
* @throws ConfigurationMismatchException
73+
*/
7274
public function read(): Repository
7375
{
7476
$appConfigFile = $this->fileList->getAppConfig();

src/Service/ServiceFactory.php

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class ServiceFactory
5252
/**
5353
* @var array
5454
*/
55-
private static $config = [
55+
private static array $config = [
5656
ServiceInterface::SERVICE_PHP_CLI => [
5757
'image' => 'magento/magento-cloud-docker-php',
5858
'pattern' => '%s:%s-cli-%s',
@@ -153,6 +153,21 @@ class ServiceFactory
153153
'image' => 'rabbitmq',
154154
'pattern' => self::PATTERN_STD,
155155
],
156+
ServiceInterface::SERVICE_ACTIVEMQ_ARTEMIS => [
157+
'image' => 'apache/activemq-artemis',
158+
'pattern' => self::PATTERN_STD,
159+
'config' => [
160+
'ports' => [61616, 61613, 8161],
161+
'environment' => [
162+
'ARTEMIS_USER' => 'admin',
163+
'ARTEMIS_PASSWORD' => 'admin',
164+
],
165+
'volumes' => [
166+
'/var/lib/artemis/data',
167+
'/var/log/artemis',
168+
]
169+
],
170+
],
156171
ServiceInterface::SERVICE_NODE => [
157172
'image' => 'node',
158173
'pattern' => self::PATTERN_STD
@@ -192,7 +207,7 @@ class ServiceFactory
192207
/**
193208
* @var FileList
194209
*/
195-
private $fileList;
210+
private FileList $fileList;
196211

197212
/**
198213
* @var string
@@ -208,12 +223,12 @@ public function __construct(FileList $fileList)
208223
}
209224

210225
/**
211-
* @param string $name
212-
* @param string $version
213-
* @param array $config
214-
* @param string|null $image
215-
* @param string|null $customRegistry
216-
* @param string|null $imagePattern
226+
* @param string $name
227+
* @param string $version
228+
* @param array $config
229+
* @param string|null $image
230+
* @param string|null $customRegistry
231+
* @param string|null $imagePattern
217232
* @return array
218233
* @throws ConfigurationMismatchException
219234
*/
@@ -226,10 +241,12 @@ public function create(
226241
?string $imagePattern = null
227242
): array {
228243
if (!array_key_exists($name, self::$config)) {
229-
throw new ConfigurationMismatchException(sprintf(
230-
'Service "%s" is not supported',
231-
$name
232-
));
244+
throw new ConfigurationMismatchException(
245+
sprintf(
246+
'Service "%s" is not supported',
247+
$name
248+
)
249+
);
233250
}
234251

235252
$metaConfig = self::$config[$name];
@@ -246,7 +263,7 @@ public function create(
246263
}
247264

248265
/**
249-
* @param string $name
266+
* @param string $name
250267
* @return string
251268
* @throws ConfigurationMismatchException
252269
*/
@@ -256,14 +273,16 @@ public function getDefaultImage(string $name): string
256273
return self::$config[$name]['image'];
257274
}
258275

259-
throw new ConfigurationMismatchException(sprintf(
260-
'Default image for %s cannot be resolved',
261-
$name
262-
));
276+
throw new ConfigurationMismatchException(
277+
sprintf(
278+
'Default image for %s cannot be resolved',
279+
$name
280+
)
281+
);
263282
}
264283

265284
/**
266-
* @param string $name
285+
* @param string $name
267286
* @return string
268287
* @throws ConfigurationMismatchException
269288
*/
@@ -273,10 +292,12 @@ public function getDefaultVersion(string $name): string
273292
return self::$config[$name]['version'];
274293
}
275294

276-
throw new ConfigurationMismatchException(sprintf(
277-
'Default version for %s cannot be resolved',
278-
$name
279-
));
295+
throw new ConfigurationMismatchException(
296+
sprintf(
297+
'Default version for %s cannot be resolved',
298+
$name
299+
)
300+
);
280301
}
281302

282303
/**

src/Service/ServiceInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ interface ServiceInterface
2727
public const SERVICE_ELASTICSEARCH = 'elasticsearch';
2828
public const SERVICE_OPENSEARCH = 'opensearch';
2929
public const SERVICE_RABBITMQ = 'rabbitmq';
30+
public const SERVICE_ACTIVEMQ_ARTEMIS = 'activemq-artemis';
3031
public const SERVICE_NODE = 'node';
3132
public const SERVICE_VARNISH = 'varnish';
3233
public const SERVICE_SELENIUM = 'selenium';
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CloudDocker\Test\Functional\Acceptance;
9+
10+
/**
11+
* ActiveMQ Artemis acceptance tests for PHP 8.4 and Magento 2.4.x
12+
*
13+
* @group php84
14+
*/
15+
class ActivemqArtemis84Cest extends ActivemqArtemisCest
16+
{
17+
/**
18+
* Template version for testing
19+
*/
20+
protected const TEMPLATE_VERSION = '2.4.9-alpha-opensearch3.0';
21+
}

0 commit comments

Comments
 (0)