1 Reply Latest reply on Oct 2, 2009 9:43 AM by flexrocker

    mx:Consumer doesn't subscribe to JMS-Grails

    flexrocker
      I am creating a very simple flex application where I have one button on click on which consumer subscribe to a JMS topic which is published via Grails application to ActiveMQ.
      I am not what causing a problem but I whenever I click th button in flex I get to know the consumer is not subscribed to topic.
      Below is the mxml code:
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
               >
              <mx:Script>
                      <![CDATA[
                              import mx.messaging.config.ServerConfig;
                              import mx.messaging.ChannelSet;
                              import mx.controls.Alert;
                              import mx.messaging.events.MessageFaultEvent;
                              import mx.messaging.events.MessageEvent;
                              private function initApp():void{
                                      consumer.destination = "activejmsmqcontopic";
                                      consumer.channelSet = ServerConfig.getChannelSet("grails-amf");
                                      //consumer.selector="type='Person'";
                                      consumer.subscribe();
                                      Alert.show("done " + consumer.subscribed);
                              }
                             
                              private function messageHandler(e:MessageEvent):void{
                                      Alert.show(e.message.body.toString());
                              }

       

                              private function faultHandler(e:MessageFaultEvent):void{
                                      Alert.show(e.message.faultString);
                              }
                      ]]>
              </mx:Script>
             
              <mx:Consumer id="consumer" message="messageHandler(event)"
               fault="faultHandler(event)"  />
              <mx:Button x="145" y="217" label="subscribe" click="initApp()"/>
      </mx:Application>

       

       

      Here is services-config.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <services-config>

       

          <services>
          <service id="message-service" class="flex.messaging.services.MessageService" messageTypes="flex.messaging.messages.AsyncMessage">
              <adapters>
                  <adapter-definition id="jms" class="flex.messaging.services.messaging.adapters.JMSAdapter" default="true"/>
              </adapters>

       

       

              <destination id="activejmsmqcontopic">
                  <properties>
                      <jms>
                          <message-type>javax.jms.ObjectMessage</message-type>
                          <connection-factory>ConnectionFactory</connection-factory>
                          <destination-jndi-name>activejmsmqcontopic</destination-jndi-name>
                          <delivery-mode>NON_PERSISTENT</delivery-mode>
                          <message-priority>DEFAULT_PRIORITY</message-priority>
                          <acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode>
                          <transacted-sessions>false</transacted-sessions>
                          <initial-context-environment>
                              <property>
                                  <name>Context.PROVIDER_URL</name>
                                  <value>tcp://localhost:61616</value>
                              </property>
                              <property>
                                  <name>Context.INITIAL_CONTEXT_FACTORY</name>
                                  <value>org.apache.activemq.jndi.ActiveMQInitialContextFactory</value>
                              </property>
                              <property>
                                  <name>topic.activejmsmqcontopic</name>
                                  <value>activejmsmqcontopic</value>
                              </property>            
                          </initial-context-environment>
                      </jms>
                  </properties>
                  <channels>
                              <channel ref="grails-amf"/>
                  </channels>
                  <adapter ref="jms"/>
              </destination>

       


          </service>

       


              <service id="grails-remoting-service" class="flex.messaging.services.RemotingService">
                  <adapters>
                      <adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter" default="true"/>
                  </adapters>
              </service>

       

              <!--
              Grails bootstrap service. This service registers the SpringFactory and
              creates destinations for the annotated Grails services.
              -->
              <service id="grails-service" class="org.codehaus.groovy.grails.plugins.flex.GrailsBootstrapService"></service>

       

              <!--
              Application level default channels. Application level default channels are
              necessary when a dynamic destination is being used by a service component
              and no ChannelSet has been defined for the service component. In that case,
              application level default channels will be used to contact the destination.
              -->  
              <default-channels>
                 <channel ref="grails-amf"/>
              </default-channels>
          </services>

       

          <channels>
              <channel-definition id="grails-amf" class="mx.messaging.channels.AMFChannel">
                  <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
                  <properties>
                      <polling-enabled>true</polling-enabled>
                      <polling-interval-seconds>4</polling-interval-seconds>
                  </properties>
              </channel-definition>
          </channels>

       

          <logging>
              <target class="flex.messaging.log.ConsoleTarget" level="Debug">
                  <properties>
                      <prefix>[BlazeDS] </prefix>
                      <includeDate>false</includeDate>
                      <includeTime>false</includeTime>
                      <includeLevel>false</includeLevel>
                      <includeCategory>false</includeCategory>
                  </properties>
                  <filters>
                      <pattern>Endpoint.*</pattern>
                      <pattern>Service.*</pattern>
                      <pattern>Configuration</pattern>
                  </filters>
              </target>
          </logging>

       

      </services-config>

       


      I have JMS & Flex plugins installed in grails application.
      I can see the topic in ActiveMQ console which is published via Grails application.

       


      Any help is really appericated, but it is quite urgent.

       

      Thanks in advance.