BlazeDS,LiveCycle DS Configuration

Configuration of the destinations of messaging is done in the messaging-config.xml file. The file looks like this.

<?xml version="1.0" encoding="UTF-8"?>
<service id="message-service">
        <adapter-definition id="actionscript"
        <adapter-definition id="jms" default="false"/>

        <channel ref="my-polling-amf"/>

    <destination id="stock-topic-jms">
        <adapter ref="jms"/>

There are a few things to notice here. You can see the message type, the connection factory and destination using JNDI. The initial context environment is coming from ActiveMQ and the provider url should be familiar by now.

The client

The final step is the flex client. Flex has very good support for consumers and producers. On the client I am mainly using Mate, which is a flex event driven framework. It has support for messaging as well through the MessageHandlers tag. It turns however that flex 3.2 has a problem together with Mate. Check this blog post for the way it should work and go through the comments to get an idea why it does not work. Because of this problem I had to take a slight detour. The most important part is very easy though. The following code block shows the most important part of configuring a consumer.

<mx:Consumer id="consumer" destination="stock-topic-jms" message="messageHandler(event)"
acknowledge="acknowledgeHandler(event);" fault=" faultHandler(event)"/>

Then finally you need to login, this can best be done in the creationComplete handler.

private function logon():void {

That is it, now you just have to implement the three methods that are attached to the consumer. I’ll show the messageHandler implementation as the last piece of the puzzle.

private function messageHandler(event:MessageEvent):void {
    var stock:Stock = event.message.body as Stock;
    var updateEvent:StockEvent = new StockEvent(StockEvent.UPDATE_STOCKITEM_EVENT);
    updateEvent.stock = stock;

Notice that by using the ObjectMessage type, the body of a message is a stock object.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s