Spring STOMP simple server: a few improvements
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Sat, 27 Aug 2016 00:29:58 +0000 (02:29 +0200)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Sat, 27 Aug 2016 00:30:39 +0000 (02:30 +0200)
SpringJava/STOMP/spring-stomp-server-simple/src/main/java/de/spring/stomp/interceptors/CustomChannelInterceptor.java
SpringJava/STOMP/spring-stomp-server-simple/src/main/resources/log4j2.xml
SpringJava/STOMP/spring-stomp-server-simple/src/main/resources/spring-configuration/spring-configuration.xml

index 533ab23..740787b 100644 (file)
@@ -57,7 +57,7 @@ public class CustomChannelInterceptor extends ChannelInterceptorAdapter {
            
            byte[] payload = (byte[])message.getPayload();
            String stringPayload = new String(payload);
-           LOGGER.info("CustomChannelInterceptor preSend, payload: " + stringPayload);
+           LOGGER.info("CustomChannelInterceptor postSend, payload: " + stringPayload);
            
          }
 
index fe6e7db..5b83466 100644 (file)
                 
     <Appenders>
         <Appender type="Console" name="STDOUT">
-            <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class{36} %L %M - %msg%xEx%n"/>
+            <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %t %class{36} %L %M - %msg%xEx%n"/>
         </Appender>
     </Appenders>
     <Loggers>
     
+    
+       <!-- 
+               State and counters. Requires INFO level.
+        -->
+        <Logger
+               name="org.springframework.web.socket.config.WebSocketMessageBrokerStats"
+                       level="INFO" additivity="false">
+            <AppenderRef ref="STDOUT" />
+        </Logger>
+       
+       
         <!-- 
                SockJS client disconnects. Requires TRACE level always.
                It works because I know for sure I will be using WebSockets when using SockJS.
index 8c036bc..33af00a 100644 (file)
     <bean id="sessionSubscribeListener" class="de.spring.stomp.listeners.SessionSubscribeListener"/>    
     <bean id="sessionUnsubscribeListener" class="de.spring.stomp.listeners.SessionUnsubscribeListener"/>
         
-    <!-- Scheduler --> 
-    <bean id="simpleBrokerScheduler" class="org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler" />   
+    <!-- Heart beat scheduler --> 
+    <bean id="simpleBrokerScheduler" class="org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler">
+       <property name="threadNamePrefix" value="StompHeartBeatBroker-"/>
+       <property name="poolSize" value="4"/>
+               <property name="removeOnCancelPolicy" value="true"/>
+       </bean>
+    
+    <!-- Message broker scheduler
+        See: org.springframework.web.socket.config.annotationWebSocketMessageBrokerConfigurationSupport
+                 org.springframework.messaging.simp.config.AbstractMessageBrokerConfiguration
+                 org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurationSupport
+    
+     -->
+    <bean id="messageBrokerTaskScheduler" class="org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler"> 
+               <property name="threadNamePrefix" value="MessageBroker-"/>
+       <property name="poolSize" value="4"/>
+               <property name="removeOnCancelPolicy" value="true"/>
+       </bean>
      
     <!-- STOMP -->
     <!-- Simple broker -->
@@ -73,7 +89,7 @@
                        Matching the value used by client.
         -->
         <websocket:simple-broker prefix="/topic, /queue"
-               scheduler="simpleBrokerScheduler" heartbeat="0,20000" />
+               scheduler="simpleBrokerScheduler" heartbeat="20000,20000" />
         
         <websocket:client-inbound-channel>
                        <websocket:executor core-pool-size="100" max-pool-size="200" keep-alive-seconds="600"/>