Skip to content

Commit 6814aaf

Browse files
artembilangaryrussell
authored andcommitted
INT-3511: Document WebSocket Support
JIRA: https://jira.spring.io/browse/INT-3511 Add note about Broker destinations Doc Polishing INT-3511: Fix 'useBroker' Docs and provide compatibility with SF 4.1.1
1 parent 1a0fdc6 commit 6814aaf

File tree

7 files changed

+628
-109
lines changed

7 files changed

+628
-109
lines changed

spring-integration-websocket/src/main/java/org/springframework/integration/websocket/IntegrationWebSocketContainer.java

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,13 @@
2626
import org.apache.commons.logging.LogFactory;
2727

2828
import org.springframework.beans.factory.DisposableBean;
29-
import org.springframework.context.ApplicationEvent;
30-
import org.springframework.context.ApplicationEventPublisher;
31-
import org.springframework.context.ApplicationEventPublisherAware;
3229
import org.springframework.util.Assert;
3330
import org.springframework.web.socket.CloseStatus;
3431
import org.springframework.web.socket.SubProtocolCapable;
3532
import org.springframework.web.socket.WebSocketHandler;
3633
import org.springframework.web.socket.WebSocketMessage;
3734
import org.springframework.web.socket.WebSocketSession;
3835
import org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator;
39-
import org.springframework.web.socket.messaging.SessionDisconnectEvent;
4036

