Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embedded broker as maven dependency #19

Closed
dowhiletrue opened this issue May 25, 2019 · 11 comments · Fixed by #164
Closed

Embedded broker as maven dependency #19

dowhiletrue opened this issue May 25, 2019 · 11 comments · Fixed by #164
Labels
feature Contributions welcome!

Comments

@dowhiletrue
Copy link

Problem or use case

I would like to test my mqtt client/broker setup using JUnit tests.
Since it is cumbersome to start a broker before running the tests, an embedded MQTT 5 compliant broker would ease up the testing.

Preferred solution or suggestions

  • HiveMQ broker as maven dependency
  • Documentation on how to start the broker within a running Java process (e.g. Junit test)
@sauroter
Copy link
Member

Hi @dowhiletrue,
Thank you for your feature request.

We see the need for something like that, but are right now not sure how to best tackle the issue. Internal considerations are ongoing at the moment.

We will keep the issue open and track progress once decisions are made.

Kind regards
Georg

@siepkes
Copy link

siepkes commented Jul 19, 2019

@sauroter I see some places (like this one) where an embedded mode is mentioned. However I can't find any documentation about it. Does the embedded mode still exist?

@schaebo schaebo added the feature Contributions welcome! label Jul 30, 2019
@ObviousDWest
Copy link

I am also interested in this feature. I would prefer it be compatible with Spring (or at least not preclude it), so I can integrate with other standard systems (logging, actuator, RestTemplate, caching, permissions, spring security, maybe jms...). Eg. for implementing hivemq extensions. While some of this can be done by splitting things into microservices, integration tests are much easier if I can recombine all that into a compound application.

I guess I could modify HiveMQServer.java.

@abonstu
Copy link

abonstu commented Nov 14, 2019

Any further feedback here guys?

There are a bunch of projects looking to transition away from moquette but maven dependency support would seem to be a pretty common prerequisite.

@St0n3Gh0st
Copy link

I also need to be able to use maven to get HiveMQ CE as an embedded broker.

Any timeline for either maven or gradle support?

@nhitchins
Copy link

Having the same problem - been looking for a solution for a while. Any ETA?

@ramod8
Copy link

ramod8 commented Feb 11, 2020

Has there been any progress on this? I have been waiting on this for a while.

@sauroter
Copy link
Member

sauroter commented Feb 12, 2020

Hi,
oops I forgot to update this ticket. I am sorry.
Actually there has been some progress. Wich at least in part solves this issue.

There now exists an official docker image for HiveMQ CE.

Now you can use the Testcontainers project to pretty easily build a test dependency. Your custom container can look something like this:

public class HiveMQCEContainer extends GenericContainer<HiveMQCEContainer> {

    public HiveMQCEContainer() {
        super("hivemq/hivemq-ce:2020.2");

        this.withExposedPorts(1883)
                .waitingFor(Wait.forListeningPort());
    }


    @Test
    public void test() {
        final HiveMQCEContainer testContainer = new HiveMQCEContainer();
        testContainer.start();
        final Mqtt5BlockingClient client =
                Mqtt5Client.builder()
                        .serverHost("localhost")
                        .serverPort(testContainer.getMappedPort(1883))
                        .build().toBlocking();


        final Mqtt5ConnAck connAck = client.connect();

        assertEquals(0, connAck.getReasonCode().getCode());
    }
}

I know that this does not solve every part of this issue, but it should be a starting point.

Feel free to contact me if you have any questions.
Cheers

Georg

@fbeister
Copy link

Thanks for the heads-up - at least for my usecase (https://community.hivemq.com/t/hivemq-ce-as-maven-dependency/39) docker is not a solution. Should I open a separate issue for that? Do you have a roadmap for real maven integration?

@splatch
Copy link

splatch commented Feb 13, 2020

Well, I know its kind of side topic, however as you ask for maven centric solution I can bring one idea. ActiveMQ 5.x can be embedded with dedicated maven plugin and it has support for MQTT transport. It will be able to serve you as long as you need basic transport and not HiveMQ specific extensions on other side.

@sauroter
Copy link
Member

We now have an embedded broker api in master, so this issue is closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Contributions welcome!
Projects
None yet
Development

Successfully merging a pull request may close this issue.