Announcement Announcement Module
Collapse
No announcement yet.
Own Adapter for Flex Messaging Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Own Adapter for Flex Messaging

    Hey Guys,

    There is a problem and I hope that you can help me :-).

    I have coded an Adapter for flex messaging:

    Code:
    public class FlexDeviceDataListener extends ServiceAdapter implements DeviceDataListener {
    
        private String data = "Test";
    
        public void newDataReceived(String deviceId) {
            /*MessageBroker msgBroker = MessageBroker.getMessageBroker(null);
            String clientID = UUIDUtils.createUUID();
                // creating a new async message.
    
                AsyncMessage msg = new AsyncMessage();
                // setting the destination for this message.
    
                msg.setDestination("DataPush");
                msg.setClientId(clientID);
                msg.setMessageId(UUIDUtils.createUUID());
                msg.setBody(deviceId);
                msg.setHeader("topic", "flex.messaging.unknownData");
                msgBroker.routeMessageToService(msg, null);*/
        }
    }
    I have declared it in the spring config like this:

    Code:
    <bean id="dataPushAdapter" class="org.springframework.flex.core.ManageableComponentFactoryBean">
            <constructor-arg value="rm.proemion.ui.flex.commons.FlexDeviceDataListener"/>
        </bean>
    And for the message-destination I hav added this:

    Code:
    <flex:message-destination id="dataPush" channels="my-streaming-amf,my-polling-amf" 
                                  service-adapter="dataPushAdapter"/>
    Now the problem ;-):

    If the server gets new data the newDataReceived method in the FlexDeviceDataListener class will trigger. This java method should route the message to the flex client which is subscribed. The problem is that the messageBroker that I want to get to route the message ist null. Its throws a NullPointerException everytime it try to get the messageBroker instance.

    What goes wrong there??
    Do I have to declare an extra MessageBroker in spring config ??

    THX

  • #2
    I have solved the problem:

    In the flex.messages.MessageBroker Class the method getMessageBroker(String id) required a default messageBroker id. If you call getMessageBroker(null) the inbuild default MessageBroker id is "__default__", but with blazeds spring integration it is _messageBroker. So you have to call getMessageBroker("_messageBroker")

    Comment


    • #3
      You might prefer to use a constant for that. If so, you can use this:
      Code:
      org.springframework.flex.config.BeanIds.MESSAGE_BROKER

      Comment

      Working...
      X