Skip navigation
Currently Being Moderated

Example of Java code to publish to Flex?

Jan 13, 2012 2:03 PM

Tags: #java #publish #blazeds #subscribe #tomcat

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?



  • Currently Being Moderated
    Jan 15, 2012 10:42 AM   in reply to TheOriginalEdge

    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: a-3a437432122a8558cdf-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.



    Mark as:
  • Currently Being Moderated
    Jan 16, 2012 8:19 AM   in reply to TheOriginalEdge



    The URL should have been: 2c78ffa-3a437432122a8558cdf-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).



    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points