Commit Graph

353 Commits

Author SHA1 Message Date
Juergen Hoeller dbd353bbd9 MessageHeaderAccessor defensively checks id, timestamp and contentType values
Issue: SPR-12730
2015-02-18 22:28:27 +01:00
Juergen Hoeller 8716129058 Revised MappingJackson2MessageConverter towards var-arg constructor
Issue: SPR-12724
2015-02-18 16:45:01 +01:00
Sebastien Deleuze 8159aa99a1 Add parametrized constructors to MappingJackson2MessageConverter
Issue: SPR-12724
2015-02-18 14:23:19 +01:00
Juergen Hoeller 058714b03a Polishing 2015-02-10 19:30:59 +01:00
Juergen Hoeller 7585be85f3 Revised validation javadoc, plus protected validate/isBindingErrorFatal template methods
Issue: SPR-12655
2015-02-10 19:28:30 +01:00
Stephane Nicoll f0fca890bb Annotation-based event listeners
Add support for annotation-based event listeners. Enabled automatically
when using Java configuration or can be enabled explicitly via the
regular <context:annotation-driven/> XML element. Detect methods of
managed beans annotated with @EventListener, either directly or through
a meta-annotation.

Annotated methods must define the event type they listen to as a single
parameter argument. Events are automatically filtered out according to
the method signature. When additional runtime filtering is required, one
can specify the `condition` attribute of the annotation that defines a
SpEL expression that should match to actually invoke the method for a
particular event. The root context exposes the actual `event`
(`#root.event`) and method arguments (`#root.args`). Individual method
arguments are also exposed via either the `a` or `p` alias (`#a0` refers
to the first method argument). Finally, methods arguments are exposed via
their names if that information can be discovered.

Events can be either an ApplicationEvent or any arbitrary payload. Such
payload is wrapped automatically in a PayloadApplicationEvent and managed
explicitly internally. As a result, users can now publish and listen
for arbitrary objects.

If an annotated method has a return value, an non null result is actually
published as a new event, something like:

@EventListener
public FooEvent handle(BarEvent event) { ... }

Events can be handled in an aynchronous manner by adding `@Async` to the
event method declaration and enabling such infrastructure. Events can
also be ordered by adding an `@Order` annotation to the event method.

Issue: SPR-11622
2015-02-10 09:13:02 +01:00
Rossen Stoyanchev f017cc3feb DefaultSubscriptionRegistry returns safe to iterate Map
Prior to this change when adding subscriptions
DefaultSubscriptionRegistry (incorrectly) made a copy of the given map
for its "access" cache rather than for its "update" cache.

Issue: SPR-12665
2015-02-02 13:52:12 -05:00
Rossen Stoyanchev 497944f0dd Fix minor test issues
Issue: SPR-12615
2015-01-20 17:14:20 -05:00
Rossen Stoyanchev 43d93712f1 Remove isStreaming flag from AbstractHttpSockJsSession
This change removes the need for the isStreaming field from the base
class AbstractHttpSockJsSession. This field was used to account for
differences between polling vs streaming SockJS sessions without having
to expose to sub-classes private fields that are otherwise protected
from concurrent access by the base class. The change manages to delegate
to sub-classes without providing direct access to protected fields.

Issue: SPR-12427
2015-01-12 14:48:09 -05:00
Rossen Stoyanchev f59fc83f30 Remove STOMP relay integration test
The test was verifying that when a DISCONNECT frame is sent to the
broker, there will be no further messages on the clientOutboundChannel.

This is generally true, however in some cases when the broker receives
a DISCONNECT it may close its connection fast enough (before we do) in
which case we send an ERROR message downstream to ensure the WebSocket
side is cleaned up. Either way the downstream should be idempotent
with regards to cleaning up sessions.
2015-01-06 09:52:06 -05:00
Juergen Hoeller 730bd02da7 Polishing 2014-12-30 15:01:51 +01:00
Juergen Hoeller bc075c713f Polishing 2014-12-29 20:34:18 +01:00
Juergen Hoeller ed0e2f4445 PayloadArgumentResolver does not insist on configured Validator anymore
Issue: SPR-12567
2014-12-29 12:55:37 +01:00
Sebastien Deleuze fbd85925de Use Jackson improved default configuration everywhere
With this commit, Jackson builder is now used in spring-websocket
to create the ObjectMapper instance.

