title: Custom object mapper for Websockets in Spring 4
body: <p>I'm using Spring 4 and was following the <a href="http://assets.spring.io/wp/WebSocketBlogPost.html" rel="nofollow">Rossen Stoyanchev's blog post</a> about using websockets in Spring. I was able to get everything working but I'm not sure what the best way to use a custom object mapper when sending <code>application/json</code>.</p>
  
  <p>I'm injecting a <code>SimpMessageSendingOperations</code> and calling <code>convertAndSend</code>. I'm not positive but I'm pretty sure I'm getting a <code>SimpMessagingTemplate</code> (it implements <code>SimpMessageSendingOperations</code>) which contains a <code>setMessageConverter</code>. This method takes a <code>MessageConverter</code> and there is a <code>MappingJackson2MessageConverter</code> class but of course it uses it's own internal <code>ObjectMapper</code> which cannot be redefined.</p>
  
  <p>So what it looks like I have to do is create a custom <code>MessageConverter</code> and define my custom <code>ObjectMapper</code> within it so I can pass it to an instance of <code>SimpMessagingTemplate</code> that I can then inject into my classes.</p>
  
  <p>This seems like it would work, but also more involved than I expected. Am I overlooking something?</p>