The BlazeDS Integration documentation (as of 1.0.3) encourages the decoupling of the BlazeDS channel configuration in the client from the channel config in the server. While in many cases this is the right thing to do, in other cases developers may prefer to define the configuration in one place (in services-config.xml) and compile the client(s) against service-config. Developers using the joint Java-Flex project support in Flash Builder, for example, (provided under the hood by Eclipse WTP) will find this approach convenient, especially in the early stages as they are learning the framework.
Unfortunately neither the BlazeDS Integration documentation (as of 1.0.3) nor Adobe's LCDS documentation (as of 3.0) provides an example of how to define an application-wide default channel set in services-config.xml.
You can define a default application-wide channel in service-config.xml as follows:-
Code:
<?xml version="1.0" encoding="UTF-8"?>
<services-config>
<services>
<default-channels>
<channel ref="longpollamf"/>
</default-channels>
</services>
<channels>
<channel-definition id="longpollamf" class="mx.messaging.channels.AMFChannel">
<endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/longpollamf" class="flex.messaging.endpoints.AMFEndpoint"/>
<properties.... />
</channel-definition>
</channels>
</services-config>
With an application-wide default channel set in services-config you can define mx:RemoteObjects, mx:Producers and mc:Consumers in the client as follows without having to specify a channel configuration explicitly. (This assumes the client is compiled against service-config.xml which has been the default in Flex/Flash Builder for projects set up with BlazeDS support since WTP support was introduced in v2.0.1).
Code:
<mx:Consumer id="notificationConsumer" destination="notification" />
and allows a simpler Spring config as follows:-
Code:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:flex="http://www.springframework.org/schema/flex"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/flex http://www.springframework.org/schema/flex/spring-flex-1.0.xsd">
<flex:message-broker>
<flex:remoting-service />
<flex:message-service />
</flex:message-broker>
<flex:message-destination id="notification" />
<bean id="notificationServiceMessageTemplate" class="org.springframework.flex.messaging.MessageTemplate"/>
</beans>
Additionally remoting endpoints annotated as Spring BlazeDS endpoints work too without having to specify a channel explicitly as follows:
Code:
@Service
@RemotingDestination
public class TradeService
{
....
}
I think the section in the BlazeDS Integration documentation that discusses this topic would be better with an example of configuring an application-wide default channel set in service-config (even if you choose to discourage its use) as it significantly reduces the complexity of the Spring BlazeDS config in the simple case.