-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathActiveMQContainer.java
More file actions
38 lines (32 loc) · 1.34 KB
/
ActiveMQContainer.java
File metadata and controls
38 lines (32 loc) · 1.34 KB
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
/*
* Copyright The OpenZipkin Authors
* SPDX-License-Identifier: Apache-2.0
*/
package zipkin2.reporter.activemq;
import java.time.Duration;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.containers.wait.strategy.Wait;
import static org.testcontainers.utility.DockerImageName.parse;
final class ActiveMQContainer extends GenericContainer<ActiveMQContainer> {
static final Logger LOGGER = LoggerFactory.getLogger(ActiveMQContainer.class);
static final int ACTIVEMQ_PORT = 61616;
ActiveMQContainer() {
super(parse("ghcr.io/openzipkin/zipkin-activemq:3.6.0"));
withExposedPorts(ACTIVEMQ_PORT);
waitStrategy = Wait.forListeningPorts(ACTIVEMQ_PORT);
withStartupTimeout(Duration.ofSeconds(60));
withLogConsumer(new Slf4jLogConsumer(LOGGER));
}
ActiveMQSender.Builder newSenderBuilder(String queue) {
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
connectionFactory.setBrokerURL(brokerURL());
return ActiveMQSender.newBuilder().queue(queue).connectionFactory(connectionFactory);
}
String brokerURL() {
return "failover:tcp://" + getHost() + ":" + getMappedPort(ACTIVEMQ_PORT);
}
}