1 package de.spring.stomp.interceptors;
3 import org.slf4j.Logger;
4 import org.slf4j.LoggerFactory;
5 import org.springframework.messaging.Message;
6 import org.springframework.messaging.MessageChannel;
7 import org.springframework.messaging.simp.stomp.StompCommand;
8 import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
9 import org.springframework.messaging.support.ChannelInterceptorAdapter;
11 public class CustomChannelInterceptor extends ChannelInterceptorAdapter {
12 private static final Logger LOGGER = LoggerFactory.getLogger(CustomChannelInterceptor.class);
15 public Message<?> preSend(Message<?> message, MessageChannel channel) {
16 StompHeaderAccessor accessor = StompHeaderAccessor.wrap(message);
17 StompCommand command = accessor.getCommand();
19 LOGGER.info("CustomChannelInterceptor preSend, StompCommand: " + command);
20 LOGGER.info("CustomChannelInterceptor preSend, login: " + accessor.getLogin());
21 LOGGER.info("CustomChannelInterceptor preSend, heartBeat: " + accessor.getHeartbeat());
22 LOGGER.info("CustomChannelInterceptor preSend, destination: " + accessor.getDestination());
23 LOGGER.info("CustomChannelInterceptor preSend, host: " + accessor.getHost());
29 public void postSend(Message<?> message, MessageChannel channel, boolean sent) {
30 StompHeaderAccessor accessor = StompHeaderAccessor.wrap(message);
31 StompCommand command = accessor.getCommand();
33 LOGGER.info("CustomChannelInterceptor postSend, StompCommand: " + command);
34 LOGGER.info("CustomChannelInterceptor postSend, login: " + accessor.getLogin());
35 LOGGER.info("CustomChannelInterceptor postSend, heartBeat: " + accessor.getHeartbeat());
36 LOGGER.info("CustomChannelInterceptor postSend, destination: " + accessor.getDestination());
37 LOGGER.info("CustomChannelInterceptor postSend, host: " + accessor.getHost());