Are there any simple AMQP server/broker implementation written in Java?
I need to use it for local integration tests. I would like to start it from ant/maven, and I don't need any features like clustering, persistence, performance and so on. Just a mock RabbitMQ-like instance, without installation (just as a dependency at maven pom) and configuration.
I'd say it is perfectly legal to write integration tests / end-to-end tests / automated user acceptance tests that test the whole application, including everything that is done within the MQs. You should select the test cases that fire up something like this wiesely, as it drastically slows down the feedback loop of your tests.
There is org.apache.qpid, which you can simply include in your application as mvn/gradle (mvn central) dependency (gradle example):
testCompile 'org.apache.qpid:qpid-broker:6.0.1'
and then add a Rule containing a ExternalResource that fires up the broker before your tests, somewhat similar to this rather simple setup:
@Rule
private static final ExternalResource embeddedAMQPBroker = new ExternalResource() {
Broker broker;
@Override
protected void before() throws Throwable {
BrokerOptions brokerOptions = new BrokerOptions();
brokerOptions.setConfigProperty("qpid.amqp_port", "55672");
broker = new Broker();
broker.startup(brokerOptions);
}
@Override
protected void after() {
broker.shutdown();
}
};
Untested, since for me this did not work, because all my applications contain Jetty 9 and QPID (still) requires a Jetty<9.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With