Search Engine: Elastic

Article ID: 120170, created on Feb 17, 2014, last review on Jul 14, 2018

  • Applies to:
  • Operations Automation 6.0
  • APS 2.x


I want to run some code when limits for my application's resources are changed in a subscription. For instance, as soon as the customer purchases additional amount of a certain resource, I want to send a notification about it to some external system. How can I do this?


In most cases, if your application needs to keep track of some limits in external system (disk space, traffic, etc.) you should implement counters in customer's resource. Then, if limits for counter change, your resource gets a PUT request with new limits (or, if you use PHP runtime, configure function is executed, more about this in documentation, you may also want to check out the resource counters sample package).

Starting with POA 5.5.7 it is possible to subscribe to a custom event that is triggered when resources limits is changed in POA subscription.

More information about this event is available in documentation.

If you use the PHP runtime library, you can subscribe to these events like this:

  • You need to declare a relation with POA subscription in customer's resource (typically the one that is automatically provided automatically):

     * @link("")
     * @required
    public $subscription;
  • Then, from any function in your code, e.g. from provision(), you can subscribe to limits change event for this subscription:

    $sub = new \APS\EventSubscription("", "onLimitChange");
    $apsc = \APS\Request::getController();
    $apsc->subscribe($this, $sub);
  • Finally, declare the actual event handler with the logic you need executed when limits change. This example will add a log entry:

     * @verb(POST)
     * @path("/onLimitChange")
     * @param("",body)
    public function onLimitChange($event) {
        APS\Logger::get()->debug("Limits changed, and we got a notification about it!");

After subscription limits get changed, onLimitChange function for your resource will be called by APS controller. Note that you will not get limits with the event object, you can fetch the limits using the SubscriptionResource structure in the event handler.

70bf700e0cdb9d7211df2595ef7276ab 717db81efe94e616312b74fb03a5d474 5356b422f65bdad1c3e9edca5d74a1ae caea8340e2d186a540518d08602aa065 e12cea1d47a3125d335d68e6d4e15e07 956c448bddc7e1f3585373687602379f 6f1456866eed87488c0f02b298a741c0

Email subscription for changes to this article
Save as PDF