1 <?xml version="1.0" encoding="UTF-8"?>
2 <beans xmlns="http://www.springframework.org/schema/beans"
3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 xmlns:context="http://www.springframework.org/schema/context"
5 xmlns:websocket="http://www.springframework.org/schema/websocket"
7 xsi:schemaLocation="http://www.springframework.org/schema/beans
8 http://www.springframework.org/schema/beans/spring-beans.xsd
9 http://www.springframework.org/schema/context
10 http://www.springframework.org/schema/context/spring-context.xsd
11 http://www.springframework.org/schema/websocket
12 http://www.springframework.org/schema/websocket/spring-websocket.xsd">
15 Searches for beans in packages (instead of XML configuration we can use
16 in this way annotations like @Service, @Endpoint, etc, etc)
18 <context:component-scan base-package="de.spring.stomp"/>
21 <bean class="org.springframework.web.socket.server.standard.ServletServerContainerFactoryBean">
22 <property name="maxTextMessageBufferSize" value="8192"/>
23 <property name="maxBinaryMessageBufferSize" value="8192"/>
27 Note that even though the STOMP CONNECT frame has "login" and "passcode" headers that can be used for
28 authentication, Spring’s STOMP WebSocket support ignores them and currently expects users to have been
29 authenticated already via HTTP.
31 In some cases it may be useful to assign an identity to a WebSocket session even when the user has not
32 been formally authenticated. For example, a mobile app might assign some identity to anonymous users,
33 perhaps based on geographical location. The do that currently, an application can sub-class DefaultHandshakeHandler
34 and override the determineUser method. The custom handshake handler can then be plugged in
35 (see examples in Section 25.2.4, “Deployment Considerations”).
37 <bean id="customHandshakeHandler" class="de.spring.stomp.handlers.CustomHandshakeHandler"/>
40 <bean id="customChannelInterceptor" class="de.spring.stomp.interceptors.CustomChannelInterceptor"/>
41 <bean id="customHttpHandshakeInterceptor" class="de.spring.stomp.interceptors.CustomHttpHandshakeInterceptor"/>
44 <bean id="brokerAvailabilityListener" class="de.spring.stomp.listeners.BrokerAvailabilityListener"/>
45 <bean id="sessionConnectedListener" class="de.spring.stomp.listeners.SessionConnectedListener"/>
46 <bean id="sessionConnectListener" class="de.spring.stomp.listeners.SessionConnectListener"/>
47 <bean id="sessionDisconnectListener" class="de.spring.stomp.listeners.SessionDisconnectListener"/>
48 <bean id="sessionSubscribeListener" class="de.spring.stomp.listeners.SessionSubscribeListener"/>
49 <bean id="sessionUnsubscribeListener" class="de.spring.stomp.listeners.SessionUnsubscribeListener"/>
52 <bean id="simpleBrokerScheduler" class="org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler" />
55 <!-- Simple broker -->
56 <websocket:message-broker application-destination-prefix="/app">
57 <websocket:transport send-timeout="15000" send-buffer-size="524288" message-size="131072" />
58 <websocket:stomp-endpoint path="/portfolio" allowed-origins="*">
59 <websocket:handshake-handler ref="customHandshakeHandler" />
60 <websocket:handshake-interceptors>
61 <ref bean="customHttpHandshakeInterceptor"/>
62 </websocket:handshake-interceptors>
64 </websocket:stomp-endpoint>
68 hearbeat: Configure the value for the heartbeat settings. The first number represents how often the server will
69 write or send a heartbeat. The second is how often the client should write. 0 means no heartbeats.
70 By default this is set to "0, 0" unless the scheduler attribute is also set in which case the
71 default becomes "10000,10000" (in milliseconds).
73 Matching the value used by client.
75 <websocket:simple-broker prefix="/topic, /queue"
76 scheduler="simpleBrokerScheduler" heartbeat="0,20000" />
78 <websocket:client-inbound-channel>
79 <websocket:executor core-pool-size="100" max-pool-size="200" keep-alive-seconds="600"/>
80 <websocket:interceptors>
81 <ref bean="customChannelInterceptor"/>
82 </websocket:interceptors>
83 </websocket:client-inbound-channel>
84 <websocket:client-outbound-channel>
85 <websocket:executor core-pool-size="101" max-pool-size="201" keep-alive-seconds="601"/>
86 <websocket:interceptors>
87 <ref bean="customChannelInterceptor"/>
88 </websocket:interceptors>
89 </websocket:client-outbound-channel>
90 </websocket:message-broker>