我正在尝试在我的 grails 应用程序中实现 jms。
我在 ActiveMQ 代理上基于 Spring 的环境中列出了几个 JMS 消费者。我编写了一个简单的测试命令行客户端,它创建消息并以请求响应的方式接收它们。
这是以 Spring JMS 方式发送 MapMessage 的片段。只要我在我的春天世界,这对我有用。
final String corrID = UUID.randomUUID().toString();
asyncJmsTemplate.send("test.RequestQ", new MessageCreator()
{
public Message createMessage(Session session) throws JMSException {
try {
MapMessage msg = session.createMapMessage();
msg.setStringProperty("json", mapper.writeValueAsString(List<of some objects>));
msg.setJMSCorrelationID(corrID);
msg.setJMSReplyTo(session.createQueue("test.ReplyQ"));
return msg;
} catch (JsonGenerationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JsonMappingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
});
但是当我尝试在我的 grails 测试应用程序中实现这个方法时,我收到了一些 METHOD_DEF 异常。通过 JMS 插件提供的 jmsTemplate.convertAndSende(Queue, Message) 发送简单的 TextMessage 是可行的。
谁能帮我?这是个常见的问题吗?
干杯汉斯