JMS MessageCreator.createMessage() in Grails
- by Hans Wurst
Hi there,
I am trying to implement jms to my grails application.
I have several JMS consumer in a spring based enviroment listining 
on an ActiveMQ broker. I wrote a simple test commandline client which creates
messages and receives them in an request response manner.
Here is the snippet that sends a MapMessage in Spring JMS way.
This works for me as long I am in my spring world.
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;
 }
});
BUT when I tried to implement this methods to my grails test app
I receive some METHOD_DEF exceptions. Sending simple TextMessages 
via the jmsTemplate.convertAndSende(Queue, Message) provided by 
the JMS Plugin works. 
Can any one help me? Is this a common problem?
Cheers Hans