4 Replies Latest reply: May 19, 2012 1:51 PM by neoX286 RSS

    Updating ManagedRemoting Entity from Server

    neoX286

      I have a pretty simple task that I need to complete, but it's taken up several days trying to find out how to do it because I can't find any documentation on managed remoting on the server side...

       

      Basically, I have setup Managed Remoting using a flex client, and it works flawlessly, but I need the server to be able to manipulate the managed entities as well.  I want a thread to run on the server that updates the entites in real time based upon a feed coming in from an external server.  If I communicate with the managed remoting service class directly from another java class it persists fine, but it does not update the clients because I am unable to figure out how to pass in a ManagedRemotingMessage to the Managed Remoting service.

       

      Can anyone explain how I can tell my MR service that an entity with ID x needs to commit a change to property y?  It seems like a fairly simple task, and I've tried everything I can find thus far, but nothing seems to get the job done...

       

      my server setup is very simple, just a few entity classes, a hibernate DAO, and a class annotated as such:

       

      @ManagedRemoteService(managedEntities = {com.petzent.agentmonitor.objects.Agent.class}, destinationId="agentService", channels = { "RTMP" })

       

      (and then the appropriate CRUD annotations on the various methods in the class, of course)

       

       

      As far as how to interface with that class from another Java class, I won't even bother posting my code because I don't even know where to begin...

        • 1. Re: Updating ManagedRemoting Entity from Server
          Rohit . Kumar Adobe Employee

          Consider using the ManagedRemotingContext class. It provides ability to submit CRUD operations to Assembler. Take a look at its javadoc at: http://help.adobe.com/en_US/dataservicesjee/4.6/APIReference/flex/data/ManagedRemotingCont ext.html.

           

          Rohit

          • 2. Re: Updating ManagedRemoting Entity from Server
            neoX286 Community Member

            That would be ideal, but I can't get the current context from ManagedRemotingContextImpl.getCurrent(), it simply returns null.  The only time I am able to get the context successfully is when the Flex client calls the service.

             

            This leads me to believe that the problem lies in how I'm communicating with the class.  For good measure, let me show you my classes:

             

             

             

            @ManagedRemoteService(managedEntities = {com.petzent.agentmonitor.objects.Agent.class}, destinationId="agentService", channels = { "RTMP" })

            public class AgentMonitorService

            {

                 public AgentDAO aDAO;

             

                 public AgentMonitorService()

                 {

                      aDAO = AgentDAO.getInstance();

                 }

             

                 /**

                 * Agent Management

                 */

                 @Create

                 public String createAgent(Agent agent)

                 {

                      aDAO.createAgent(agent);

                      return "Created new agent";

                 }

                 @Get

                 public Agent getAgent(Integer agentId)

                 {

                      return aDAO.getAgent(agentId);

                 }

                 @Update

                 public void updateAgent(Agent agent)

                 {

                      ManagedRemotingContext context = ManagedRemotingContextImpl.getCurrent();

                      aDAO.updateAgent(agent);

                 }

                 @Delete

                 public void deleteAgent(Agent agent)

                 {

                      aDAO.deleteAgent(agent);

                 }

            }

             

             

            Okay, pretty simple service.  Now, I've tried several methods of interfacing with it directly:

            • Turning the service into a singleton, and calling it's updateAgent function from AgentMonitorService.getInstance().updateAgent(agent);
            • Having the service pass itself into the class through a memory reference in the service's constructor.
            • Having the service listen for an event containing the updated agent and fire the updateAgent(agent) method as the callback

             

            None of these allow me to grab the current context using ManagedRemotingContextImpl.getCurrent().  In fact, the only time I have ever been able to retrieve the context is when I call the service directly from my Flex client...

            • 3. Re: Updating ManagedRemoting Entity from Server
              Rohit . Kumar Adobe Employee

              I think someone from your team is already in touch with us. We will provide you an example for how to achieve this.

               

              Rohit

              • 4. Re: Updating ManagedRemoting Entity from Server
                neoX286 Community Member

                haha, yea thats me.  Appreciate it!