Search code examples
activemq-artemisjakarta-migration

Is there currently a way to run Jakarta ActiveMQ Artemis embedded in JUnit 5 tests using the OpenWire protocol?


I'm trying to move my application from EE8 to EE10 and while ActiveMQ has published a Jakarta-compatible "transition" client, as per my earlier question, I need to run an embedded, OpenWire compatible, broker for some tests.

The official Apache ActiveMQ Artemis project publishes the artemis-jakarta-server, but I'm unable to create a JUnit 5 extension supporting the OpenWire protocol. They also publish an artifact called artemis-junit-5, but this is not Jakarta compatible.

As far as I can tell, the missing piece is a Jakarta compatible artemis-openwire-protocol artifact.

Any ideas?


Solution

  • I found a solution to my problem, but it doesn't really involve embedding. By utilizing my new favourite tool Testcontainers I was able to remove ActiveMQ server from my classpath, thereby sidestepping the problem entirely. Since there currently is no "official" ActiveMQ Testcontainers library, I created my own using their excellent API.

    public class ActiveMQContainer extends GenericContainer<ActiveMQContainer> {
    
    private static final int OPENWIRE_PORT = 61616;
    public ActiveMQContainer(Logger logger) {
        this(logger, "5.18.2");
    }
    
    public ActiveMQContainer(Logger logger, String version) {
        super(DockerImageName.parse("apache/activemq-classic:" + version));
    
        setExposedPorts(List.of(OPENWIRE_PORT));
        setLogConsumers(List.of(new Slf4jLogConsumer(logger)));
    }
    
    public String getURL() {
        return "tcp://localhost:" + getMappedPort(OPENWIRE_PORT);
    }
    

    }

    I realize this technically isn't an answer to the question I posed but I feel it's better solution even though it depends on Docker.