Search code examples
actionscript-3apache-flexflex3amf

Understanding an AMF Polling call


One of my testers is asking me about an AMF polling that we do in our app:

flex_amf_call(
    "AMF3_call_12",
    "Gateway=http://test.url.com:22000/InventoryTesting/boa/messagebroker/amfpolling",
    "Snapshot=t19.inf",
    MESSAGE,
    "Method=null",
    "TargetObjectId=/7",
    BEGIN_ARGUMENTS,
    "<AMF3><object-externalizable-custom><flex.messaging.messages.CommandMessage>\n  "
    "<destination>InvTestMessaging</destination>\n  <messageId>"
    "4AF91854-F89E-F56D-EE22-4EC8BBAEA4BC</messageId>\n  <timestamp>0</timestamp>\n  "
    "<timeToLive>0</timeToLive>\n  <headers>\n    <entry>\n      <string>"
    "DSEndpoint</string>\n      <string>my-polling-amf</string>\n    </entry>\n    "
    "<entry>\n      <string>DSId</string>\n      <string>{ParamDSValue_string}"
    "</string>\n    </entry>\n  </headers>\n  <body serialization=\"custom\" class="
    "\"flex.messaging.io.amf.ASObject\">\n    <unserializable-parents/>\n    <map>\n "
    "     <default>\n        <loadFactor>0.75</loadFactor>\n        <threshold>"
    "12</threshold>\n      </default>\n      <int>16</int>\n      <int>0</int>\n    "
    "</map>\n    <flex.messaging.io.amf.ASObject>\n      <default>\n        "
    "<inHashCode>false</inHashCode>\n        <inToString>false</inToString>\n      "
    "</default>\n    </flex.messaging.io.amf.ASObject>\n  </body>\n  <correlationId/>"
    "\n  <operation>0</operation>\n</flex.messaging.messages.CommandMessage>"
    "</object-externalizable-custom></AMF3>",
    END_ARGUMENTS,
    LAST);

What does this node mean?

<operation>

They are seeing values of 0 and 5.


Solution

  • A CommandMessage with an operation of 0 is a "subscribe" operation, and is sent automatically when a session is initiated with the server under certain circumstances. A CommandMessage with an operation of 5 is a "ping" operation, and the server must respond with an appropriately populated AcknowledgeMessage or AMF communication is terminated. A CommandMessage is automatically sent by the flash player as needed, and whatever server you're using should be appropriately configured to automatically handle them, or provide hooks for their handling (like with login and logout operations).

    See http://livedocs.adobe.com/blazeds/1/javadoc/flex/messaging/messages/CommandMessage.html for more details about the CommandMessage.