2 Replies Latest reply on Jul 28, 2008 12:42 PM by Cr99

    blazeds messaging header problem

    Cr99 Level 1
      I have been using blazeds messaging for several weeks now it thought it was working fine. But somehow it's losing information now.

      Here is some of the code I've been using to create the message:

      var message:IMessage = new AsyncMessage();
      var arc:ArrayCollection = chartList.getChartList();
      trace(" send chartLIST len ", arc.length);
      message.headers["charts"] = arc;

      The trace shows that the charlist has 3 elements when sent.

      But in the java method which receives the code it comes up with a list of size zero:

      public Object invoke(Message message) {

      Map info = message.getHeaders();
      ArrayList chartList = (ArrayList)info.get("charts");
      System.out.println(" CHART LIST Size: "+chartList.size());
      // more code below to delete chart...


      The ArrayCollection to ArrayList works in other parts of the code. I have no idea why it's failing at this point and again this code was working before.
        • 1. blazeds messaging header problem
          Cr99 Level 1
          In further debugging, I've found that it seems that if I add certain things, say Strings to the ArrayCollection, the header will get the values. So it must be the objects in the ArrayCollection which are somehow showing up as empty in the java decoding of the message. But I really don't know what could be causing it to fail like this with the current ArrayCollection. It is an array of ChartObjects which are actually created in Java, passed to flex and displayed in flex. Then when I want to delete the same objects, I pas the same array of ChartObjects which I created when the charts were first pushed from java to flex

          • 2. Re: blazeds messaging header problem
            Cr99 Level 1
            Ok, so well no one responded...In case anyone in the future stumbles into this problem, I think I've found out the problem.

            Since I was deleting this info, I was sending the delete request to my java code (which read the array of ChartObjects and deleted each one using the name of the chart to delete it from the database) and then immediately afterwards, I was deleting the same data structures in my flex code.

            Apparently Flex doesn't copy the data and send it, but sends the actual data or a reference to it. So even though my lines to remove the data were after the database delete request, by the time the database deletion got executed in the system, the data had been erased by flex. It seems like Flex does not handle events in sequential order as it is written in the code. I've run into this in other places with messaging and flex. So I'll just have to rewrite the logic to take into account this behavior.