4137
/**
4238
* The high-level 'connection factory pattern' contract over low-level Web-Socket
@@ -59,7 +55,7 @@
5955
* @see org.springframework.integration.websocket.inbound.WebSocketInboundChannelAdapter
6056
* @see org.springframework.integration.websocket.outbound.WebSocketOutboundMessageHandler
6157
*/
62-
public abstract class IntegrationWebSocketContainer implements ApplicationEventPublisherAware, DisposableBean {
58+
public abstract class IntegrationWebSocketContainer implements DisposableBean {
6359

6460
protected final Log logger = LogFactory.getLog(this.getClass());
6561

@@ -75,8 +71,6 @@ public abstract class IntegrationWebSocketContainer implements ApplicationEventP
7571

7672
private volatile int sendBufferSizeLimit = 512 * 1024;
7773

78-
private ApplicationEventPublisher eventPublisher;
79-
8074
public void setSendTimeLimit(int sendTimeLimit) {
8175
this.sendTimeLimit = sendTimeLimit;
8276
}
@@ -85,11 +79,6 @@ public void setSendBufferSizeLimit(int sendBufferSizeLimit) {
8579
this.sendBufferSizeLimit = sendBufferSizeLimit;
8680
}
8781

88-
@Override
89-
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
90-
this.eventPublisher = applicationEventPublisher;
91-
}
92-
9382
public void setMessageListener(WebSocketListener messageListener) {
9483
Assert.state(this.messageListener == null || this.messageListener == messageListener,
9584
"'messageListener' is already configured");
@@ -146,15 +135,6 @@ public void destroy() throws Exception {
146135
this.sessions.clear();
147136
}
148137

149-
private void publishEvent(ApplicationEvent event) {
150-
try {
151-
this.eventPublisher.publishEvent(event);
152-
}
153-
catch (Throwable ex) {
154-
logger.error("Error while publishing " + event, ex);
155-
}
156-
}
157-
158138
/**
159139
* An internal {@link WebSocketHandler} implementation to be used with native
160140
* Web-Socket containers.
@@ -192,9 +172,6 @@ public void afterConnectionClosed(WebSocketSession session, CloseStatus closeSta
192172
if (IntegrationWebSocketContainer.this.messageListener != null) {
193173
IntegrationWebSocketContainer.this.messageListener.afterSessionEnded(session, closeStatus);
194174
}
195-
else if (IntegrationWebSocketContainer.this.eventPublisher != null) {
196-
publishEvent(new SessionDisconnectEvent(this, session.getId(), closeStatus));
197-
}
198175
}
199176
}
200177

@@ -203,10 +180,8 @@ public void handleTransportError(WebSocketSession session, Throwable exception)
203180
WebSocketSession removed = IntegrationWebSocketContainer.this.sessions.remove(session.getId());
204181
if (removed != null) {
205182
IntegrationWebSocketContainer.this.sessions.remove(session.getId());
206-
if (IntegrationWebSocketContainer.this.eventPublisher != null) {
207-
publishEvent(new SessionErrorEvent(this, session.getId(), exception));
208-
}
209183
}
184+
throw new Exception(exception);
210185
}
211186

212187
@Override

spring-integration-websocket/src/main/java/org/springframework/integration/websocket/SessionErrorEvent.java

Lines changed: 0 additions & 71 deletions
This file was deleted.

spring-integration-websocket/src/main/resources/org/springframework/integration/websocket/config/spring-integration-websocket-4.1.xsd

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@
234234
</xsd:documentation>
235235
<xsd:appinfo>
236236
<tool:annotation kind="ref">
237-
<tool:expected-type type="org.springframework.web.socket.sockjs.frame.SockJsMessageCodec"/>
237+
<tool:expected-type
238+
type="org.springframework.web.socket.sockjs.frame.SockJsMessageCodec"/>
238239
</tool:annotation>
239240
</xsd:appinfo>
240241
</xsd:annotation>
@@ -357,19 +358,18 @@
357358
<xsd:attribute name="payload-type" type="xsd:string">
358359
<xsd:annotation>
359360
<xsd:documentation source="java:java.lang.Class">
360-
Fully qualified name of the java type for the target `payload`
361+
Fully qualified name of the java type for the target 'payload'
361362
to convert from the incoming WebSocketMessage.
362363
</xsd:documentation>
363364
</xsd:annotation>
364365
</xsd:attribute>
365366
<xsd:attribute name="use-broker" default="false">
366367
<xsd:annotation>
367368
<xsd:documentation>
368-
Flag to indicate if this adapter will send non-MESSAGE type WebSocketMessages
369-
and messages with broker destinations to the `AbstractBrokerMessageHandler`
369+
Flag to indicate if this adapter will send non-MESSAGE type 'WebSocketMessage's
370+
and messages with broker destinations to the 'AbstractBrokerMessageHandler'
370371
from the application context.
371-
If the `AbstractBrokerMessageHandler` bean isn't present the warn log is emitted
372-
and adapter behaviour is falling back to default like this attribute is 'false'.
372+
The 'Broker Relay' configuration is required when 'use-broker' is 'true'.
373373
This attribute is used only on server side. On client side it is ignored.
374374
Defaults to 'false'.
375375
</xsd:documentation>
@@ -441,7 +441,7 @@
441441
<xsd:annotation>
442442
<xsd:documentation>
443443
Flag to indicate if the default converters should be registered after any custom
444-
converters. This flag is used only if message-converters
444+
converters. This flag is used only if 'message-converters'
445445
are provided, otherwise all default converters will be registered.
446446
Defaults to 'false'.
447447
</xsd:documentation>

src/reference/docbook/aggregator.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -882,8 +882,7 @@ then you should simply provide an implementation of the <classname>ReleaseStrate
882882
</section>
883883

884884
<section id="reaper">
885-
<title id="reaper">Managing State in an Aggregator:
886-
MessageGroupStore</title>
885+
<title>Managing State in an Aggregator: MessageGroupStore</title>
887886

888887
<para>Aggregator (and some other patterns in Spring Integration) is a
889888
stateful pattern that requires decisions to be made based on a group of

src/reference/docbook/index.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@
144144
<xi:include href="./syslog.xml"/>
145145
<xi:include href="./ip.xml"/>
146146
<xi:include href="./twitter.xml"/>
147+
<xi:include href="./web-sockets.xml"/>
147148
<xi:include href="./ws.xml"/>
148149
<xi:include href="./xml.xml"/>
149150
<xi:include href="./xmpp.xml"/>

0 commit comments

Comments
 (0)