It is not possible to use the builder for spring-messaging
and spring-jms since these modules don't have a dependency on
spring-web, thus they now just customize the same features:
 - MapperFeature#DEFAULT_VIEW_INCLUSION is disabled
 - DeserializationFeature#FAIL_ON_UNKNOWN_PROPERTIES is disabled

Issue: SPR-12293
2014-12-03 09:49:41 +01:00
Rossen Stoyanchev ed4cd9947f Add private method to remove duplication 2014-12-02 15:26:50 -05:00
Rossen Stoyanchev fa89ae244f Enrich CONNECTED frames with Principal
Issue: SPR-12479
2014-12-02 14:30:36 -05:00
Juergen Hoeller 2496d68e9f Relaxed final declarations and protected doInvoke methods
Issue: SPR-12484
2014-12-01 15:07:24 +01:00
Sebastien Deleuze 400738e804 Polish MessageHeaderAccessor
Issue: SPR-12431
2014-11-25 11:22:10 +01:00
Juergen Hoeller 929cda6790 Allow custom @Validated annotations for handler method parameters
Issue: SPR-12406
2014-11-24 23:34:24 +01:00
Juergen Hoeller 2675ce7c9f Polishing 2014-11-22 18:05:35 +01:00
Brian Clozel 75c70fac3d Fix user destination parsing in simp messaging
This commit fixes the parsing of message destinations such as
"/user/anna/queue/foo", reverting a regression introduced by SPR-11506,
which worked well with @SendToUser use cases but caused issues for
messages sent to other users.

Issue: SPR-12444
2014-11-21 15:23:32 +01:00
Juergen Hoeller a831ed524f Polishing 2014-11-11 03:09:29 +01:00
Juergen Hoeller 05bdc2cf77 Consistent declaration and use of UTF-8 Charset constants, plus related polishing 2014-11-11 02:38:30 +01:00
Sebastien Deleuze 18033486ae Check STOMP headers against ending backslash
Issue: SPR-12418
2014-11-10 17:12:08 +01:00
Juergen Hoeller a9c47df0c1 Polishing 2014-11-01 14:05:32 +01:00
Juergen Hoeller 1146d5ba1d Polishing 2014-10-29 22:44:59 +01:00
Rossen Stoyanchev da612d079f Replace "if(" with "if (" 2014-10-27 09:04:23 -04:00
Rossen Stoyanchev 01aa64c534 Simple broker sends notice after disconnect
Before this change the simple broker simply removed subscriptions
upon receiving a DISCONNECT message assuming it was a result of
a client STOMP WebSocket session ending.

However, if the server-side application sends a DISCONNECT to
the broker in order to terminate a session, the STOMP WebSocket
session could remain unware without any further action. This
change ensures the simple broker sends a DISCONNECT_ACK message
downstream whenever it receives a DISCONNECT.

Issue: SPR-12288
2014-10-24 09:48:18 -04:00
Rossen Stoyanchev 687955a704 Add ImmutableMessageChannelInterceptor
This change adds a ChannelInterceptor that flips the immutable flag on
messages being sent. This allows components sending messages to leave
the message mutable for interceptors to further apply modifications
before the message is sent (and exposed to concurrency).

The interceptor is automatically added with the STOMP/WebSocket Java
and XML config and the StompSubProtocolHandler leaves parsed incoming
messages mutable so they can be further modified before being sent.

