Commit Graph

976 Commits

Author SHA1 Message Date
Sebastien Deleuze 4d9144132e Upgrade to Reactor Core 3.1
Issue: SPR-15318
2017-04-11 18:13:04 +02:00
Juergen Hoeller 5986f881d0 HandlerMethod evaluates ResponseStatus annotation for early caching
Issue: SPR-15227
2017-04-08 15:56:05 +02:00
Brian Clozel b799013567 Update to Reactor Aluminium SNAPSHOT
Currently the BOM versions are:

* reactor-core 3.0.6.BUILD-SNAPSHOT
* reactor-netty 0.6.2.BUILD-SNAPSHOT

This commit fixes as well a few deprecations in reactor-core.
2017-03-10 15:20:40 +01:00
stonio 7d062df992 Use String#isEmpty()
Closes gh-1335
2017-02-22 11:55:17 +01:00
Juergen Hoeller d2cc97af47 Polishing 2017-02-21 22:41:40 +01:00
Rossen Stoyanchev f219680d42 Add equals/hashcode for STOMP Subscription
Issue: SPR-15229
2017-02-21 15:05:06 -05:00
Stephane Maldini ba97432043 prepare for reactor-netty 0.6.1.RELEASE 2017-02-21 16:00:19 +00:00
Juergen Hoeller 370e3d683a Polishing 2017-02-20 23:00:12 +01:00
Juergen Hoeller 74bdcd8ed4 MutableMessageHeaders serializes itself as regular MessageHeaders
Issue: SPR-15262
2017-02-17 20:59:17 +01:00
Juergen Hoeller 50d93d3794 Consistently support CompletionStage next to CompletableFuture
Issue: SPR-15258
2017-02-15 23:16:11 +01:00
Rossen Stoyanchev 60517b23e2 StompSession supports custom headers for UNSUBSCRIBE
Issue: SPR-15131
2017-01-31 17:55:53 -05:00
Juergen Hoeller 9b26fcd7d2 Refined assertion messages
Issue: SPR-15196
2017-01-31 15:56:39 +01:00
Juergen Hoeller 1b2dc3638f Revisit Assert to avoid single-arg assert methods (with refined messages)
Issue: SPR-15196
2017-01-30 22:15:55 +01:00
Arjen Poutsma 69c16f3821 Add headers in InterceptingClientHttpRequest
This commit *adds* the "intercepted" headers to the ClientHttpRequest,
as opposed to replacing them, which is what happened before this commit.

Issue: SPR-15166
2017-01-30 14:18:50 +01:00
Juergen Hoeller 8038fb9c8b HandlerMethod pre-resolves parameter types at construction time
Issue: SPR-15186
2017-01-25 11:09:43 +01:00
Juergen Hoeller 12973ac702 Polishing 2017-01-24 00:12:53 +01:00
Juergen Hoeller f095aa20eb Polishing 2017-01-23 21:28:40 +01:00
Juergen Hoeller e9db4d6f96 Proper resolution of Optional.empty() for header arguments
Issue: SPR-15151
2017-01-17 10:46:37 +01:00
Juergen Hoeller 62e530ec94 Resolve minor 4.3.x deprecations in master
Issue: SPR-15139
2017-01-16 21:43:12 +01:00
Juergen Hoeller 047786acef Revised InvocableHandlerMethod exception messages (controller vs endpoint vs handler)
Introduces dedicated MethodArgumentResolutionException for spring-messaging invocations.

Issue: SPR-15139
2017-01-16 21:14:46 +01:00
Juergen Hoeller 7c05b427a7 MimeTypeUtils constants cleanup: removed web media types
Issue: SPR-15137
2017-01-12 23:30:57 +01:00
Juergen Hoeller 743ce2cda6 Polishing 2017-01-12 23:30:38 +01:00
Sam Brannen 9ed66bf2eb Clean up warnings across code base 2017-01-07 01:54:38 +01:00
Gary Russell 80bc8fc596 Implement MessagingException.toString()
Issue: SPR-15091
Closes gh-1284
2017-01-05 10:25:04 +01:00
Rossen Stoyanchev e62b104e03 Resource cleanup on shutdown in ReactorNettyTcpClient 2016-12-28 21:37:12 -05:00
Rossen Stoyanchev 698c885e06 Reconnect failures delegated to TcpConnectionHandler
When connecting with a ReconnectStrategy we can only report the outcome
of the first connect to the ListenableFuture<Void> return value.

Failures for all subsequent attempts to reconnect however must be
channeled to TcpConnectHandler#afterConnectFailure which is used in
the STOMP broker relay for example to publish
BroadcastAvailability(true/false) events.
2016-12-28 21:37:07 -05:00
Rossen Stoyanchev ea274ebc0a Fix decoding issue in Reactor TcpClient
When decoding STOMP messages unread portions of a given input ByteBuf
must be kept until more input is received and the next complete STOMP
frame can be parsed.

In Reactor Net 2.x this was handled for us through the "remainder"
field in NettyChannelHandlerBridge. The Reactor Netty 0.6 upgrade
however applied only a simple map operator on the input ByteBuf
after which the buffer is relased.

This commit replaces the use of a simple map operator for decoding
and installs a ByteToMessageDecoder in the Netty channel pipeline
which has a built-in ability to preserve and merge unread input into
subsequent input buffers.
2016-12-28 21:36:37 -05:00
Rossen Stoyanchev fdf88c9795 Workaround for onReadIdle issue in Reactor TcpClient
https://github.com/reactor/reactor-netty/issues/22
2016-12-28 21:36:37 -05:00
Rossen Stoyanchev 2a3e01399a Polish ReactorNettyTcpClient 2016-12-28 21:36:37 -05:00
Juergen Hoeller 5c48daa8eb Remove unused Log object from MessageHeaderAccessor
Issue: SPR-15045
2016-12-22 23:34:19 +01:00
Juergen Hoeller ae62341fa3 Avoid deprecated Scheduler.shutdown() in favor of Scheduler.dispose() 2016-12-22 22:35:54 +01:00
Juergen Hoeller 4c005e6336 ResolvableType-based matching respects generic factory method return type
Includes consistent use of ResolvableType.resolve() wherever applicable.

Issue: SPR-15011
2016-12-17 23:10:48 +01:00
Stephane Maldini 2802926c1d update STOMP support to reactor-netty 0.6 2016-12-13 17:31:09 +00:00
Stephane Maldini 70bab23609 update STOMP support to reactor-netty 0.6 2016-12-13 17:29:43 +00:00
Rossen Stoyanchev b3fa1b40a0 Synchronized updates of STOMP header key cache
Issue: SPR-14901
2016-12-08 11:13:57 -05:00
Christoph Dreis 9b76dc2ab4 SPR-14901 Allow customization of STOMP message header encoding
Fixes SPR-14901
2016-12-08 11:13:56 -05:00
Sergei Ustimenko e4ed1f6ffd ChannelFutureMono renamed to FutureMono
In the latest reactor-netty there is renaming
of ChannelFutureMono class to FutureMono. Thus
build fails on the latest master.
2016-12-03 18:56:42 +01:00
Juergen Hoeller f6fc0a86b3 Polishing
(cherry picked from commit 0028b29)
2016-12-01 20:11:47 +01:00
Rossen Stoyanchev b874692452 Simplify ReactorNettyTcpClient input
Create a ReactorNettyCodec to hold the decoding and encoding function
and consumer along with a package-private sub-class that delegates to
StompDecoder and StompEncoder.

Issue: SPR-14531
2016-11-30 21:17:04 -05:00
Rossen Stoyanchev 85c93f5d67 Polish Reactor Netty TCP client support 2016-11-30 21:17:04 -05:00
Stephane Maldini 870f61fd8e update STOMP support to reactor-netty 2016-11-30 21:17:04 -05:00
Juergen Hoeller 5458a427a1 Polishing 2016-11-30 22:31:47 +01:00
Rossen Stoyanchev a203b74d20 PayloadArgumentResolver has useDefaultResolution flag
Issue: SPR-14937
2016-11-28 17:00:22 -05:00
Sebastien Deleuze a143b57d4b Polish Kotlin nullable support
This commit polishes Kotlin nullable support by reusing
MethodParameter#isOptional() instead of adding a new
MethodParameter#isNullable() method, adds
Kotlin tests and introduces Spring Web Reactive
support.

Issue: SPR-14165
2016-11-24 18:28:50 +01:00
Raman Gupta fada91e538 Treat Kotlin nullable as non-required
Where `isOptional` is used, also check for `isNullable` i.e.
values are not considered required if they are Kotlin nullables:
- spring-messaging: named value method arguments
- spring-web: named value method arguments
- spring-webmvc: request parts

This means that Kotlin client code no longer has to explicity specify
"required=false" for Kotlin nullables -- this information is inferred
automatically by the framework.

Issue: SPR-14165
2016-11-24 17:18:55 +01:00
Juergen Hoeller 80931b211c Shared DefaultConversionService instance for simple fallback purposes
Issue: SPR-14948
2016-11-24 15:29:17 +01:00
Juergen Hoeller 9bf4d7cf4e Polishing 2016-11-22 14:57:00 +01:00
Christoph Dreis a929e9ccaa Implement allocation-friendly method to get user count in SimpUserRegistry
SPR-14930
2016-11-21 21:02:10 +01:00
Juergen Hoeller ac774cdcef Avoid deprecated Mockito methods
Issue: SPR-14880
2016-11-04 12:24:46 +01:00
Juergen Hoeller 84d3808b3b Upgrade to Mockito 2.2
Issue: SPR-14880
2016-11-03 22:53:35 +01:00
Juergen Hoeller dc080cb1be Revised NoSuchBeanDefinitionException message and ResolvableType handling
Includes consistent quoting of qualified type names in related classes.

