How do I debug JmsTemplate?
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 开发者_JAVA百科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!
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 the JmsOperations
interface instead. You can then mock or stub out that interface in your test.
If a deeper introspection into your JMS-communication is needed:
- add
logging.level.com.ibm.mq=TRACE
to yourapplication.properties
- add
-Dcom.ibm.msg.client.commonservices.trace.status=ON
to your java-startup-parameters
Then check
- your application-logfile
- the application-start-directory, where you sould find a
*.TRC
-file with a lot of debug-information
see: https://www.ibm.com/docs/en/ibm-mq/9.0?topic=tmcja-collecting-mq-classes-jms-trace-by-using-java-system-property
精彩评论