Custom message interceptors may be used to apply special processing logic to incoming and outgoing AMF messages in their de-serialized Java form. For example, an interceptor can be used to inspect the contents of the incoming message, or to add extra information to the outgoing message.
Custom message processing logic is provided through implementations of the org.springframework.flex.core.MessageInterceptor
interface. These implementations must be configured as Spring beans and then registered through the XML configuration namespace as follows:
<!-- Custom message interceptor configured as a Spring bean --> <bean id="myMessageInterceptor" class="com.foo.app.MyMessageInterceptor"/> <flex:message-broker> <flex:message-interceptor ref="myMessageInterceptor"/> </flex:message-broker>
As of release 1.0.2 of Spring BlazeDS Integration, an additional org.springframework.flex.core.ResourceHandlingMessageInterceptor
interface
is available to use. Interceptors that implement this extended interface receive an additional guaranteed callback after message processing is completed,
whether processing was successful or failed due to an exception being thrown by the Endpoint. This allows the interceptor to clean up any resources that
it may have been using. This interface extends the basic MessageInterceptor
interface, thus it is configured the same way using the
message-interceptor
tag.