Reputation: 5659
My application uses numerous message queue connections which makes it difficult for me to run my environment locally. Currently, I'm simply connecting to the DEV or TEST environment which can be problematic when there are issues in those environments.
What are some ways that I could build a fake message queue service for local development? I would like to have some of the following functionality:
Is this possible?
Things I've considered include: - building a mock JMS service and deploying it somewhere (or run it up in a VM) - implement a mock service which returns different responses based on the incoming message
Anything else?
Upvotes: 3
Views: 1371
Reputation: 18376
You could use something like an embedded ActiveMQ Broker in your unit tests to test the behaviour of various parts of your application.
Creating an embedded broker is quite simple and you can adjust the configuration for different tests depending on what you are testing etc.
@Before
public void startBroker() throws Exception {
brokerService = new BrokerService();
brokerService.setPersistent(false);
brokerService.setUseJmx(false);
brokerService.addConnector("tcp://localhost:0");
brokerService.start();
brokerService.waitUntilStarted();
brokerURI = brokerService.getTransportConnectorByScheme("tcp").getPublishableConnectString();
}
Upvotes: 2