4 Replies Latest reply on Jan 17, 2012 10:46 AM by TheOriginalEdge

    Example of Java code to publish to Flex?


      I have Tomcat talking to Flex using BlazeDS, but the conversation is one way.  Flex has to initialize it.


      I want to be able to publish to Flex from Java (in Tomcat).  There are nice examples of the Flex code needed to catch this, and how to subscribe and all, but I cannot find any Java snippets that show how one initiates this conversation on that end.


      Can anyone point me at some sample code for this?



        • 1. Re: Example of Java code to publish to Flex?
          Rohit . Kumar Adobe Employee

          Well, you are using Flex to talk to BlazeDS that is deployed on Tomcat. What version of BlazeDS are you using?


          Can you elaborate more on "Flex has to initalize it"? You have a Flex client, so you need to register interest (subscribe) to messaging destination from Flex.


          If you are asking:

          1. How do I push messages from the server (Java) to the Flex then take a look: help.adobe.com/en_US/dataservicesjee/4.6/Developing/WS9d22440892c78ffa-3a437432122a8558cd f-8000Update.html.
          2. If you are asking how do I setup subscription from a Java, then BlazeDS does not support it (unless ofcourse you are using a JMS destination -- see documentation for how to that). The latest release of Data Services v4.6, ships with various remoting and messaging clients in Java, Andriod, iOS, HTML5/JS and lots of other features, that allow you to do this.


          Can you clarify what exactly you need? Hope that helps.



          • 2. Re: Example of Java code to publish to Flex?
            TheOriginalEdge Level 1

            I am asking question #1.  How do I push messages from a Java server to Flex.


            I am using the most recent version of BlazeDS and a very recent version of Tomcat.  BlazeDS was downloaded within the last couple of days.  Tomcat is 6.0.29.


            The link you posted is giving me a 404 Not Found error.


            Consider for instance the example in Tour de Flex under Flex Data Access / Messaging Service / Basic Authentication - with Tomcat (NEW).  It describes very nicely what to do on the Flex side, and what to do with the Tomcat configuration files.  I just don't know what to do in the Java itself to cause the subscription to be invoked in Flex. 


            I'm guessing that this is a very simple question.  It may be one of those that is so simple, people who already know how to do it are assuming that everyone else does, too.



            • 3. Re: Example of Java code to publish to Flex?
              Rohit . Kumar Adobe Employee



              The URL should have been: http://help.adobe.com/en_US/dataservicesjee/4.6/Developing/WS9d22440892c78ffa-3a437432122a 8558cdf-8000Update.html


              With respect to subscribing from java, see how the consumer subscribe happens from flex (the source code for Consumer class is viewable in FB). You will have to basically emulate that in your java code. Roughly it means doing the following:

              1. Authenticate your self, and ensure that user principal gets set on the FlexContext.

              2. Create a Subscription Command message (with appropriate values like client id etc.) and pass to the MessageBroker.routeCommandToService(subscriptionCmd, null).



              • 4. Re: Example of Java code to publish to Flex?
                TheOriginalEdge Level 1

                Works like a charm.  That URL shows just what I needed.


                Thank you!