我用Spring编写了以下REST端点:
@RequestMapping(value="/rest/endPoint", method=HttpMethod.POST)
public void handleMessage(@RequestBody Message message )
{
//do some stuff with the Message
}
将通过JMS MessageListener类中的RestTemplate调用:
public class MyMessageListener implements MessageListener {
@Autowired
RestTemplate restTemplate;
@Override
public void onMessage(Message message)
{
restTemplate.exchange('/rest/endPoint', HttpMethod.POST, message );
}
}
但是,当我运行此代码时,出现错误:
JSON parse error. Cannot construct an instance of 'javax.jms.Message'(no creators like, default constructor' exist...'
如何通过REST端点获取JMS消息?