Skip to content
Convenient library that allows an embedded JMS (ActiveMQ) JMS broker to be set up as a JUnit @rule
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Build Status Maven Central Apache V2 License for GitHub Coverage Status DepShield Badge

JUnit extension that provides a ActiveMQ Embedded in-memory JMS Broker. It should be compatible with all the usual JMS integration tools such as Apache Camel and Spring JMS Template. Inspired by the Embedded DB JUnit Rule project.


  • because you want to test your JMS integration code without being dependent on a running external JMS Broker
  • setting up the broker manually for all your tests requires a lot of boilerplate code
  • I found myself repeating myself and decided that creating this library would make my life easier :-)


This library is distributed through the Sonatype OSS repo and should thus be widely available. Java 8 or higher is required. Feedback is more than welcome. Feel free to create issues if you find bugs or have feature requests for future releases :-)


  • version 0.2: rewritten core and added support for JUnit 5 Jupiter
  • version 0.1: initial release


JUnit 5 (v. 0.2+)

More information on JMS support is found in the project WIKI

Add dependency


Use ExtendWith to enable the extension and inject the connection factory using @EmbeddedJms

class EmbeddedJmsBrokerRequestReplySpringTest {

    private static final String TEST_MESSAGE = "Test message";

    private static final String DESTINATION = "queue:destination";

    *  The type of property must be either ConnectionFactory, ActiveMQFactory or URI.
    *  If it is a URI to the broker is injected
    private ConnectionFactory connectionFactory;

    @DisplayName("My test")
    void testJmsLogic() throws Exception {
       // make JMS magic
    @DisplayName("parameterized test")
    void connectionFactoryParameter(@EmbeddedJms ConnectionFactory connectionFactory) {
        // perform JMS magic


JUnit 4

Add dependency


Add to JUnit4 test

    public EmbeddedJmsRule embeddedJmsRule = EmbeddedJmsRule.builder().build();

    public void jmsTest() throws Exception {
        final ConnectionFactory connectionFactory = embeddedJmsRule.connectionFactory();
        // work your JMS magic


For more examples check the JUnit tests in this project

You can’t perform that action at this time.