5 Replies Latest reply on Feb 15, 2016 10:35 AM by jdocken RSS
    mbonelli Newbie

    Extension: Event Subscription

    Hello everyone!!!

     

    I'm trying to figure out if it's possible for a Java extension to subscrive to an event which is defined on the ThingWorx IoT Platform. The Idea is that I have an Android app that sends data to the Platform. If somethings happens, for example the CPU Usage is too High I will trigger and event.

     

    Is there any way I can subscrive to the event CPU Usage from my Java Extension so that when the envent occurs my extension automatically runs an handler??

     

    Hope some of you will be able to help me with this!!!

     

    Have a good day everyone!

      • Re: Extension: Event Subscription
        qn Communicator

        Hi,

         

        what do you mean by the Java extension ? Is that a ThingWorx component ?

          • Re: Extension: Event Subscription
            mbonelli Newbie

            Hi,

             

            what I was trying to say is that I wanna make a Java Application for PC that connects to the ThingWork IoT Platform using the Java ThingWorx SDK. The goal is that I want the java application to detect the events that occur on the platform automatically.

             

            Is there any API that allows me to do that in the SDK? is it even possible to do something like this?

             

            The only way I thought of doing it is to define a Virtual Thing in the Java App, define a service and on the Platform bind the Virtual Thing service to the event. I don't know if this is possible or if there is a simplier way to do this, maybe without defining a Virtual Thing.

             

            Thanks for the answer, I really appreciate your help!

             

            Ps. I found some documentation on the ThingWorx SDK APIs at the following link but it doesn't say much on what the APIs actually do. Is there any other place I can find more informations?

             

            http://support.ptc.com/cs/help/thingworx_hc/thingworx_edge/

              • Re: Extension: Event Subscription
                qn Communicator
                  • Re: Extension: Event Subscription
                    mbonelli Newbie

                    Yes I saw it but I can't understand if using the annotations I can only subscribe to the events defined in the Virtual Thing or I can actually subscribe to any event, even the ones that are defined on the platform!

                      • Re: Extension: Event Subscription
                        jdocken Explorer

                        So there's two possible solutions here.  One, you could create a custom extension for Thingworx using the SDK.  This extension could define a new Thing that subscribes (either programmatically or using the annotations) to the events you're interested in on whatever things are on the server.  Since it triggers a service method whenever the event fires, you can give it any behavior you want once it receives the event.

                         

                        Two, if you prefer the separate application solution, then use the Java SDK for Edge development instead.  It's pretty similar to how you describe in that you define a virtual thing to bind to, have it subscribe to events on the other things, and then have your app handle the events whenever it receives the payload data.