如何调试JmsTemplate?
我正在使用 SpringsourceTool 和 Spring 框架。
我有一些代码使用 JmsTemplate
通过 convertAndSend(Object)
发送消息。我想将其作为 JUnit 测试进行调试。因此,对于测试类,我选择Run->Debug As->JUnit Test
。
我设置了一个断点,并且能够密切跟踪跟踪,直到我点击 jmsTemplate.convertAndSend(obj)
,在这种情况下,当我点击 Step Into (F5)
时,我会得到一个
Source not found.
Edit Source Lookup Path
谢谢!
I am using SpringsourceTool and the Spring framework.
I have some code that uses JmsTemplate
to send messages via convertAndSend(Object)
. I want to debug it as a JUnit test. So, for the test class, I select Run->Debug As->JUnit Test
.
I set a breakpoint and was able to closely follow the trace until I hit jmsTemplate.convertAndSend(obj)
in which case when I hit Step Into (F5)
, I get a
Source not found.
Edit Source Lookup Path
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,您的问题是如何使用 Eclipse,并将源附加到库依赖项。对于
JmsTemplate
或 Spring 来说这不是问题。话虽如此,您不需要对
JmsTemplate
进行单元测试 - Spring 团队已经对其进行了单元测试。你可以假设它有效。如果您的代码与
JmsTemplate
耦合,请考虑将其重构为依赖于JmsOperations
接口。然后,您可以在测试中模拟或删除该接口。Firstly, your problem is to with how to use Eclipse, and attaching sources to your library dependencies. This isn't a problem with
JmsTemplate
or Spring.Having said that, you don't need to unit test
JmsTemplate
- it's already been unit tested by the Spring team. You can assume it works.If your code is coupled to
JmsTemplate
, then consider refactoring it to depend on theJmsOperations
interface instead. You can then mock or stub out that interface in your test.如果需要对您的 JMS 通信进行更深入的内省:
logging.level.com.ibm.mq=TRACE
添加到您的application.properties
-Dcom。 ibm.msg.client.commonservices.trace.status=ON
到您的 java-startup-parameters然后检查
*.TRC-包含大量调试信息的文件
请参阅:https://www.ibm.com/docs/en/ibm-mq/9.0?topic=tmcja-collecting-mq-classes-jms -通过使用java-system-property进行跟踪
If a deeper introspection into your JMS-communication is needed:
logging.level.com.ibm.mq=TRACE
to yourapplication.properties
-Dcom.ibm.msg.client.commonservices.trace.status=ON
to your java-startup-parametersThen check
*.TRC
-file with a lot of debug-informationsee: https://www.ibm.com/docs/en/ibm-mq/9.0?topic=tmcja-collecting-mq-classes-jms-trace-by-using-java-system-property