4 Replies Latest reply on Sep 12, 2009 10:46 AM by PENNY506

    Problem with Flex Messaging using JMS

      Hi Friends,

      I have started working on flex recently and got problem while implementing Flex Chat application using JMS adaptor. I was able to successed making it work with Flex Action Script, but I need have my chat application with JMS. Here I am posting the details about how I have done the chat application for JMS.

      I am using Tomcat 5.5.25, Flex 2 and ActiveMQ 4.4 M4.

      my WEB-INF/flex/messaging-config.xml with destination as
      <adapter-definition id="jms" class="flex.messaging.services.messaging.adapters.JMSAdapter" default="true"/>

      <destination id="chat-topic-jms">




      <channel ref="my-rtmp"/>

      <adapter ref="jms"/>


      my WEB-INF/classes/jndi.properties file

      java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory

      # use the following property to configure the default connector
      java.naming.provider.url = tcp://localhost:61616

      # use the following property to specify a class path resource or URL
      # used to configure an embedded broker using the XML configuration file
      #brokerXmlConfig = file:src/conf/sample-conf/default.xml

      # use the following property to specify the JNDI name the connection factory
      # should appear as.
      connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactory

      # register some queues in JNDI using the form
      # queue.[jndiName] = [physicalName]
      # queue.MyQueue = example.MyQueue

      # register some topics in JNDI using the form
      # topic.[jndiName] = [physicalName]
      # topic.MyTopic = example.MyTopic
      topic.FlexChatTopic = chat.Topic

      in my web.xml file I have added

      <listener-class>com.silverisland.servlet.listener.ActiveMQBrokerStartListener</listener-c lass>

      finally my mxml file

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"


      import mx.messaging.messages.AsyncMessage;
      import mx.messaging.messages.IMessage;
      import mx.controls.Alert;

      private function send():void
      var message:IMessage = new AsyncMessage();
      Alert.show("msg dst >> "+message.toString());
      message.body.chatMessage = msg.text;
      msg.text = "";

      private function messageHandler(message:IMessage):void
      Alert.show("msg recived >> "+log.text);
      log.text += message.body.chatMessage + "\n";


      <mx:Producer id="producer" destination="chat-topic-jms"/>
      <mx:Consumer id="consumer" destination="chat-topic-jms" message="messageHandler(event.message)"/>

      <mx:Panel title="Chat" width="100%" height="100%">
      <mx:TextArea id="log" width="100%" height="100%"/>
      <mx:TextInput id="msg" width="100%" enter="send()"/>
      <mx:Button label="Send" click="send()"/>


      Please help me.
      Thanks in advance


        • 1. Re: Problem with Flex Messaging using JMS
          Mete Atamel Level 1
          What exactly is the problem? Turn on debug logging on the server and let us know if you see any exceptions/errors.
          • 2. Re: Problem with Flex Messaging using JMS
            itz_Kumar Level 1
            Hi Mete Atamel,

            The problem here is I am not able to send the message to the server. There is no error / exception raised.

            The same code is working fine when I was using "Flex Messaging service" with the following changes.

            my WEB-INF/flex/messaging-config.xml with destination as
            <adapter-definition id="actionscript" class="flex.messaging.services.messaging.adapters.ActionScriptAdapter" default="true" />

            <destination id="chat-topic-jms">


            <channel ref="my-rtmp"/>


            But when I changed the same code to make it work for JMS adapter, it is not even sending the message to the server itself. I was not able to understand the actual problem. Can u please tell me where I was going wrong.

            Thanks in advance.

            • 3. Re: Problem with Flex Messaging using JMS
              Mete Atamel Level 1
              It's hard to tell what might be wrong. You should turn on server side debug logging on. Look into services-config.xml, there's a logging section. Make sure the level is set to "Debug", run your test again and see what server side logging you get. If you cannot send messages, there should be more info in the debug log for why that is happening.
              • 4. Re: Problem with Flex Messaging using JMS

                Did you ever get this working?  I'm attempting to do a similar thing with Jrun4 -

                There is a good article here that might help as your configuration is similar.