Issue: SPR-12321
2014-10-23 15:25:51 -04:00
Juergen Hoeller 8325b10080 Consistent formatting of license headers, package javadocs, and import declarations 2014-10-21 01:44:07 +02:00
Sam Brannen 9bc32ac199 Delete unused imports in spring-messaging module 2014-10-13 20:33:28 +02:00
Juergen Hoeller 473ed1a672 Polishing 2014-10-04 01:01:53 +02:00
Juergen Hoeller b6a3808a97 AbstractMessageChannel triggers afterSendCompletion with previously resolved non-null Message in case of preSend returning null
Issue: SPR-12295
2014-10-04 00:40:53 +02:00
Juergen Hoeller 44e29210cb ExecutorSubscribableChannel's SendTask actually returns local MessageHandler now
Issue: Issue: SPR-12272
2014-10-01 01:05:39 +02:00
Sam Brannen 7aa3cc9bb2 Clean up MessageBrokerConfigurationTests
- clean up warnings
 - simplify ApplicationContext configuration
2014-09-30 16:52:50 +02:00
Sam Brannen 5f4eb4dd55 Complete Javadoc for MessageHandlingRunnable 2014-09-30 15:30:15 +02:00
Rossen Stoyanchev 521bbfcf56 Allow configuring custom ThreadPoolTaskExecutor
Issue: SPR-12272
2014-09-29 23:02:40 -04:00
Rossen Stoyanchev 179b236608 Add MessageHandlingRunnable
Issue: SPR-12272
2014-09-29 22:41:09 -04:00
Rossen Stoyanchev 84137ab986 Polish ExecutorSubscribableChannel
Consolidate inner classes used to invoke a subscriber with
interceptors.
2014-09-29 22:23:45 -04:00
Rossen Stoyanchev ceb79c9bee Use InterceptableChannel in AbstractBrokerMessageHandler
Issue: SPR-12218
2014-09-26 13:25:52 -04:00
Rossen Stoyanchev 6f1ab8d02d Add InterceptableChannel
The new contract allows registration of interceptors with any
MessageChannel implementation hierarchy -- for example the one in the
Spring Framework or the one in Spring Integration.
2014-09-26 13:21:27 -04:00
Rossen Stoyanchev 6c57c3e4b5 Catch exception while clearing TCP conn to broker
When a DISCONNECT is sent to the broker, we proactively close the TCP
connection unless the DISCONNECT has a receipt header. Depending on
the timing, the broker may also close the connection on its side.
That appears to cause an exception in reactor on the CI server, e.g.:

https://build.spring.io/browse/SPR-PUB-JOB1-1715/test/case/135247530

This change traps the exceptions and prevents it from propagating.
2014-09-26 12:09:59 -04:00
Rossen Stoyanchev 371d93b346 Detect unsent DISCONNECT messages
This change uses a ChannelInterceptor (inserted at index 0) to detect
when a DISCONNECT message is precluded from being sent on the
clientInboundChannel. This can happen if another interceptor allows
a runtime exception out from preSend or returns false.

It is crucial for such messages to be processed, so when detected
they're processed still.

Issue: SPR-12218
2014-09-25 23:22:12 -04:00
Rossen Stoyanchev 1feeceb6de Move MessageChannel fields up to AbstractMessageBroker 2014-09-25 22:48:43 -04:00
Juergen Hoeller 3836aa051f Message broker thread pools should be set up in allowCoreThreadTimeOut mode
Issue: SPR-12249
2014-09-25 01:29:00 +02:00
Sam Brannen bf93f0c5e9 Clean up warnings in spring-messaging 2014-09-22 14:30:21 +02:00
Rossen Stoyanchev 237b50a9c8 Allow configuring custom argument types
The WebSocket messaging namespace now exposes configuration options for
custom argument resolvers and return value handlers.

Issue: SPR-12217
2014-09-19 16:47:39 -04:00
Juergen Hoeller 1e7bfd91a7 Polishing 2014-09-10 01:28:54 +02:00
Juergen Hoeller 5790fc904a Consistent support for java.util.Optional for all applicable handler method arguments
Issue: SPR-12171
2014-09-10 01:27:46 +02:00
Juergen Hoeller 86b7118da8 Polishing 2014-09-04 02:30:25 +02:00