Issue: SPR-14831
2016-10-28 23:39:05 +02:00
Juergen Hoeller dbaafdd04e MessageChannel declares send(Message) as default method
Issue: SPR-14854
2016-10-28 15:11:03 +02:00
Juergen Hoeller 3726c6f18d Polishing 2016-10-21 12:26:27 +02:00
Juergen Hoeller eafaaa5cb8 Polishing 2016-10-12 17:11:04 +02:00
Juergen Hoeller ffc781b163 Explicit calls on Buffer base type (for compatibility with covariant return type on JDK 9's ByteBuffer)
Issue: SPR-14645
2016-10-05 00:10:06 +02:00
Juergen Hoeller fb7ae010c8 Avoid unnecessary generics on emptyMap/Set/List 2016-09-26 18:04:49 +02:00
Juergen Hoeller a6b0b6e279 Efficient STOMP content-length header check
Issue: SPR-14747
2016-09-26 17:25:21 +02:00
Juergen Hoeller c64f39943f Polishing 2016-09-26 17:20:30 +02:00
Juergen Hoeller e188b4428e Polishing 2016-09-25 21:00:07 +02:00
Christoph Dreis 774e4c3dc1 Improve performance of StompEncoder
Fixes SPR-14747
2016-09-25 19:09:01 +02:00
Rossen Stoyanchev 99c7917124 Reset connection before delegating to handler
Resetting the connection first before invoking a failure callback on
the application handler ensures that any checks to isConnected will
return false.

Issue: SPR-14721
2016-09-19 09:04:23 -04:00
Juergen Hoeller 6dc1898dbb Timeout exceptions as RuntimeExceptions
Issue: SPR-14669
2016-09-15 08:54:17 +02:00
Rossen Stoyanchev 3bc1121b9d Check both connection and connected flag
Issue: SPR-14703
2016-09-14 17:19:49 -04:00
Juergen Hoeller f592599349 Polishing
(cherry picked from commit 54db496)
2016-09-13 23:48:41 +02:00
Juergen Hoeller 03609c1518 Consistent comma splitting without regex overhead
Issue: SPR-14635
2016-08-30 23:56:58 +02:00
Rossen Stoyanchev 8b4f60b8e5 Support receipt on DISCONNECT with simple broker
Issue: SPR-14568
2016-08-29 18:31:19 -04:00
Juergen Hoeller 899ebd8ee2 Avoid collection lookups in StompCommand
Issue: SPR-14636
2016-08-29 11:54:21 +02:00
Juergen Hoeller dfdfd72a3e Polishing
(cherry picked from commit 430180a)
2016-08-26 18:59:40 +02:00
Juergen Hoeller 2e4a7480fc Consistent use of JDK 7 StandardCharsets over Charset.forName
Issue: SPR-14492
2016-08-26 14:16:19 +02:00
Juergen Hoeller 14046575b0 Polishing 2016-08-26 13:27:33 +02:00
Juergen Hoeller f3f691cc37 Revised assertions in StompHeaderAccessor
Issue: SPR-14625
2016-08-24 21:04:01 +02:00
Juergen Hoeller c4fff6db1b Reintroduced MessageMethodArgumentResolver default constructor
Issue: SPR-14616
2016-08-23 13:20:02 +02:00
Juergen Hoeller eeeab27f1f Polishing
(cherry picked from commit 35e247a)
2016-08-10 16:42:21 +02:00
Juergen Hoeller 59a24b406a Polishing 2016-08-10 14:20:42 +02:00
Juergen Hoeller 5db449556b Polishing 2016-07-27 16:21:55 +02:00
Juergen Hoeller 6d5af60a7c Expose DefaultSubscriptionRegistry's cache limit through SimpleBrokerMessageHandler and MessageBrokerRegistry
Issue: SPR-14516
2016-07-27 12:11:58 +02:00
Juergen Hoeller e03dea1d64 Polishing 2016-07-26 17:15:19 +02:00
Marius Grama 3635c9dbfe Update xmlunit library to version 2.1.0
xmlunit 2.1.0 is the latest release for xmlunit.
Most of the xmlunit functionality used within spring-framework
was done through the xmlunit 1.x helper class
`org.custommonkey.xmlunit.XMLAssert`.

As of xmlunit 2.0.0 most of the XML comparison methods are done
through hamcrest matchers exposed by the xmlunit-matchers
library. In some cases during the migration, the matchers
had to be customized with custom `NodeMatcher` or
`DifferenceEvaluator` instances in order to keep the assertions
correct (they were performed with xmlunit 1.x previously).

Issue: SPR-14043
2016-07-21 15:04:21 +02:00
Juergen Hoeller 99be15f58b Revise encoding steps towards use of JDK Charset and StandardCharsets
Issue: SPR-14492
2016-07-19 23:43:06 +02:00
Juergen Hoeller a4743c07d4 Polishing 2016-07-19 20:09:00 +02:00
Juergen Hoeller aaac199e8b Consistently use constructor-based instantiation instead of Class.newInstance / BeanUtils.instantiate
Issue: SPR-14486
2016-07-19 19:21:06 +02:00
Juergen Hoeller b1663585dc MessageHeaderAccessor properly removes header even in case of null value
Issue: SPR-14468
2016-07-15 00:15:46 +02:00
Juergen Hoeller a1f5fb53db Java 8 getParameterCount() instead of getParameterTypes().length
Issue: SPR-13188
2016-07-07 01:04:24 +02:00
Stephane Nicoll e4b0486c5a Add @FunctionalInterface on candidate interfaces
Issue: SPR-14432
2016-07-06 14:32:13 +02:00
Sam Brannen 1391248ea6 Introduce log4j 2 for Spring's test suite
This commit adds a test runtime dependency on log4j 2 for every project
and migrates all log4j.properties files to log4j2-test.xml files.

Issue: SPR-14431
2016-07-05 19:19:09 +02:00
Stephane Nicoll 00d2606b00 Explicit type can be replaced by <>
Issue: SPR-13188
2016-07-05 17:00:34 +02:00
Juergen Hoeller b5db5d3aac Broadly remove deprecated core classes and methods
Issue: SPR-14430
2016-07-05 15:52:49 +02:00
Juergen Hoeller 51252ebbca Avoid defensive checks against Java 8 API (java.util.Optional etc)
This commit also fixes broken javadoc links and code references.

Issue: SPR-13188
2016-07-05 02:09:00 +02:00
Juergen Hoeller f6334fc62b Aligned default Map capacity 2016-07-02 15:17:34 +02:00
Juergen Hoeller b204437cef Polishing 2016-07-02 14:48:15 +02:00
Juergen Hoeller e5122d084a Avoid wrapping in plain RuntimeException in favor of IllegalStateException 2016-07-02 13:03:33 +02:00
Juergen Hoeller e5de7d5455 @MessageExceptionHandler matches cause as well (analogous to @ExceptionHandler)
Issue: SPR-14424
2016-07-02 12:56:37 +02:00
Juergen Hoeller cfc560c4c4 Leniently accept custom DeferredResult etc subclasses for null values
Issue: SPR-14423
2016-07-02 12:55:30 +02:00
Rossen Stoyanchev ebdc770ed3 Use appropriate message id header for STOMP 1.1 vs 1.2
Issue: SPR-14391
2016-06-27 16:12:59 -04:00
Juergen Hoeller f5282bc1e3 PayloadArgumentResolver's MessageConversionException includes original payload type
Issue: SPR-14394
2016-06-23 17:32:30 +02:00
Juergen Hoeller a9fda3e7e2 Defensive catching of any Throwable subclasses instead of just Error
Issue: SPR-14329
2016-06-04 00:17:20 +02:00
Juergen Hoeller e4976a2c6d ExecutorSubscribableChannel consistently rethrows Error as MessageDeliveryException
Issue: SPR-14323
2016-06-01 11:38:56 +02:00
Rossen Stoyanchev 1e003a1c90 Remove unnecessary assertion
Issue: SPR-14279
2016-05-18 10:57:54 -04:00
Rossen Stoyanchev 4a81aaba6c Fix STOMP connect failure related memory leak
Normally heartbeats keep connections from hanging. However in some
cases a connection may hang before a CONNECTED frame is received
and heartbeats are put in place. This commit adds a change to enforce
a 60 limit on receiving the CONNECTED frame.

Issue: SPR-14266
2016-05-12 11:24:50 -04:00
Juergen Hoeller c15f27cfa8 Avoid package import cycle through explicit javadoc reference 2016-05-06 13:41:02 +02:00
Sam Brannen 7b13311f03 Delete unused imports 2016-05-03 20:12:37 +02:00
Rossen Stoyanchev 46e41a9d94 Consolidate SendTo vs SendToUser detection
SendTo and SendToUser are treated as mutually exclusive. The addition of
type-level support in 4.3. RC1 however did not consider the possibility
to mix and match of the two betwee type and method level.

This commit consolidates the detection of SendTo and SendToUser
annotations and considers them all together.

Issue: SPR-14238
2016-05-03 12:34:19 -04:00
Juergen Hoeller f83cbff543 Consistent SmartLifecycle implementations
Issue: SPR-14233
2016-05-02 13:01:44 +02:00
Rossen Stoyanchev bd40a93604 Ensure Environment.shutdown() in Reactor2TcpClient
Issue: SPR-14229
2016-04-28 17:47:59 -04:00
Rossen Stoyanchev 220711d45b Reactor2TcpClient cleans up TcpClient instances
Issue: SPR-14231
2016-04-28 15:27:53 -04:00
Rossen Stoyanchev 9798912557 Add missing @since tag 2016-04-26 16:48:45 -04:00
Rossen Stoyanchev 06b2d2b89e STOMP client session supports sending ack/nack
Issue: SPR-14208
2016-04-26 16:44:58 -04:00
Johnny Lim 44e652f99e Remove duplicate words
Closes gh-1039
2016-04-19 08:24:21 +02:00
Juergen Hoeller f1cb793ccb Rename MimeType's getCharSet() to getCharset()
Issue: SPR-14172
2016-04-14 16:38:59 +02:00
Juergen Hoeller 5f4e838f41 Jackson-based message converters do not log warning for serializer not found
Issue: SPR-14163
2016-04-14 14:13:13 +02:00
Juergen Hoeller 517ebd1d3e Consistent formatting 2016-03-24 19:22:50 +01:00
Juergen Hoeller 5025c615b1 Consistent use of AnnotatedElementUtils.findMergedAnnotation/hasAnnotation
Issue: SPR-13440
2016-03-23 18:39:20 +01:00
Rossen Stoyanchev 183594207f Support user destinations without leading slash
Before this commit the DefaultUserDestinationResolver did not support
well broker destinations that use dot as separator with a built in
assumptions that the destinations it resolves must start with slash.

This change adds PathMatcher property that is used to determine if
an alternative path separator is in use and if so the leading slash is
left out.

Issue: SPR-14044
2016-03-15 17:50:13 -04:00
Rossen Stoyanchev 68f6cf9d3a Support same user connected to multiple servers
The MultiServerUserRegistry now supports scenarios where the same user
is connected to multiple servers. For such cases the SimpUser returned
from the registry exposes all sessions across all servers.

Issue: SPR-13800
2016-03-10 14:37:22 -05:00
Rossen Stoyanchev 6aa216afb6 Polish SimpUserRegistry related classes
Issue: SPR-13800
2016-03-10 14:37:22 -05:00
Rossen Stoyanchev 18a59dad52 Minor Javadoc update 2016-02-18 18:11:59 -05:00
Rossen Stoyanchev 416966d943 Support Message argument with payload conversion
The MessageMethodArgumentResolver now also supports applying a
MessageConverter to the payload.

This is effectively a shortcut for declaring a method with an @Payload
argument + MessageHeaders and then creating a new message from the two.

Issue: SPR-13288
2016-02-18 18:09:16 -05:00
Rossen Stoyanchev ec3571fd4d Polish 2016-02-18 18:09:16 -05:00
Juergen Hoeller e0d7c6be00 Name attributes in method argument annotations allow for placeholders and expressions
Issue: SPR-13952
2016-02-17 22:59:12 +01:00
Juergen Hoeller 8558cbc9bf Polishing 2016-02-10 19:40:47 +01:00
Juergen Hoeller 901c2d5f74 Consistent API between spring-web and spring-messaging HandlerMethod infrastructure
Issue: SPR-13929
2016-02-10 16:23:11 +01:00
Rossen Stoyanchev e81c7dfc4c Polish SendToMethodReturnValueHandlerTests 2016-01-29 16:16:21 -05:00
Rossen Stoyanchev 03e3ef53ab @SendToUser supported on the class level
Issue: SPR-12047
2016-01-29 16:10:02 -05:00
Juergen Hoeller b4f33adf48 Consistent java.util.Optional resolution, lenient handling of optional multipart files, correct Servlet 3.0 Part list/array selection
Issue: SPR-13418
Issue: SPR-13849
Issue: SPR-13850
Issue: SPR-13893
2016-01-26 18:06:15 +01:00
Stephane Nicoll a112557dc4 Support SendTo at class-level
Issue: SPR-13578
2016-01-16 16:34:02 +01:00
Stephane Nicoll 2fc2c29e9a Update copyright header 2016-01-15 10:51:11 +01:00
Rossen Stoyanchev 3dae3fd8a9 Refine ListenableFutureCallback policy for exceptions
This change updates all cases where callbacks are invoked to catch and
suppress errors (since there is not match to do with and error from
a callback be it success or failure).

Also updated is the contract itself to clarify this and emphasize the
callbacks are really notifications for the outcome of the
ListenableFuture not the callbacks themselves.

Issue: SPR-13785
2016-01-14 17:49:01 -05:00
Sam Brannen 5b3edcd9f9 Spring Cleaning in December
- Delete unused imports
- Delete unused code
- Clean up warnings
2015-12-17 20:27:33 +01:00
Juergen Hoeller 8ce5e88c66 Require Jackson 2.6+, FreeMarker 2.3.21+, XStream 1.4.5+
Issue: SPR-13062
2015-12-17 17:14:50 +01:00
Juergen Hoeller 753347ea98 Consistent static final logger declarations 2015-12-16 20:44:00 +01:00
Juergen Hoeller bdb606b8b1 Polishing 2015-12-13 23:27:05 +01:00
Juergen Hoeller beef5ff4c3 Polishing 2015-12-10 01:12:58 +01:00
Juergen Hoeller ca9a078d82 Polishing 2015-12-10 00:31:37 +01:00
Juergen Hoeller f119962378 SimpAnnotationMethodMessageHandler ignores empty marker annotations
Issue: SPR-13704
2015-12-10 00:30:50 +01:00
Juergen Hoeller 11806b9215 Class identity comparisons wherever possible (and further polishing)
Issue: SPR-12926
2015-12-09 12:28:09 +01:00
Juergen Hoeller 8c4436926f Polishing 2015-11-26 02:09:37 +01:00
Juergen Hoeller a0747c2148 Consistent bean type checking for endpoint handlers
Issue: SPR-13725
2015-11-25 21:26:03 +01:00
Juergen Hoeller e8417ea6e1 SimpAnnotationMethodMessageHandler skips template variable check in case of no pattern
Issue: SPR-13704
2015-11-24 17:37:12 +01:00
Juergen Hoeller 760bc719f2 Polishing 2015-11-09 15:03:14 +01:00
Juergen Hoeller bc7bcab578 Consistent method selection for listeners and endpoint mappings
Issue: SPR-13654
2015-11-09 14:57:45 +01:00
Juergen Hoeller 23c8f712c4 Polishing 2015-11-02 21:30:03 +01:00
Juergen Hoeller cca037a74d Polishing 2015-11-02 14:42:46 +01:00
Sebastien Deleuze 994a11da3e Document default charset in Jackson message converters Javadoc
Issue: SPR-13600
2015-10-26 11:39:00 +01:00
Rossen Stoyanchev 922e6de788 Avoid filtering if selector header is not in use 2015-10-13 12:14:17 -04:00
Rossen Stoyanchev 7ff915a01a Enforce cacheLimit in DefaultSubscriptionRegistry
When the cacheLimit is reached and there is an eviction from the
updateCache, the accessCache is now also updated.

This change also ensures that adding a destination to the cache is
protected with synchronization on the updateCache.

Issue: SPR-13555
2015-10-13 12:14:16 -04:00
Juergen Hoeller 181533c464 MessageHeaders serialization preserves non-serializable entries in original instance
Issue: SPR-13541
2015-10-06 13:24:05 +02:00
Rossen Stoyanchev 8c316e1863 Avoid issue with switching from Reactor 2.0.5 to 2.0.6
We can't compile directly against NettyClientSocketOptions method which
changed signatures in 2.0.6. This change ensures the method is invoked
reflectively instead.
2015-09-30 18:43:07 -04:00
Rossen Stoyanchev c75206f975 Prepare for Reactor 2.0.6 2015-09-29 10:42:44 -04:00
Rossen Stoyanchev daa49c9bcd StompDecoder handles partial headers correctly
Issue: SPR-13416
2015-09-23 16:51:55 -04:00
Juergen Hoeller c4f5a0fb10 MessagingException provides null description (instead of empty String) to NestedRuntimeException
Issue: SPR-13447
2015-09-09 11:42:59 +02:00
Juergen Hoeller 667fc7e4a9 Polishing 2015-09-04 14:38:47 +02:00
Rossen Stoyanchev 4ecb3d4f3f Update WebSocket docs on proxying @Controller
Issue: SPR-13384
2015-08-25 22:14:36 -04:00
Juergen Hoeller 8cd283729b MessageHeaders returns completely immutable entry set (no entry.setValue call allowed)
Issue: SPR-13385
2015-08-25 17:54:54 +02:00
Juergen Hoeller 3d2e2cb3ae Upgrade to Reactor 2.0.5 2015-08-17 13:00:29 +02:00
Juergen Hoeller a369fc8afd Introduce SmartMessageConverter interface with conversionHint arguments
Issue: SPR-13343
2015-08-12 17:45:46 +02:00
Juergen Hoeller 9ef38807e6 Polishing 2015-07-30 19:34:33 +02:00
Juergen Hoeller b1d6ae77e1 Polishing 2015-07-30 00:08:36 +02:00
Sam Brannen 725292081e Introduce 'value' alias for 'attribute' in @AliasFor
SPR-11512 introduced support for annotation attribute aliases via
@AliasFor, requiring the explicit declaration of the 'attribute'
attribute. However, for aliases within an annotation, this explicit
declaration is unnecessary.

This commit improves the readability of alias pairs declared within an
annotation by introducing a 'value' attribute in @AliasFor that is an
alias for the existing 'attribute' attribute. This allows annotations
such as @ContextConfiguration from the spring-test module to declare
aliases as follows.

public @interface ContextConfiguration {

     @AliasFor("locations")
     String[] value() default {};

     @AliasFor("value")
     String[] locations() default {};

    // ...
}

Issue: SPR-13289
2015-07-29 15:27:06 +02:00
Juergen Hoeller 02d05ed133 Consistent lookup of parameter-level JsonView annotation
Issue: SPR-13265
2015-07-29 01:05:25 +02:00
Juergen Hoeller d83735694e Polishing 2015-07-28 12:15:48 +02:00
Rossen Stoyanchev 4b4efa9f6e Placeholder support for STOMP @MessageMapping methods
Issue: SPR-13271
2015-07-27 16:54:21 -04:00
Rossen Stoyanchev a65e0369f4 Polish SimpAnnotationMethodMessageHandlerTests 2015-07-27 16:54:21 -04:00
Juergen Hoeller 0f54f686b2 PayloadArgumentResolver supports JsonView as well (through AbstractMessageConverter revision)
AbstractMessageConverter provides overloaded methods with a conversion hint, MappingJackson2MessageConverter takes that hint into account, and SimpMessagingTemplate transformes such a hint in the given headers map into an explicit argument invocation argument.

Issue: SPR-13265
2015-07-24 17:50:31 +02:00
Juergen Hoeller f06581f5b8 Polishing 2015-07-22 14:20:12 +02:00
Juergen Hoeller edd6e76b9f Polishing 2015-07-21 22:58:34 +02:00
Juergen Hoeller 203f1225c3 Polishing 2015-07-17 15:25:43 +02:00
Juergen Hoeller 2a36abcaea Polishing 2015-07-07 16:44:19 +02:00
Sebastien Deleuze 97936140cc Support HandlerMethod parameter in @MessageExceptionHandler
Issue: SPR-13196
2015-07-07 15:43:39 +02:00
Juergen Hoeller f79a5c12d5 DefaultSubscriptionRegistry defensively checks for removal between keySet and get calls
Issue: SPR-13205
2015-07-07 11:11:56 +02:00
Juergen Hoeller fefc4b478f Polishing 2015-07-07 02:22:44 +02:00
Juergen Hoeller 145d88d152 Polishing 2015-07-07 00:26:31 +02:00
Juergen Hoeller f0175bc42d DefaultSubscriptionRegistry uses deep LinkedMultiValueMap copies between accessCache and updateCache
Issue: SPR-13185
2015-07-07 00:25:47 +02:00
Rossen Stoyanchev 16cbfcfd2f Add test to demonstrate 4.2 not affected by SPR-13185
Issue: SPR-13185
2015-07-06 17:32:55 -04:00
Rossen Stoyanchev 0b43e4e4f2 Add concurrent test and fix potential NPE
After SPR-12884 (4.2 RC1) introduced support for a selector header
expression on SUBSCRIBE frames, messages from the destination cache
are further filtered based on the selector expression. While adding a
test to find subscriptions at the same time as unsubscribing, a
potential NPE was exposed. This commit fixes the NPE.

Issue: SPR-13204
2015-07-06 17:07:20 -04:00
Rossen Stoyanchev 5dcbc5db29 Polish DefaultSubscriptionRegistryTests 2015-07-06 17:07:20 -04:00
Juergen Hoeller dc1f921f5c Split between basic MethodParameter and SynthesizingMethodParameter
This split avoids a package tangle (between core and core.annotation) and also allows for selective use of raw annotation exposure versus synthesized annotations, with the latter primarily applicable to web and message handler processing at this point.

Issue: SPR-13153
2015-06-30 00:02:02 +02:00
Sam Brannen 078d252d1e Delete trailing whitespace in Java source code 2015-06-19 17:09:52 +02:00
Rossen Stoyanchev 1153969ea2 Polish 2015-06-15 14:56:56 -04:00
Josh King 11824893a9 Header values are optional in Stomp 1.1 and 1.2 2015-06-15 14:56:56 -04:00
Sam Brannen ab24592662 Introduce alias for 'value' attribute in @SendToUser
Issue: SPR-11393
2015-06-01 14:14:23 +02:00
Sam Brannen 53d095aa28 Polish Javadoc for @SubscribeMapping 2015-06-01 13:56:44 +02:00
Sam Brannen a6f53ef2a7 Polish Javadoc for @MessageMapping 2015-06-01 13:37:08 +02:00
Sam Brannen 7b10dc6e93 Fix typo in Javadoc 2015-05-29 23:24:09 +02:00
Sam Brannen 60a5ec87d0 Introduce alias for 'value' attribute in @Header
This commit introduces 'name' as an alias for 'value' in @Header.

Issue: SPR-11393
2015-05-29 23:23:52 +02:00
Sam Brannen 35c3e7c0f3 Polishing 2015-05-29 23:10:25 +02:00
Sam Brannen 250787a35a Introduce alias for 'value' attribute in @Payload
This commit introduces 'expression' as an alias for 'value' in @Payload.

Issue: SPR-11393
2015-05-29 22:58:55 +02:00
Sam Brannen 7018747cec Remove trailing whitespace in Java source code 2015-05-29 02:03:44 +02:00
Juergen Hoeller 05d475a275 Polishing 2015-05-22 23:50:47 +02:00
Rossen Stoyanchev bbd3f902d0 Fix failing tests 2015-05-22 14:14:20 -04:00
Rossen Stoyanchev c48e8708a7 Fix NPE in DefaultSimpUserRegistry 2015-05-22 13:44:09 -04:00
Rossen Stoyanchev 92bd7bba50 Restore userSessionRegistry field in StompSubProtocolHandler
This change ensures that the deprecated UserSessionRegistry is still
used if configured.
2015-05-22 13:44:09 -04:00
Rossen Stoyanchev 0db216daab Polish 2015-05-22 09:06:18 -04:00
Sebastien Deleuze 5255e7ae21 Support CompletableFuture in @MessageMapping handler methods
Issue: SPR-12207
2015-05-22 11:30:56 +02:00
Sebastien Deleuze d3db99c201 Support ListenableFuture in @MessageMapping handler methods
This commit introduces support for asynchronous return values thanks
to the new AsyncHandlerMethodReturnValueHandler interface. Out of
the box support for ListenableFuture is also provided.

Issue: SPR-12168
2015-05-22 11:29:13 +02:00
Juergen Hoeller b4095c3e1d Class identity comparisons wherever possible
Issue: SPR-12926
2015-05-20 14:34:16 +02:00
Sebastien Deleuze 876c9694c4 Allow use of @JsonView on @MessageMapping methods
Issue: SPR-12741
2015-05-19 15:35:40 +02:00
Stephane Nicoll cf391f5ce1 polish
Remove unused imports
2015-05-19 08:49:01 +02:00
Rossen Stoyanchev 696a010e81 Add SubProtocolErrorHandler
Issue: SPR-12732
2015-05-15 18:18:05 -04:00
Juergen Hoeller 49c600b234 Resolved cyclic dependency between handler.invocation and handler.annotation
Issue: SPR-12696
2015-05-12 22:04:59 +02:00
Rossen Stoyanchev 281588d7bb Add SimpUserRegistry with multi-server support
This change introduces SimpUserRegistry exposing an API to access
information about connected users, their sessions, and subscriptions
with STOMP/WebSocket messaging. Provides are methods to access users
as well as a method to find subscriptions given a Matcher strategy.

The DefaultSimpUserRegistry implementation is also a
SmartApplicationListener which listesn for ApplicationContext events
when users connect, disconnect, subscribe, and unsubscribe to
destinations.

The MultiServerUserRegistry implementation is a composite that
aggregates user information from the local SimpUserRegistry as well
as snapshots of user  on remote application servers.

UserRegistryMessageHandler is used with MultiServerUserRegistry. It
broadcats user registry information through the broker and listens
for similar broadcasts from other servers. This must be enabled
explicitly when configuring the STOMP broker relay.

The existing UserSessionRegistry which was primiarly used internally
to resolve a user name to session id's has been deprecated and is no
longer used. If an application configures a custom UserSessionRegistr
still, it will be adapted accordingly to SimpUserRegistry but the
effect is rather limited (comparable to pre-existing functionality)
and will not work in multi-server scenarios.

Issue: SPR-12029
2015-05-12 15:29:12 -04:00
Rossen Stoyanchev eb9eadbb50 Polish 2015-05-07 12:01:54 -04:00
Arjen Poutsma a36319e91c Introduce Marshalling MessageConverter
This commit introduces a messaging.converter.MessageConverter that
marshals to/from XML using the abstractions provided in the OXM module.

Issue: SPR-12726
2015-05-07 12:01:54 -04:00
Juergen Hoeller 1cc042d4c7 Polishing 2015-05-07 16:03:15 +02:00
Sam Brannen 7a690df925 Remove trailing whitespace from Java source code 2015-05-06 20:08:42 +02:00
Rossen Stoyanchev 5538863dc9 Use shared eventLoopGroup in Reactor2TcpClient 2015-05-04 06:08:25 -04:00
Stephane Maldini 7891c0d5ca Update reactor2 support 2015-04-30 10:59:11 +02:00
Stephane Maldini 5ebc1a8b60 Update to latest reactor 2.0.1 snapshot 2015-04-30 10:59:00 +02:00
Rossen Stoyanchev 60b19c784d Update TCP/Reactor
Issue: SPR-12599
2015-04-24 07:19:04 -04:00
Stephane Maldini 74c0250525 Upgrade to Reactor 2
Issue: SPR-12599
2015-04-24 07:18:42 -04:00
Rossen Stoyanchev 16ee69203c Add support for destination vars in @SendTo/SendToUser
Issue: SPR-12170
2015-04-22 17:54:41 -04:00
Rossen Stoyanchev b6327acec8 Add SpEL based selector to DefaultSubscriptionRegistry
Issue: SPR-12884
2015-04-21 22:50:32 -04:00
Rossen Stoyanchev c29eae3307 Support user destinations with multiple app servers
This change adds support for broadcasting messages with unresolved
user destinations so that other servers can try to resolve it.
That enables sending messages to users who may be connected to a
different server.

Issue: SPR-11620
2015-04-17 11:55:44 -04:00
Rossen Stoyanchev c384945a17 Polish "user" destination support package
Issue: SPR-11620
2015-04-17 11:55:44 -04:00
Juergen Hoeller 10a51a4f19 InvocableHandlerMethod logs argument resolution exceptions at debug level
Issue: SPR-12925
2015-04-16 20:26:11 +02:00
Rossen Stoyanchev de9675bf5a Support heartbeat in SimpleBrokerMessageHandler
Issue: SPR-10954
2015-04-06 16:57:23 -04:00
Rossen Stoyanchev ae3417133b Add public access to PathMatcher in WebSocket config
Issue: SPR-12845
2015-03-26 16:50:33 -04:00
Juergen Hoeller d23893fd25 Consistent javadoc param declarations for type variables 2015-03-25 00:44:01 +01:00
Juergen Hoeller 4e28da439d TcpConnection extends java.io.Closeable
Issue: SPR-12849
2015-03-25 00:42:14 +01:00
Rossen Stoyanchev 4886edd10b Send STOMP ERROR if external broker not available
Issue: SPR-12820
2015-03-20 17:34:31 -04:00
Juergen Hoeller 898c24fcdd Optimized access to resolved bean type (avoiding BeanFactory locks)
Revised HandlerMethod.getBeanType() impl for both web and messaging.
In addition, HandlerMethods get created with the internal BeanFactory now.

Issue: SPR-12832
2015-03-20 17:35:44 +01:00
Rossen Stoyanchev 41e437066e Support @MessageExceptionHandler w/ @ControllerAdvice
This change adds support for global @MessageExceptionHandler methods
with STOMP over WebSocket messages. Such methods can be added to
@ControllerAdvice annotated components, much like @ExceptionHandler
methods for Spring MVC.

Issue: SPR-12696
2015-03-19 14:21:24 -04:00
Sam Brannen bf0703e07e Delete unused imports in spring-messaging 2015-03-17 17:29:38 +01:00
Rossen Stoyanchev d30b3eaf55 Add STOMP client
WebSocketStompClient can be used with any implementation of
org.springframework.web.socket.client.WebSocketClient, which includes
org.springframework.web.socket.sockjs.client.SockJsClient.

Reactor11TcpStompClient can be used with reactor-net and provides STOMP
over TCP. It's also possible to adapt other WebSocket and TCP client
libraries (see StompClientSupport for more details).

For example usage see WebSocketStompClientIntegrationTests.

Issue: SPR-11588
2015-03-12 21:48:29 -04:00
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
Juergen Hoeller 20c2ba35dc Polishing 2014-09-04 00:55:38 +02:00
Rossen Stoyanchev 96563c7eea Update Javadoc in SimpMessageSendingOperations
Issue: SPR-12143
2014-09-02 15:41:17 -04:00
Juergen Hoeller 820a160578 Polishing 2014-08-23 01:57:52 +02:00
Juergen Hoeller 078f23d6e6 Polishing 2014-08-23 01:07:01 +02:00
Juergen Hoeller b93dd95475 Polishing 2014-08-22 22:55:57 +02:00
Juergen Hoeller 28a966f544 MessageBuilder avoids intermediate HashMap for MessageHeaders building
Issue: SPR-11468
2014-08-22 22:55:48 +02:00
Phillip Webb ac8326d2df Polish mockito usage
Consistent use of BDDMockito rather than standard Mockito.
2014-08-11 16:23:11 -07:00
Juergen Hoeller c06ac06bdd JmsMessagingTemplate uses local convertJmsException template method instead of generic MessagingExceptionTranslator interface
This commit also turns MessagingException into a NestedRuntimeException subclass which delivers a root message that has the cause message appended to it. That's a common expectation with the use of Spring exceptions since all of our exception hierarchies have historically been designed that way.

Issue: SPR-12064
Issue: SPR-12038
2014-08-09 22:06:50 +02:00
Stephane Nicoll c1d149591a Add base header mapper implementation 2014-08-08 16:59:42 +02:00
Stephane Nicoll e010309530 Use @Payload on method declaration
Issue: SPR-12071
2014-08-07 15:09:04 +02:00
Stephane Nicoll 3da68cfe21 Remove unused imports 2014-08-04 14:13:40 +02:00
Stephane Nicoll 7d1e33d88d Move JmsHandlerMethodFactory to spring-messaging
This commit moves JmsHandlerMethodFactory and its default
implementation to the messaging abstraction. Working on a similar
support for AMQP revealed that this factory has nothing that is JMS
specific and is exactly identical in the case of AMQP.

Issue: SPR-12053
2014-08-01 16:08:31 +02:00
Juergen Hoeller 1fe742addf MessagingExceptionTranslator lives in support subpackage now
Issue: SPR-12038
2014-07-29 16:22:47 +02:00
Stephane Nicoll 89d63eb79b JmsMessagingTemplate exception management
This commit introduces MessagingExceptionTranslator, a messaging
exception translation infrastructure similar to what
PersistenceExceptionTranslator provides.

JmsMessagingTemplate does not throw raw JmsException anymore but
translates those to an instance of Spring's MessagingException
hierarchy.

Issue: SPR-12038
2014-07-29 12:29:43 +02:00
Juergen Hoeller 8cc0fa5ae1 Polishing 2014-07-28 22:05:40 +02:00
Juergen Hoeller 9fa4dad13c Polishing 2014-07-28 15:58:22 +02:00
Stephane Nicoll b6389a6c66 Jms request/reply operations
This commit updates JmsMessagingTemplate to support the
MessageRequestReplyOperation interface that provides synchronous
request/reply operations.

As JmsMessagingTemplate delegates everything under the scenes to
JmsTemplate, the latter has been updated as well to offer such lower
level operation.

Issue: SPR-12037
2014-07-28 15:52:50 +02:00
Juergen Hoeller 9d6c38bd54 Consistent bracket alignment 2014-07-18 17:21:58 +02:00
Juergen Hoeller 188e58c46a Fixed javadoc links 2014-07-18 17:21:44 +02:00
Rossen Stoyanchev 44e4569150 Polish 2014-07-17 09:24:45 -04:00
Sebastien Deleuze 59f39706dc Fix default target destination when using "." as path separator
Issue: SPR-11660
2014-07-17 09:01:45 -04:00
Rossen Stoyanchev e8d8c3390a Increase timeout in integration test 2014-07-16 22:05:50 -04:00
Sebastien Deleuze 86e8bdab6b Make ListenableFuture compliant with Java 8 lambda
Make it possible to use a ListenableFuture with Java 8
lambda expressions, using a syntax like
listenableFuture.addCallback(() -> ..., () -> ...);

Issue: SPR-11820
2014-07-16 16:06:24 +02:00
Rossen Stoyanchev ab2526a586 Update support for using "." as path separator
Issue: SPR-11660
2014-07-14 18:49:25 -04:00
Sebastien Deleuze 928a466b5d Allow to customize separator for messaging destinations
In order to be able to use separators like "." (used by default
by most broker relays) instead of "/" for destination patterns
handling, the PathMatcher used in spring-messaging can now
be customized easily thanks to XML websocket namespace
or JavaConfig.

AntPathMatcher has been updated in order to use the configured path
separator instead of an hardcoded "/" for path concatenation.
Extension handling is now disabled when the "." separator is configured.

Issue: SPR-11660
2014-07-14 18:49:24 -04:00
Rossen Stoyanchev b318880661 Ensure StompEncoder never writes content-length twice
Issue: SPR-11984
2014-07-11 10:09:48 -04:00
Rossen Stoyanchev 2f371e5aeb Add ExecutorChannelInterceptor
Issue: SPR-11968
2014-07-10 16:55:34 -04:00
Rossen Stoyanchev f8e4547228 Fix test class name and protect debug log message 2014-07-10 16:55:34 -04:00
Rossen Stoyanchev 670c216d38 Change converter ordering in message broker config
Issue: SPR-11961
2014-07-10 12:57:00 -04:00
Juergen Hoeller e254b558f0 Polishing 2014-07-10 18:38:07 +02:00
Rossen Stoyanchev eaad0a0f52 Add after completion callbacks to ChannelInterceptor
Issue: SPR-11966
2014-07-09 18:57:11 -04:00
Juergen Hoeller 6f062581a6 Removed unused import (which indicated a package cycle) 2014-07-10 00:36:54 +02:00
Juergen Hoeller 0d4ff1adbf Polishing 2014-07-09 22:25:35 +02:00
Juergen Hoeller fa4f51c5d0 Subpackage rearrangements within 4.1's jms-messaging alignment
Issue: SPR-10873
2014-07-09 22:19:14 +02:00
Juergen Hoeller 777085bbfc MappingJackson2JsonView/MessageConverter calls non-deprecated Jackson 2.1+ createGenerator API
Also removing workaround for https://github.com/FasterXML/jackson-databind/issues/12 (fixed in 2.1+)

Issue: SPR-11262
2014-07-09 21:23:09 +02:00
Rossen Stoyanchev 48236be4a2 STOMP and WebSocket messaging related logging updates
This change removes most logging at INFO level and also ensures the
amount of information logged at DEBUG level is useful, brief, and
not duplicated.

Also added is custom logging for STOMP frames to ensure very readable
and consise output.

Issue: SPR-11934
2014-07-09 00:39:59 -04:00
Rossen Stoyanchev ab4864da2a Add STOMP/WebSocket stats collection
This change adds collection of stats in key infrastructure components
of the WebSocket message broker config setup and exposes the gathered
information for logging and viewing (e.g. via JMX).

WebSocketMessageBrokerStats is a single class that assembles all
gathered information and by default logs it once every 15 minutes.
Application can also easily expose to JMX through an MBeanExporter.

A new section in the reference documentation provides a summary of
the available information.

Issue: SPR-11739
2014-07-09 00:39:47 -04:00
Juergen Hoeller 526b463474 Standard use of resolvedDestinationCache Map; fixed formatting
Issue: SPR-11939
2014-07-02 20:53:52 +02:00
Rossen Stoyanchev 6d15fcc4a6 Log name of test for WebSocket integration tests
This makes it easier to trace log output on the CI server where the
output is per class.
2014-07-02 14:26:51 -04:00
Juergen Hoeller 5614e257d1 Polishing
Issue: SPR-11939
2014-07-02 17:03:05 +02:00
Juergen Hoeller c84b30d4a4 CachingDestinationResolverProxy for slow target DestinationResolvers
Issue: SPR-11939
2014-07-02 17:00:26 +02:00
Rossen Stoyanchev 7a1f19b96c Polish 2014-07-01 14:24:16 -04:00
Sebastien Deleuze ce20abde51 Improve subscription removal in SubscriptionRegistry
Avoid using destination pattern based search when removing sessions or
subscriptions from DefaultSubscriptionRegistry and use only session and
subscription ids.

Issue: SPR-11930
2014-07-01 14:23:26 -04:00
Sebastien Deleuze 083d415fc4 Fix cache cleanup issue in DefaultSubscriptionRegistry
Issue: SPR-11931
2014-07-01 14:23:06 -04:00
Rossen Stoyanchev 7da3fb4ce6 Support STOMP DISCONNECT with receipt
Issue: SPR-11599
2014-06-29 13:15:22 -04:00
Rossen Stoyanchev 86de416908 More WebSocket logging updates
Update WebSocketSession toString methods to include the handshake URI
and add id and URI fields to ensure they're available after close().

Log WebSocket session open and close events at INFO.

Remove trace messages for destinations that do not match.

Issue: SPR-11884
2014-06-29 13:15:02 -04:00
Rossen Stoyanchev cab0b97a83 Polish 2014-06-27 12:43:52 -04:00
Rossen Stoyanchev 7a5b3c1eed Append suffx to user dest in SimpMessagingTemplate
Isssue: SPR-11868
2014-06-27 12:43:52 -04:00
Rossen Stoyanchev 113fd1180a Fine tune STOMP and WebSocket related logging
Optimize logging with tracking the opening and closing of WebSocket
sessions and STOMP broker connections in mind.

While the volume of messages makes it impractical to log every message
at anything higher than TRACE, the opening and closing of connections
is more manageable and can be logged at INFO. This makes it possible to
drop to INFO in production and get useful information without getting
too much in a short period of time.

The logging is also optimized to avoid providing the same information
from multiple places since messages pass through multiple layers.

Issue: SPR-11884
2014-06-27 04:06:06 -04:00
Juergen Hoeller 18131bf611 Consistent declaration of private static final logger variables
Issue: SPR-11905
2014-06-24 14:02:05 +02:00
Juergen Hoeller 5a8e470ede DefaultSubscriptionRegistry's removeSubscriptionInternal defensively handles non-existing destinations
Issue: SPR-11832
2014-06-04 22:48:34 +02:00
Stephane Nicoll e4ad9c5204 polishing
If no converter is found, the MessageConversionException now contains
the message instance that could not be handled

Issue: SPR-11817
2014-05-30 14:53:09 +02:00
Stephane Nicoll 12a9df8a1c Throw a proper exception if no convert is found
Prior to this commit, no exception was raised if a message could not
be converted to the requested payload because no suitable converter
were found.

This commit adds an explicit check if the converted payload is null.

Issue: SPR-11817
2014-05-28 16:48:48 +02:00
Stephane Nicoll 9fabcad3dd Revisit JmsMessagingTemplate
This commit revisits JmsMessagingTemplate and adds support for
receiving operations as well. JmsMessageSendingOperations has been
renamed to JmsMessageOperations.

The messaging abstraction did not split receiving and request-reply
operations. AbstractMessageReceivingTemplate has been created to hold
only the receiving operations.

Issue: SPR-11772
2014-05-26 09:35:03 +02:00
Stephane Nicoll 7469159bf1 Add MessageSendingOperations for JMS
This commit adds a JMS implementation of MessageSendingOperations,
allowing to send JMS messages using Spring's standard Messaging
abstraction.

MessagingMessageConverter is a standard JMS's MessageConverter that
can convert Spring's Message to JMS message and vice versa. Existing
infrastructure has been updated to use this implementation.

Issue: SPR-11772
2014-05-19 10:46:13 +02:00
Rossen Stoyanchev 673a497923 Await TcpClient shutdown in STOMP broker relay 2014-05-15 22:00:17 -04:00
Rossen Stoyanchev 2c4cbb617e Add WebSocket scope
This change adds support for a custom "websocket" scope.

WebSocket-scoped beans may be injected into controllers with message
handling methods as well as channel interceptor registered on the
"inboundClientChannel".

Issue: SPR-11305
2014-05-11 12:31:17 -04:00
Rossen Stoyanchev 97fb308b6b Allow use of @SendToUser even w/o authenticated user
Before this change, subscribing to a user destination and use of
@SendToUser annotation required an authenticated user.

This change makes it possible to subscribe to a user destination from
WebSocket sessions without an authenticated user. In such cases the
destination is associated with one session only rather than with a
user (and all their sessions).

It is then also possible to send a message to a user destination
via "/user/{sessionId}/.." rather than "/user/{user}/...".

That means @SendToUser works relying on the session id of the input
message, effectively sending a reply to destination private to the
session.

A key use case for this is handling an exception with an
@MessageExceptionHandler method and sending a reply with @SendToUser.

Issue: SPR-11309
2014-05-08 22:06:57 -04:00
Sebastien Deleuze 98738c0bbb Avoid ConcurrentModificationException
Removal of cached destination is now moved outside the for loop
that removes subscriptions to avoid ConcurrentModificationException.

Also since updateCache is a LinkedHashMap with accessOrder=true,
a simple access with updateCache.get() modify the map.
By iterating over updateCache.entrySet(), we avoid this update.

Issue: SPR-11755
2014-05-06 20:19:09 -04:00
Rossen Stoyanchev 9598a1e2ef Update @SendToUser and related code
Issue: SPR-11506
2014-05-01 10:35:35 -04:00
Mark Galea 088b80f4c5 Add singleSession attribute to @SendToUser
Added the ability to send a message only to one user session. Given a
user has two tabs open and the client sends a message to the server
from tab 1, it is now possible to send a reply message to only 1 tab
instead of the default mode of targetting all known user sessions.

Issue: SPR-11506
2014-05-01 10:33:14 -04:00
Rossen Stoyanchev 5dcd55b23b Log ignored CONNECT messages at error level
Issue: SPR-11673
2014-04-30 11:11:43 -04:00
Rossen Stoyanchev d52f07aa1b Log STOMP ERROR frames at error level
Issue: SPR-11673
2014-04-30 11:00:27 -04:00
Rossen Stoyanchev 1958ae3a62 Update log level
Issue: SPR-11673
2014-04-30 10:26:51 -04:00
Rossen Stoyanchev 6a9b229249 Split destination cache into access vs update
Issue: SPR-11657
2014-04-29 22:15:18 -04:00
Rossen Stoyanchev c879796e00 Add cache limit to DefaultSessionRegistry and polish
Issue: SPR-11657
2014-04-29 18:16:09 -04:00
Sebastien Deleuze 1054080b24 Fix DefaultSubscriptionRegistry when using pattern destinations
DestinationCache is now used for both plain and pattern
destinations. It stores internally the subscriptions map for each
cached destination. Subscriptions are initially created when there
is no cache for the requested destination, and are updated when
subscriptions change.

Issue: SPR-11657
2014-04-29 18:16:09 -04:00
Rossen Stoyanchev 58adc150c9 Fix STOMP broker relay int test issue
Avoid dependency on order in which expected messages are received.
2014-04-29 17:17:10 -04:00
Rossen Stoyanchev 56d26443e2 Fix one more issue in STOMP broker relay int test 2014-04-29 16:36:43 -04:00
Rossen Stoyanchev 13be6d2321 Fix issue in STOMP broker relay integration test 2014-04-29 15:48:39 -04:00
Rossen Stoyanchev 01fe2923ee Simplify STOMP broker relay integration test
This change simplifies the implementation of the "test" EventPublisher
and MessageHandler used in the STOMP broker relay integration tests.
The updated implementations use a time-limted poll on a BlockingQueue.
2014-04-29 13:22:23 -04:00
Rossen Stoyanchev 1200755125 Fix issue with subscribe destination
The original fix for SPR-11423:
32e5f57e64

was insufficient when using an external broker since the original
destination header has to be in the "native headers" map (i.e. with
STOMP headers) in order to be included in messages broadcast by
the broker.
2014-04-25 12:26:04 -04:00
Stephane Nicoll bded025d9f @SendTo support for jms listener endpoints
This commit replaces the "responseDestination" attribute on the
JmsListener annotation by a support of the standard SendTo annotation.

Issue: SPR-11707
2014-04-24 15:33:24 +03:00
Rossen Stoyanchev 08f0395033 Rename Reactor support classes
This change modifies the names of the Reactor support classes in order
to align with the same changes in the 4.0.x line which now supports
both Reactor 1.1 and 1.0.

Issue: SPR-11636
2014-04-23 23:46:43 -04:00
Stephane Nicoll 5559209233 Remove useless imports 2014-04-22 09:57:12 +02:00
Philippe Marschall eb5f397a39 Clean up spring-messaging imports
spring-messaging is full of unused imports. This commit removes all
unused imports from spring-messaging.
2014-04-22 07:28:10 +02:00
Juergen Hoeller 086f1eda71 Polishing 2014-04-17 22:39:47 +02:00
Juergen Hoeller 28887750b0 MessageConversionException offers constructor without cause argument now, plus related polishing
Issue: SPR-11653
2014-04-17 21:19:37 +02:00
Stephane Nicoll 713dd60fa7 JMS annotation-driven endpoints.
This commit adds the support of JMS annotated endpoint. Can be
activated both by @EnableJms or <jms:annotation-driven/> and
detects methods of managed beans annotated with @JmsListener,
either directly or through a meta-annotation.

Containers are created and managed under the cover by a registry
at application startup time. Container creation is delegated to a
JmsListenerContainerFactory that is identified by the containerFactory
attribute of the JmsListener annotation. Containers can be
retrieved from the registry using a custom id that can be specified
directly on the annotation.

A "factory-id" attribute is available on the container element of
the XML namespace. When it is present, the configuration defined at
the namespace level is used to build a JmsListenerContainerFactory
that is exposed with the value of the "factory-id" attribute. This can
be used as a smooth migration path for users having listener containers
defined at the namespace level. It is also possible to migrate all
listeners to annotated endpoints and yet keep the
<jms:listener-container> or <jms:jca-listener-container> element to
share the container configuration.

The configuration can be fine-tuned by implementing the
JmsListenerConfigurer interface which gives access to the registrar
used to register endpoints. This includes a programmatic registration
of endpoints in complement to the declarative approach. A default
JmsListenerContainerFactory can also be specified to be used if no
containerFactory has been set on the annotation.

Annotated methods can have flexible method arguments that are similar
to what @MessageMapping provides. In particular, jms listener endpoint
methods can fully use the messaging abstraction, including convenient
header accessors. It is also possible to inject the raw
javax.jms.Message and the Session for more advanced use cases. The
payload can be injected as long as the conversion service is able to
convert it from the original type of the JMS payload. By
default, a DefaultJmsHandlerMethodFactory is used but it can be
configured further to support additional method arguments or to
customize conversion and validation support.

The return type of an annotated method can also be an instance of
Spring's Message abstraction. Instead of just converting the payload,
such response type allows to communicate standard and custom headers.

The JmsHeaderMapper infrastructure from Spring integration has also
been migrated to the Spring framework. SimpleJmsHeaderMapper is based
on SI's DefaultJmsHeaderMapper. The simple implementation maps all
JMS headers so that the generated Message abstraction has all the
information stored in the protocol specific message.

Issue: SPR-9882
2014-04-17 09:16:06 +02:00
Rossen Stoyanchev 6cb9a144db Expand static resource handling mechanism
An initial commit with expanded support for static resource handling:

- Add ResourceResolver strategy for resolving a request to a Resource
  along with a few implementations.

- Add PublicResourceUrlProvider to get URLs for client-side use.

- Add ResourceUrlEncodingFilter and
  PublicResourceUrlProviderExposingInterceptor along with initial
  MVC Java config support.

Issue: SPR-10933
2014-04-16 23:42:44 -04:00
Rossen Stoyanchev 4e1781ae8c Use strategy for customizing ID/TIMESTAMP generation
Issue: SPR-11468
2014-04-14 21:03:13 -04:00
Rossen Stoyanchev 95e25d4e6f Add strategy for customizing ID/TIMESTAMP headers
Introduce MessageHeaderInitializer strategy for initializing a
MessageHeaderAccessor.

Add IdTimestampMessageHeaderInitializer implementation that provides
control over ID and timestamp header generation.

Disable ID and timestamp by default in SimpMessageHeaderAccessor and
therefore its sub-class StompHeaderAccessor.

Issue: SPR-11468
2014-04-14 13:52:55 -04:00
Rossen Stoyanchev 65b17b80ba Switch BufferingStompDecoder to decoration
The BufferingStompDecoder now decorates rather than extend
StompDecoder. This allows a single StompDecoder instance to be
configured and extended independantly while buffering remains a
separate concern.
2014-04-13 21:35:22 -04:00
Rossen Stoyanchev fda9c633c4 Support mutable headers in MessagingTemplate
AbstractMessageConverter and messaging template implementations now
detect and use mutable headers if passed in.

The SimpMessagingTemplate is optimized to supporting using a single
MessageHeaders instance while preparing a message.

This commit also updates code using the SimpMessagingTemplate to take
advantage of its new capabilities.

Issue: SPR-11468
2014-04-13 18:43:25 -04:00
Rossen Stoyanchev ae942ffdb8 Make use of enhanced MessageHeaderAccessor support
Mutate rather than re-create headers when decoding STOMP messages
before a message is sent on a message channel.

Use MessageBuilder.createMessage to ensure the fully prepared
MessageHeaders is used directly MessageHeaderAccessor instance.

Issue: SPR-11468
2014-04-13 18:43:25 -04:00
Rossen Stoyanchev 4867546aec Enhance MessageHeaderAccessor support
Refine semantics of ID and TIMESTAMP headers provided to protected
MessageHeaders constructor.

Refactor internal implementation of MessageHeaderAccessor.

Support mutating headers from a single thread while a message is being
built (e.g. StompDecoder creating message + then adding session id).

Improve immutablity in NativeMessageHeaderAccessor and in
StompHeaderAccessor.

Optimize object creation for initializing messages and subsequent
accessing their headers.

Introduce MessageHeaderAccessorFactory support to enable applying a
common strategies for ID and TIMESTAMP generation to every message.

Add MessageBuilder shortcut factory method for creating messages from
payload and a full-prepared MessageHeaders instance. Also add
equivalent constructors to GenericMessage and ErrorMessage.

Issue: SPR-11468
2014-04-13 18:43:25 -04:00
Rossen Stoyanchev ddf8750511 Update MessageHeaders constructor
Following discussion with Gary.

Issue: SPR-11468
2014-04-04 15:49:53 -04:00
Gary Russell 1eee339c15 Relax constraints in MessageHeaders for subclasses
Allow a subclass to modify MessageHeaders as well as override the
strategy for or even skip having `ID` and `TIMESTAMP` headers.

Issue: SPR-11468
2014-04-04 14:39:09 -04:00
Rossen Stoyanchev 5e925ac03c Rename header for "orig" destination
The UserDestinationMessageHandler adds a header providing a hint for
what the original destination a user may have used when subscribing.
That is then used when writing messages back to WebSocket clients to
ensure they dont see the internally used, transformed user destination.

This change moves the header name constatn to make it more broadly
applicable. For example SPR-11645.
2014-04-04 14:31:49 -04:00
Brian Clozel ec0b672baa Fix @SubscribeMapping MESSAGE response destination
Prior to this commit, @SubscribeMapping mapped methods (backed with
@SendTo* annotations, or not) would send MESSAGEs with the wrong
destination. Instead of using the original SUBSCRIBE destination, it
would use the lookup path computed from the configured prefixes in the
application.

This commit fixes this issue - now @SubscribeMapping MESSAGEs use the
original SUBSCRIBE destination.

Issue: SPR-11648
2014-04-04 12:43:35 +02:00
Rossen Stoyanchev 990f5bb720 Improve handling of disconnects in STOMP broker relay
Issue: SPR-11655
2014-04-03 22:31:10 -04:00
Rossen Stoyanchev 59703981c4 Upgrade to reactor 1.1.0 snapshots
Issue: SPR-11636
2014-04-01 22:05:10 -04:00
Sam Brannen 89a4c291c3 Remove trailing whitespace 2014-04-01 20:22:25 +02:00
Rossen Stoyanchev 75439c7836 Polish 2014-03-27 20:35:00 -04:00
Rossen Stoyanchev e3ef3fffa5 Optimize STOMP encoding/decoding hotspots 2014-03-27 20:15:53 -04:00
Rossen Stoyanchev d19e30e2f8 Increase log level in spring-messaging tests 2014-03-27 09:21:08 -04:00
Stephane Nicoll c1eb50ef48 polishing 2014-03-25 16:49:54 +01:00
Rossen Stoyanchev 2c1d5efbb0 Introduce base exception class for arg resolution
Issue: SPR-11584
2014-03-25 11:02:24 -04:00
Stephane Nicoll 2aee0d8250 Improve MessageMethodArgumentResolver
This commit validates that the payload type of the message is
assignable to the one declared in the method signature. If that
is not the case, a meaningful exception message is thrown with
the types mismatch.

Prior to this commit, only the Message interface could be defined
in the method signature: it is now possible to define a sub-class
of Message if necessary which will match as long as the Message
parameter is assignable to that type.

Issue: SPR-11584
2014-03-25 10:12:29 -04:00
Rossen Stoyanchev 8780464c64 Update test to catch CI server issue 2014-03-25 08:24:53 -04:00
Rossen Stoyanchev c11484b2e7 Add WebSocket transport configuration support
Issue: SPR-11527
2014-03-24 19:20:38 -04:00
Rossen Stoyanchev 545c4effb1 Polish StompDecoder and the new Buffering sub-class
Issue: SPR-11527
2014-03-24 19:20:37 -04:00
Sebastien Deleuze bbdb72d808 Add configuration for message buffer size limit
BufferingStompDecoder message buffer size limit can now be configured
with JavaConfig MessageBrokerRegistry.setMessageBufferSizeLimit() or
with XML <websocket:message-brocker message-buffer-size="">.

Issue: SPR-11527
2014-03-24 19:20:37 -04:00
Rossen Stoyanchev ebffd67b5e Add BufferingStompDecoder
Before this change the StompDecoder decoded and returned only the first
Message in the ByteBuffer passed to it. So to obtain all messages from
the buffer, one had to loop passing the same buffer in until no more
complete STOMP frames could be decoded.

This chage modifies StompDecoder to return List<Message> after
exhaustively decoding all available STOMP frames from the input buffer.
Also an overloaded decode method allows passing in Map that will be
populated with any headers successfully parsed, which is useful for
"peeking" at the "content-length" header.

This change also adds a BufferingStompDecoder sub-class which buffers
any content left in the input buffer after parsing one or more STOMP
frames. This sub-class can also deal with fragmented messages,
re-assembling them and parsing as a whole message.

Issue: SPR-11527
2014-03-24 19:20:37 -04:00
Juergen Hoeller dd7f54c3c0 Revised ResizableByteArrayOutputStream as an actual subclass of ByteArrayOutputStream, and consistently applied appropriate ByteArrayOutputStream initial capacities across the codebase
Issue: SPR-11594
2014-03-24 22:57:38 +01:00
Rossen Stoyanchev 929e9ca401 Raise MessageConversionException in @Payload resolver
If a payload is present but conversion returns null (meaning no
converter knows how to convert), raise a MessageConversionException
that provides information about the type we were trying to convert
to and the message itself whose headers (namely content-type) contain
crucial information required to debug the problem.

Issue: SPR-11577
2014-03-21 08:59:12 -04:00
Rossen Stoyanchev d4782647a4 Ensure default value of @Payload required is enforced
When no @Payload is provided, it is equivalent to @Payload with default
attribute values. Since the default value of required=true, then
an argument that's not annotated is required.
2014-03-20 19:44:19 -04:00
Stephane Nicoll 52c3f713bf Fix handling of required payload.
A payload that is required will now throw an appropriate exception
regardless of if a conversion is required or not.

isEmptyPayload now takes the payload instead of the message
so that both the original payload and the converted payload, if
necessary, share the same logic.

JSR-303 validation is now consistently applied.

Issue: SPR-11577
2014-03-20 16:43:33 -04:00
Stephane Nicoll 4cd818b9e4 Harmonize log configuration
Prior to this commit, the codebase was using a mix of log4j.xml
and log4j.properties for test-related logging configuration. This
can be an issue as log4j takes the xml variant first when looking
for a default bootstrap configuration.

In practice, some modules declaring the properties variant were
taking the xml variant configuration from another module.

The general structure of the configuration has also been
harmonized to provide a standard console output as well as an
easy way to enable trace logs for the current module.
2014-03-20 09:43:29 -07:00
Rossen Stoyanchev 10af128e96 Update thread pool settings in STOMP/WebSocket config
The clientInboundChannel and clientOutboundChannel now use twice
the number of available processors by default to accomodate for some
degree of blocking in task execution on average.

In practice these settings still need to be configured explicitly in
applications but these should serve as better default values than
the default values in ThreadPoolTaskExecutor.

Issue: SPR-11450
2014-03-20 00:45:37 -04:00
Rossen Stoyanchev 1bab8a3916 Add session attributes to SimpMessageHeaderAccessor
This change exposes the WebSocketSession attributes through a message header.
The StompSubProtocolHandler adds this to incoming messages.
For now messaging handling  methods can access the map via @Header, e.g.:

@Header(StompHeaderAccessor.SESSION_ATTRIBUTES) Map<String, Object> attrs) {

Issue: SPR-11566
2014-03-19 13:45:40 -04:00
Rossen Stoyanchev 1fa4a7d34f Fix minor issue in STOMP broker relay 2014-03-19 10:35:48 -04:00
Rossen Stoyanchev df98490f0d Increase logging for spring-messaging tests
A temporary measure related to intermittent CI build server failures.
2014-03-17 22:32:01 -04:00
Rossen Stoyanchev a372b683cd Use custom config read in ReactorTcpClient
Use a custom ConfigReader to enforce the use of SynchronousDispatcher
and no other dispatchers otherwise created by default. Avoids the
creation thread pools never to be used.
2014-03-17 21:13:14 -04:00
Rossen Stoyanchev 57af56aeeb Improve logging in STOMP broker relay
Ignore DISCONNECT messages if already disconnected. This can occur if
the client explicitly sends a DISCONNECT frame and then closes the
socket quickly. The closing of the WebSocket sessions also sends a
DISCONNECT upstream to ensure the broker is aware.
2014-03-17 17:11:15 -04:00
Rossen Stoyanchev 918e21fd8f Upgrade to reactor 1.0.1.RELEASE 2014-03-17 17:10:53 -04:00
Rossen Stoyanchev f68bd5c8b2 Rename ReactorNettyTcpClient to ReactorTcpClient
Even though Netty is a required dependency of reactor-tcp at present,
there is no hard dependency in the spring-messaging Reactor-based
implementation.
2014-03-16 18:12:45 -04:00
Rossen Stoyanchev 2e13bf8b81 Refine Reactor-based TCP client implementation
Configure explicitly use of SynchronousDispatcher instead of the one
used otherwise by default (RingBufferDispatcher). As a result TCP
optations are now scoped to Netty's threads.

Remove Environment field. It is no longer required to shut it down
since we're now using SynchronousDispatcher by default.

Replace connection.in() with connection.consume() when composing
connection handling. The former creates a Stream for further composing,
e.g. via map(), filter() but all we need is to read a message.

Provide additional constructor that aceepts a pre-configured Reactor
TcpClient instance.

Issue: SPR-11531
2014-03-16 18:12:45 -04:00
Rossen Stoyanchev 6bcbb94aba Refine BrokerAvailabilityEvent behavior
Add accessor for brokerAvailable in AbstractBrokerMessageHandler
Ensure brokerAvailable is set even if eventPublisher is not
Add tests BrokerMessageHandlerTests

Turn off brokerAvailable when StompBrokerRelayMessageHandler stops
Actually stop message handling when brokerAvailable=false
Improve log messages

Issue: SPR-11563
2014-03-16 18:12:45 -04:00
Juergen Hoeller 189cd663c5 Polishing 2014-03-15 00:46:06 +01:00
Juergen Hoeller 791f58e6be Polishing 2014-03-13 17:31:39 +01:00
Rossen Stoyanchev 13af188bdc Handle invalid STOMP content-length header value
After this change if a content-length header is provided but is less
than 0 or cannot be parsed as a number, it is ignored and the body
is read sequentially, i.e. until we reach a null byte terminator.

This provides better protection against clients that may set the
content-length header in error.

Issue: SPR-11528
2014-03-10 22:07:39 -04:00
Rossen Stoyanchev cff23b84ae Add messages for number of active sessions/connections
Issue: SPR-11531
2014-03-10 16:58:02 -04:00
Rossen Stoyanchev a473d46e1c Tighten connection management in STOMP broker relay
Fix NPE exception when closing TcpConnection

Ensure a ConnectionHandler is cleared when a TcpConnection is closed
(at the same time), logging an exception if the closing fails.

Improve error messages.

Issue: SPR-11531
2014-03-10 16:46:13 -04:00
Sam Brannen 2edff2135f Polish Javadoc for DefaultContentTypeResolver 2014-02-28 15:19:35 +01:00
Rossen Stoyanchev 6016536055 Remove ContentTypeResolver from composite converter
Before this change CompositeMessageConverter had a ContentTypeResolver
field that was in turn set on all contained converters.

After this change that field is removed and effectively
CompositeMessageConverter is a simple container of other converters.
Each converter in turn must have been configured with a
ContentTypeResolver.

Doing so means it is less likely to have unexpected consequences when
configuring converters, the ContentTypeResolver set in the composite
converter overriding the one configured in a contained converter.

Also commit 676ce6 added default ContentTypeResolver initialization
to AbstractMessageConverter, which ensures that converters are still
straight forward to configure.

Issue: SPR-11462
2014-02-27 21:41:35 -05:00
Rossen Stoyanchev 0da1eefd74 Add default ContentTypeResolver initialization
Previously AbstractMessageConverter did not have a ContentTypeResolver
configured by default. However the Java config and XML namespace in
spring-messaging and spring-websocket always configured one.

This change ensures every AbstractMessageConverter is configured with an
instance of DefaultContentTypeResolver by default. This makes sense since
all the resolver does is make an attempt to find a content type to use
for matching. If it can't it returns null and it's up to the converter
to decide whether it can convert or not.

Issue: SPR-11462
2014-02-27 21:40:53 -05:00
Rossen Stoyanchev 56476cdd5f Add strictContentTypeMatching converter option
AbstractMessageConverter now supports a strictContentTypeMatching mode
in which the content type of a message must be resolved to a (non-null)
value that matches one of the configured supported MIME types in order
for the converter to be used.

Issue: SPR-11463
2014-02-27 15:43:54 -05:00
Sebastien Deleuze 2b69c1f15b Support String contentType headers in spring-messaging
After this change DefaultContentTypeResolver supports String-based
"contentType" header values in addition to MimeType-based.

Issue: SPR-11461
2014-02-27 12:00:50 -05:00
Rossen Stoyanchev b727cdb120 Adjust ActiveMQ settings in integration tests
Before this change tests on the CI server showed the following message:

Store limit is 102400 mb, whilst the data directory:
/opt/.../KahaDB only has 74810 mb of usable space

This change turns off store persistence and also explicitly sets the
limit on memory usage.
2014-02-24 17:07:34 -05:00
Brian Clozel 1dedb67fbc Set virtualHost on StompBrokerRelayRegistration
Prior to this commit, one couldn't set the virtualHost property on
StompBrokerRelayMessageHandler via JavaConfig, since
StompBrokerRelayRegistration's API didn't offer that possibility.

This commit adds a new method in StompBrokerRelayRegistration's fluent
API to set the virtualHost used by StompBrokerRelayMessageHandler.
Note: this property is already configurable via xml config.

Issue: SPR-11433
2014-02-17 14:51:05 +01:00
Juergen Hoeller 14e5a02870 Mixed polishing along with recent changes 2014-02-14 21:39:40 +01:00
Juergen Hoeller 72fe7ebc34 Objects with multi-threaded access should not lazily populate a hash field
Issue. SPR-11428
2014-02-14 20:46:34 +01:00
Rossen Stoyanchev 32e5f57e64 Ensure matching user destination returned
Before this change, when a client subscribed to a "user" destination
(e.g. /user/foo), actual messages received in response to that
subscription contained the server-translated, unique user destination
(e.g. /foo-user123).

This is not an issue for clients such as stomp.js since the
subscription is unique and sufficient to match subscription responses.
However, other STOMP clients do additional checks on the destination
of the subscription and the response.

This change ensures that messages sent to clients on user destionations
always contain a destination that matches the one on the original
subscription.

Issue: SPR-11423
2014-02-13 16:38:56 -05:00
Juergen Hoeller cead06a3d9 Polishing 2014-02-12 00:12:52 +01:00
Juergen Hoeller 1a1c72ce4b Revised InvocableHandlerMethod exception handling
Issue: SPR-11281
2014-02-11 23:48:10 +01:00
Rossen Stoyanchev 7301b58ec9 Improve info on use of @Controller's with aop proxying
Before this change, issues surrounding the use of @Controller's in
combination with AOP proxying, resulted in an IllegalArgumentException
when trying to invoke the controller method.

This change detects such cases proactively and reports them with a
clear recommendation to use class-based proxying when it comes to
@Controller's. This is the most optimcal approach for controllers
in many respects, also allows @MVC annotations to remain on the
class.

The documentation has also been updated to have a specific section
on @Controller's and AOP proxying providing the same advice.

Issue:SPR-11281
2014-02-11 12:25:54 -05:00
Sam Brannen c335e99e3f Remove trailing whitespace from source code 2014-02-08 17:30:39 +01:00
Juergen Hoeller 919d6ccb3b Actually log the cause of canRead/canWrite failures
Issue: SPR-11403
2014-02-07 17:27:17 +01:00
Rossen Stoyanchev f636ccb5eb Fix failing test 2014-02-05 22:02:59 -05:00
Rossen Stoyanchev 46c0e45130 Improve header processing in SimpMessagingTemplate
Headers provided to the SimpMessagingTemplate's convertAndSend methods
are now automatically moved into the "nativeHeaders" sub-map. This
ensures the headers will go out with the STOMP message and be received
by subscribers.

Issue: SPR-11387
2014-02-05 21:25:35 -05:00
Sam Brannen 67142dcb0a Polish Javadoc in @*ExceptionHandler 2014-02-05 20:15:50 +01:00
Rossen Stoyanchev e6f4796779 Fix failing test 2014-02-01 10:46:51 -05:00
Rossen Stoyanchev da369aa826 Add null check after message conversion
AbstractMessageSendingTemplate now checks if MessageConverter.toMessage
returns null and raises an exception.

Issue: SPR-11370
2014-01-31 21:34:18 -05:00
Rossen Stoyanchev f0a53ae54e Fine-tune default mime type in message broker config
Issue: SPR-11370
2014-01-31 20:55:07 -05:00
Rossen Stoyanchev a106e06a89 Expose failing test in GenericMessagingTemplateTests
Assertions made in callbacks invoked on separate thread were not
reaching the test framework. This fix ensures failures are detected
and cause tests to fail.
2014-01-22 16:43:21 -05:00
Gary Russell 0e7b94f9e9 Add constructors to MessageHandlingException
Issue: SPR-11345
2014-01-22 14:43:35 -05:00
Rossen Stoyanchev 8ee2a2d18c Remove unused constructor arg from UserDestinationMH 2014-01-22 11:55:44 -05:00
Rossen Stoyanchev 0db2f79bdb Polish message method handling tests 2014-01-22 11:29:38 -05:00
Brian Clozel db9b6fa28e Split tests for MethodMessageHandlers impl.
Prior to this commit, all MethodMessageHandlers tests were
implemented in a single class. Since SimpAnnotationMsgHandler
has been refactored with an abstract class, tests also
needed such a refactoring.

This commit creates test fixtures for AbstractMethodMessageHandler.

Issue: SPR-11191
2014-01-22 10:42:24 -05:00
Sam Brannen 597ef099d0 Suppress warnings and remove unused imports 2014-01-22 12:23:32 +01:00
Brian Clozel 845a6b0b7d Remove serialVersionUIDs in spring-messaging Exc.
Prior to this commit, several spring-messaging exceptions
had defined serialVersionUIDs. Those exception aren't
supposed to leave the system via Java serialization; also,
their deserialization is supported only against the same
version of Spring.

Issue: SPR-11339
2014-01-22 11:37:04 +01:00
Rossen Stoyanchev d03fb8954b Encode user names in user destanations
Issue: SPR-11302
2014-01-21 14:57:51 -05:00
Rossen Stoyanchev ae06c3a6ab Use DestinationUserNameProvider with @SendTo
Issue: SPR-11327
2014-01-21 12:32:35 -05:00
Rossen Stoyanchev e4ad2b352e Add DestinationUserNameProvider interface
The interface is to be implemented in addition to
java.security.Principal when Principal.getName() is not globally unique
enough for use in user destinations.

Issue: SPR-11327
2014-01-21 12:12:05 -05:00
Rossen Stoyanchev 2cafe9d73a Polish 2014-01-21 12:12:05 -05:00
Phillip Webb 6bb6b6e6b5 Fix warnings in HeaderMethodArgumentResolver 2014-01-20 13:53:17 -08:00
Rossen Stoyanchev 5053fdc8c9 Resolve native header values with @Header
The @Header annotation in spring-messaging now resolves values from the
nested "nativeHeaders" map as well as top-level header map values.

In case of ambiguity (a value that exists in both), the top-level map
value is used and a warning message is printed. This is unlikly in most
cases but can be resolved by prefixing the header value with
"nativeHeadres.myHeader".

Issue: SPR-11326
2014-01-20 16:28:27 -05:00
Rossen Stoyanchev b4e48d6749 Fix issue in DefaultUserDestinationResolver
DefaultUserDestinationResolver now uses the session id of
SUBSCRIBE/UNSUBSCRIBE messages rather than looking up all session id's
associated with a user.

Issue: SPR-11325
2014-01-20 15:41:22 -05:00
Rossen Stoyanchev e2feed494b Move "handlers" field to AbstractSubscribableChannel
Move the management of subscribers to the abstract parent class where
it belongs.
2014-01-17 11:24:28 -05:00
Rossen Stoyanchev 4e933b4765 Polish log messages 2014-01-17 11:03:02 -05:00
Sam Brannen 2dfd69bbb3 Stop using deprecated junit.framework.Assert class 2014-01-14 18:19:06 +01:00
Rossen Stoyanchev 4342497305 Add support for custom message converters
The Java and XML config for STOMP WebSocket applications now supports
configuring message converters.

Issue: SPR-11184
2014-01-07 16:16:29 -05:00
Rossen Stoyanchev abb8a93e2f Drop separate user dest property for subscriptions
Before this change DefaultUserDestinationResolver provided a separate
destination prefix property for identifying "user" destinations in
subscription requests as opposed to in sent messages. Such a separate
property should not be needed.

Issue: SPR-11263
2014-01-03 16:44:01 -05:00
Brian Clozel b9c8f47b01 Use OptionalValidatorFactoryBean in Configurers
Configurers and BeanDefinitionParsers should use
OptionalValidatorFactoryBean instead of
LocalValidatorFactoryBean.

The Optional implementation catches and logs setup
exceptions, useful when a validation API is present on
the classpath but not the actual implementation.

Issue: SPR-11272
2014-01-03 22:36:56 +01:00
Brian Clozel 15d7d6d7ab Fix Validator initialization with a no-op implementation
Issue: SPR-11185
2014-01-03 16:02:57 +01:00
Brian Clozel 2c8f670d5f Support Validation in @MessageMapping annotated methods
Payload parameters in @MessageMapping annotated
methods can now also be validated when annotated
with a Validation annotation (@Valid, @Validated...).

A default Validator is registered by the MessageBroker
Configurer, but it is possible to provide a list of custom
validators as well.

Issue: SPR-11185
2014-01-03 15:25:33 +01:00
Rossen Stoyanchev 3b14e974f8 Remove unnecessary copying of headers in GenericMessage
Since the MessageHeaders constructor is makes a copy of the headers and
is protected against a null map, there is no need for the same to be
done in GenericMessage.

Issue: SPR-11268
2014-01-02 11:35:31 -05:00
Rossen Stoyanchev 12fe9174f0 Make ObjectMapper configurable in spring-messaging
Issue: SPR-11279
2014-01-02 11:27:18 -05:00
Juergen Hoeller 85921808b3 MappingJackson2(Http)MessageConverter logs warnings after canRead/canWrite checks
This change involves a general upgrade to Jackson 2.3 in our build.

Issue: SPR-11261
2013-12-29 21:50:43 +01:00
Rossen Stoyanchev 4e5e700213 Add client login/passcode to broker relay
Issue: SPR-11154
2013-12-23 21:40:27 -05:00
Rossen Stoyanchev 0a12f28b58 Introduce StompReactorNettyTcpClient
Issue: SPR-11153
2013-12-23 21:40:27 -05:00
Rossen Stoyanchev e637418010 Update stomp/websocket documentation 2013-12-11 23:36:55 -05:00
Rossen Stoyanchev 92dad1849f Rename @[Path/Destination]Variable in spring-messaging
Issue: SPR-11208
2013-12-11 14:44:57 -05:00
Phillip Webb a1529d498e Fix possible GenericMsgTemplate race condition
Fix a potential race condition with GenericMessagingTemplate's inner
TemporaryReplyChannel class.

Prior to this commit the `hasReceived` member variable was read after
calling `replyLatch.countDown()`.

Issue: SPR-11206
2013-12-11 00:08:34 -08:00
Rossen Stoyanchev fcecd0328a Collapse messaging.simp.handler into messaging.simp 2013-12-06 17:23:31 -05:00
Rossen Stoyanchev 307bf4bede Add messaging.simp.user package 2013-12-06 17:05:29 -05:00