问题描述
有一条消息(文本),我肯定知道其格式和内容.
目前,已经实现了Java类,该类从文件中解析并读取此消息.
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.
目前,我应该在本地PC上模拟,模拟或生成Message Queue以进行测试.
For now I should simulate, mock or generate Message Queue on my local PC for testing purposes.
Java规范( 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.
关于此规范,我需要 JMS提供程序 .
Concerning this specification, i need JMS provider.
JMS客户端-这是我的类,可以读取消息.
我知道消息本身.
JMS client-it's my class that reads message.
Message itself i know.
所以问题是如何启动消息队列?
如何从Java代码中以编程方式模拟它?我可以以某种方式嘲笑它吗?
So the question is how to start message queue?
How can i simulate it programmaticaly from Java code? Can i mock it somehow?
谢谢.
推荐答案
如果使用 Spring集成,您可以轻松完成此操作.它具有非常基本的抽象通道"实现.您可以创建和测试生产者和消费者,并且准备好进一步操作时,只需在Channel顶部指定一个JMS适配器即可.
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.
这篇关于模拟或模拟消息队列(JMS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!