Which context should websocket config go into?

72 views Asked by At

As most people, I have a root and servlet contexts. I need to enable websocket Stomp. I also need to send messages from the Service layer. So how do I configure?

If I put websocket:message-broker into the servlet config, then SimpMessagingTemplate is not autowired in the service layer. If I put it into the root, then it doesn't work at all, it isn't registered as an HTTP handler (even though logs say it does). If I put everything into the dispatcher context, then there is a

java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
   org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:252

For now I am going to work around it by calling SimpMessaging from Controller, and not Service, but I'd rather a better solution.

0

There are 0 answers