Commit Graph

466 Commits

Author SHA1 Message Date
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