620323b1129edf88de6c4e69547a0618d95dad13
[JavaForFun] /
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"
6
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">
13
14     <!--
15         Searches for beans in packages (instead of XML configuration we can use
16         in this way annotations like @Service, @Endpoint, etc, etc)
17     -->
18     <context:component-scan base-package="de.spring.stomp"/>
19
20
21     <bean class="org.springframework.web.socket.server.standard.ServletServerContainerFactoryBean">
22         <property name="maxTextMessageBufferSize" value="8192"/>
23         <property name="maxBinaryMessageBufferSize" value="8192"/>
24     </bean>
25     
26     <!--
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.
30         
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”).
36     -->
37     <bean id="customHandshakeHandler" class="de.spring.stomp.handlers.CustomHandshakeHandler"/>
38     
39     <!-- Interceptors -->
40     <bean id="customChannelInterceptor" class="de.spring.stomp.interceptors.CustomChannelInterceptor"/>
41     <bean id="customHttpHandshakeInterceptor" class="de.spring.stomp.interceptors.CustomHttpHandshakeInterceptor"/>
42     
43     <!-- Listeners -->
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"/>
50         
51     <!-- STOMP -->
52     <!-- Simple broker -->
53     <websocket:message-broker application-destination-prefix="/app">
54         <websocket:transport send-timeout="15000" send-buffer-size="524288" message-size="131072" />
55         <websocket:stomp-endpoint path="/portfolio" allowed-origins="*">
56             <websocket:handshake-handler ref="customHandshakeHandler" />
57                 <websocket:handshake-interceptors>
58                 <ref bean="customHttpHandshakeInterceptor"/>
59                 </websocket:handshake-interceptors>
60                 <websocket:sockjs/>    
61         </websocket:stomp-endpoint>
62         <!--
63                 In memory broker.
64
65                 hearbeat: Configure the value for the heartbeat settings. The first number represents how often the server will
66                         write or send a heartbeat. The second is how often the client should write. 0 means no heartbeats.
67                         By default this is set to "0, 0" unless the scheduler attribute is also set in which case the
68                         default becomes "10000,10000" (in milliseconds).
69                         
70                         Matching the value used by client.
71         -->
72         <websocket:simple-broker prefix="/topic, /queue"
73         heartbeat="0,20000" />
74         
75         <websocket:client-inbound-channel>
76                         <websocket:executor core-pool-size="100" max-pool-size="200" keep-alive-seconds="600"/>
77                         <websocket:interceptors>
78                                 <ref bean="customChannelInterceptor"/>
79                         </websocket:interceptors>
80                 </websocket:client-inbound-channel>
81                 <websocket:client-outbound-channel>
82                         <websocket:executor core-pool-size="101" max-pool-size="201" keep-alive-seconds="601"/>
83                         <websocket:interceptors>
84                                 <ref bean="customChannelInterceptor"/>
85                         </websocket:interceptors>
86                 </websocket:client-outbound-channel>
87     </websocket:message-broker>
88     
89     <!-- Full-featured broker -->
90     <websocket:message-broker application-destination-prefix="/app">
91         <websocket:transport send-timeout="15000" send-buffer-size="524288" message-size="131072" />
92         <websocket:stomp-endpoint path="/fullportfolio" allowed-origins="*">
93                 <websocket:handshake-handler ref="customHandshakeHandler" />
94                 <websocket:handshake-interceptors>
95                 <ref bean="customHttpHandshakeInterceptor"/>
96                 </websocket:handshake-interceptors>
97             <websocket:sockjs/>
98         </websocket:stomp-endpoint>
99         <!--
100                 Full-featured broker
101         -->
102         <websocket:stomp-broker-relay prefix="/topic, /queue"
103         relay-host="" relay-port="" client-login="" client-passcode="" system-login="" system-passcode=""
104         heartbeat-send-interval="" heartbeat-receive-interval="" auto-startup="true" virtual-host=""/>
105         
106         <websocket:client-inbound-channel>
107                         <websocket:executor core-pool-size="100" max-pool-size="200" keep-alive-seconds="600"/>
108                         <websocket:interceptors>
109                                 <ref bean="customChannelInterceptor"/>
110                         </websocket:interceptors>
111                 </websocket:client-inbound-channel>
112                 <websocket:client-outbound-channel>
113                         <websocket:executor core-pool-size="101" max-pool-size="201" keep-alive-seconds="601"/>
114                         <websocket:interceptors>
115                                 <ref bean="customChannelInterceptor"/>
116                         </websocket:interceptors>
117                 </websocket:client-outbound-channel>
118     </websocket:message-broker>
119
120 </beans>