4 Replies Latest reply on Oct 28, 2009 2:43 PM by olegkon

    JMS Messaging configuration

    olegkon Level 1

      Hi,

       

      I wrote a Flex app (prototype of JMS dashboard), which:

      1) every 3 secs generates JMS message with some random number and sends it to JMS queue;

      2) receives that message from JMS queue, gets that number and displays it in the LineChart component.

       

      In service-config.xml I specify localhost in messagebroker URL, because I deploy on JBoss5.1 using its JMS (similar to ActiveMQ).

       

      When I deploy my Flex app on JBoss on my PC, it works just fine,

      but if I deploy on JBoss on Linux server, messaging does not work.

      Both JBoss servers have exactly the same configuration.

       

      The only difference I see is that in both cases I download that Flex App

      to PC (i.e. from the same computer), but in case of Linux it is not the same computer.

      Can that be the problem ? 

       

      Do I have to specify the server name instead of localhost in messagebroker URL?

       

      Or do I need a crossdomain file ?

       

      Using Flex3.2, BlazeDS 3.2,  JDK1.6  (Win XP or OpenSuse Linux 10.3), IE9 or FireFox3.

       

      Please help !

       

      TIA,

      Oleg.

        • 1. Re: JMS Messaging configuration
          paul.williams Level 4

          You shouldn't need to hardcode your server name and port into services-config.xml. The {server.name} and {server.port} are inferred from the url of the SWF and substituted at runtime. There is more on the subject here:

           

          http://coenraets.org/blog/2009/03/externalizing-service-configuration-using-blazeds-and-lc ds/

          • 2. Re: JMS Messaging configuration
            olegkon Level 1

            Very interesting !

             

            So what you are saying is that I should not hardcode "localhost", but use {server.name} and {server.port} instead ?

             

             

            Is this also applicable to other parts of  configuration, like JNDI in Initial Context URL in messaging-config.xml:

            <initial-context-environment>
                  <property>
                        <name>Context.INITIAL_CONTEXT_FACTORY</name>
                        <value>org.jnp.interfaces.NamingContextFactory</value>
                   </property>
                   <property>
                        <name>Context.PROVIDER_URL</name>                      
                        <value>jnp://localhost:21099</value>   //have few instances of JBoss on  Linux box, so I put 21099 instead of standard 1099, 8080->28080
                   </property>                   
            </initial-context-environment>

            or in Java code for properties passed to InitialContext :

            props.setProperty(Context.PROVIDER_URL, "jnp://localhost:21099");

             

            I will try that now.

            Also will try to install Firefox & Flash plugin on Linux and play with it.

             

            Thank you,

            Oleg.

            • 3. Re: JMS Messaging configuration
              paul.williams Level 4

              As described in the link:

               

              "When you then compile your application, the required values of services-config.xml are baked into the SWF. In other words, services-config.xml is read at compile time and not at runtime as you may have thought intuitively. To abstract things a little bit, you can use tokens such as {server.name}, {server.port}, and {context.root} in services-config.xml. However, {context.root} is still substituted at compile time, while {server.name} and {server.port} are replaced at runtime using the server name and port number of the server the SWF was loaded from (which is why you can’t use these tokens for AIR applications)."

               

              The motivation for using {server.name} and {server.port} tokens is to avoid having to recompile your swf if you change its deployment url. The constraint is that the server name and port number of the swf must match those of the message broker url. If this constraint is not satisfied, then you could use the alternative externalisation method described in the link.

               

              None of the configuration you mentioned (jndi, initial context url, etc) are required by the client so they are not compiled into the swf. They relate to the configuration of the server and can be changed easily without any recompilation by editing the config files.

               

              .

              1 person found this helpful
              • 4. Re: JMS Messaging configuration
                olegkon Level 1

                That is good.

                 

                I put {server.name} only into services-config for messagebroker [hardcoded the port 28080 as it's non-standard]

                and  was able to run it on both PC & Linux JBoss.

                 

                Now a little bit of an extension question:

                1) I need to convert that SWF into AIR project.  It says "you can’t use these tokens for AIR applications".

                So what do I have to put into that services-config for messagebroker, "localhost" or "mylinuxserver" ?

                 

                2) Also regarding AIR.

                I will need users to download that AIR (originally) from Linux JBoss server and install it on their PC.

                Is it easy to install AIR app on Linux ? (or needs RPM, root access, etc?)  had lots of headaches installing Firefox and Flash on Linux.