3 Replies Latest reply on Jul 26, 2007 9:03 AM by Mete Atamel

    LCDS and JMS on weblogic9

    stephflex
      Hello,

      I need some clues about how LCDS work with JMS messaging.
      I've setup a j2ee application which use a JMS queue on my weblogic server. I have a message driver bean to catch messages and dispatch it to other class to update some data. Everything work fine.

      What I want to do is build a flex UI to monitoring JMS message that come on my queue for testing purpose.
      So I setup a flex application with live cycle data and configure end point to connect to my queue using rtmp.

      What am I facing now is that I am not receiving any message from my queue but when I send some data from the flex UI my MDB is catching it correctly.

      So my questions are :
      • Do I need to go throw my MDB and add this code on the onMessage() method ? :
        MessageService msgService = (MessageService)service;
        msgService.pushMessageToClients(message, true);
        msgService.sendPushMessageFromPeer(message, true);
      • flex.messaging.services.messaging.adapters.JMSAdapter should not have this role to notify client on messages coming instead usind a MDB

        Here the code I'm usinf for the flex UI. It's pretty simple :
      quote:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application creationComplete="consumer.subscribe();" xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns:comp="components.*" layout="absolute" viewSourceURL="srcview/index.html">
      <mx:Script>
      <![CDATA[
      import mx.messaging.*;
      import mx.messaging.messages.*;
      import mx.messaging.events.*;
      private function messageHandler(event:MessageEvent):void {
      // Handle message event.
      msgTxt.text = "Message received";
      msgTxt.text = event.toString();
      }
      private function acknowledgeHandler(event:MessageAckEvent):void{
      // Handle message event.
      msgTxt.text = event.acknowledgeMessage.toString();
      }
      private function faultHandler(event:MessageFaultEvent):void {
      // Handle fault event.
      msgTxt.text = event.faultString.toString();
      }
      private function sendMessage():void {
      var message:AsyncMessage = new AsyncMessage();
      message.body = userName.text + ": " + msg.text;
      producer.send(message);
      }
      ]]>
      </mx:Script>
      <mx:Consumer id="consumer" destination="onjJMS"
      message="messageHandler(event)"
      fault="faultHandler(event)"/>
      <mx:Producer id="producer" destination="onjJMS"
      acknowledge="acknowledgeHandler(event)"
      fault="faultHandler(event)"/>

      <mx:VBox x="0" y="0" height="100%" width="100%">
      <mx:Label text="Message received" color="#fe9301" fontWeight="bold"/>
      <mx:TextArea width="100%" height="100%" id="msgTxt"/>
      <mx:Label text="User" color="#fe9301" fontWeight="bold"/>
      <mx:TextInput id="userName" width="100%"/>
      <mx:Label text="Message" color="#fe9301" fontWeight="bold"/>
      <mx:TextInput id="msg" width="100%"/>
      <mx:Button label="Send" click="sendMessage()"/>
      </mx:VBox>

      </mx:Application>

      And here it is my messaging-config.xml
      quote:

      <?xml version="1.0" encoding="UTF-8"?>
      <service id="message-service"
      class="flex.messaging.services.MessageService">

      <adapters>
      <adapter-definition id="actionscript" class="flex.messaging.services.messaging.adapters.ActionScriptAdapter" default="true" />
      <adapter-definition id="jms" class="flex.messaging.services.messaging.adapters.JMSAdapter"/>
      </adapters>

      <destination id="onjJMS">

      <adapter ref="jms"/>

      <properties>

      <jms>
      <destination-type>Queue</destination-type>
      <message-type>javax.jms.ObjectMessage</message-type>
      <connection-factory>java:comp/env/jms/QCF</connection-factory>
      <destination-jndi-name>java:comp/env/jms/ONJQUEUE</destination-jndi-name>
      <destination-name>SimpleMessageBean</destination-name>
      <delivery-mode>NON_PERSISTENT</delivery-mode>
      <message-priority>DEFAULT_PRIORITY</message-priority>
      <acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode>
      <transacted-sessions>false</transacted-sessions>
      </jms>

      <network>
      <session-timeout>0</session-timeout>
      <throttle-inbound policy="ERROR" max-frequency="50"/>
      <throttle-outbound policy="REPLACE" max-frequency="500"/>
      </network>

      <server>
      <max-cache-size>1000</max-cache-size>
      <message-time-to-live>0</message-time-to-live>
      <durable>true</durable>
      <durable-store-manager>
      flex.messaging.durability.FileStoreManager
      </durable-store-manager>
      </server>
      </properties>

      <channels>
      <channel ref="my-rtmp"/>
      <channel ref="my-polling-amf"/>
      </channels>
      </destination>

      </service>


      Regard's
        • 1. Re: LCDS and JMS on weblogic9
          Mete Atamel Level 1
          First, why are you using a MDB and JMSAdapter at the same time? I mean if you want to use JMSAdapter to get JMS messages and pass it to Flex clients, then that's fine by itself, but I don't understand why you're introducing the MDB into the equation.

          Second, in JMS queues, there is only JMS sender and 1 JMS receiver. When a message is sent from the JMS server, only 1 JMS receiver is supposed to receive it. So when you're using MDB and JMSAdapter at the same time to listen for the same queue, it's not surprising that only MDB receives the message.
          • 2. Re: LCDS and JMS on weblogic9
            stephflex Level 1
            Thank you for your posting Mete,

            You completely right !! I should use a topic instead because my MDB is the only receiver for my Queue.
            I've just testing without the Strut MDB app deployed and it's working however it seem that multiple flex client with consumer.suscribe() to the same queue don't raise any error and the message dispatching doesn't follow any rules about which client going to receive the message.
            • 3. Re: LCDS and JMS on weblogic9
              Mete Atamel Level 1
              You're right that there're no set rules for a JMSAdapter listening on a queue and multiple Flex clients using that JMSAdapter. In that case, only one of those Flex clients will receive the message. That's why it doesn't make much sense to use JMSAdapter with JMS queues right now. However, in the next release, there will be some enhancements to give people more control over the delivery of JMS messages from JMS to Flex Clients. So, stay tuned!