Mock or simulate Message Queue (JMS)

sergionni picture sergionni · Oct 19, 2010 · Viewed 41.7k times · Source

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?

Thanks.

Answer

jcalvert picture jcalvert · Oct 19, 2010

If you use Spring Integration, you can do this pretty easily. It has a very basic, abstract "Channel" implementation. You can create and test your producers and consumers, and when you're ready to move a step further, you just specify a JMS adapter on top of your Channel.