sergionni sergionni - 1 year ago 201
Java Question

Mock or simulate Message Queue (JMS)

There is a message(text), which format and content i definitely know.

For now,class in Java,that parses and reads this message from file,is implemented.

In real world, this message will come from Message Queue.

For now I should simulate, mock or generate Message Queue on my local PC for testing purposes.

Java spec(java jms):

JMS provider: A messaging system that implements the JMS specification.
JMS clients: Java applications that send and receive messages.
Messages: Objects that are used to communicate information between JMS clients.

Concerning this specification, i need JMS provider.

JMS client-it's my class that reads message.

Message itself i know.

So the question is how to start message queue?

How can i simulate it programmaticaly from Java code? Can i mock it somehow?


Answer Source

Generally it is a bad practice to mock or simulate an external system, such as JMS. A better idea would be to abstract your logic into a standalone bean, implement a delegation layer that would bridge JMS with your bean. With such design you can test your bean in isolation from JMS and then have system test that would test the whole integration with real JMS system.

As for in-process JMS you can look at SomnifugiJMS.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download