The initialization of the MessageBroker
by the MessageBrokerFactoryBean
logically consists of two phases:
Parsing the BlazeDS XML configuration files and applying their settings to a newly created MessageBroker
Starting the MessageBroker and its services
A special MessageBrokerConfigProcessor
callback interface is provided that allows custom processing to be done on the
newly created MessageBroker after each phase, before it is made available for request processing. This interface is used internally
by Spring BlazeDS Integration, but is also available for general use in advanced programmatic introspection and customization of the
MessageBroker
. A custom MessageBrokerConfigProcessor
can be configured as a Spring bean and then registered with the
MessageBrokerFactoryBean
via the config-processor
tag. For example, given a trivial implementation
to log some additional info about the MessageBroker:
package com.example; import org.springframework.flex.config.MessageBrokerConfigProcessor; import flex.messaging.MessageBroker; import flex.messaging.services.RemotingService; public class MyDestinationCountingConfigProcessor implements MessageBrokerConfigProcessor { public MessageBroker processAfterStartup(MessageBroker broker) { RemotingService remotingService = (RemotingService) broker.getServiceByType(RemotingService.class.getName()); if (remotingService.isStarted()) { System.out.println("The Remoting Service has been started with " +remotingService.getDestinations().size()+" Destinations."); } return broker; } public MessageBroker processBeforeStartup(MessageBroker broker) { return broker; } }
This class could be configured and registered with the MessageBroker
as follows:
<flex:message-broker> <flex:config-processor ref="myConfigProcessor" /> </flex:message-broker> <bean id="myConfigProcessor" class="com.example.MyDestinationCountingConfigProcessor" />