cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way that the 'service invoke complete' trigger can used in a subscription?

SrijithKrish
12-Amethyst

Is there a way that the 'service invoke complete' trigger can used in a subscription?

Hi,

 

I had query whether there is a way that I can call a service, only if another particular service is invoked, i.e. lets say I have a service 'A' and a service 'B'. I want my service 'B' to run or be called or invoked only in the case that the service 'A' is invoked.

Within a mashup there is the service invoke trigger that can be used for this purpose but i need a trigger similar or the same to be used within a subscription to call a service. I do not want to use within the mashup I want to use this trigger at the back end or outside the mashup.

 

Please let me know if there is any way for the same. 

 

Thanks in advance

Srijith

1 ACCEPTED SOLUTION

Accepted Solutions

To my knowledge there is not out of the box  Service invoke Completed event (or other hook).

The Service A is not overridable correct ?

 

View solution in original post

7 REPLIES 7

You can emit an custom Event from Service A and trigger Service B from a subscription on that event.

Regards.

 

PS : Creating and Triggering Custom Events in ThingWorx 

Thank you @smainente 

 

Actually the issue is that the service 'A' is part of an extension imported. Therefore I cannot edit in the service 'A'.

So is there a way in this case?

I am not able to edit the service 'A'. This is the main reason why I need a trigger that can be used so I can or my service 'B' will know that service 'A' have invoked and it is time for 'B' to run.

To my knowledge there is not out of the box  Service invoke Completed event (or other hook).

The Service A is not overridable correct ?

 

Yes you are correct, the service 'A' is not overridable.

 

Is there any work around? Actually my Service 'A' is updating a particular field of a row selected from a stream. So is there a way other than using a timer which check the stream in a given interval of time. My service 'B' is where once the field of the selected row of the stream is updated, just runs a particular logic based on the updated row details and changes, lets say a status or a variable.

 

So I want to run the logic only after the update of the field is down.

@SrijithKrish ,

 

You could create a 'wrapper' service that calls Service A and then fires off a custom event.  Just make sure your wrapper service has all of the same inputs as your Service A:

 

//call serviceA

me.serviceA({
  param1: val1,
  param2: val2
});

//call your event
me.myCustomEvent();

Thank You @nmilleson 

 

So there is no other way to run my service 'B' after the service 'A' without touching service 'A'. Actually the service 'A' is used within a mashup, like on a button click and even that mashup is part of the extension. 

There is no trigger like the service invoke complete that can be used in a subscription right?

 

I shall try with the options suggested. 

Once again thank you for the information. 

@SrijithKrish ,

 

Sometimes, extensions (such as the Azure IoT Hub extension) will have custom events already defined and you can check for that in the Events tab of the thing.  If not, you can get there in a backwards way by incrementing a numeric property every time service A runs and then subscribe to that property change.  That should get you what you need.  Essentially, just create a property on a Thing and create a small service that increments its value by one every time it runs.  In your mashup, attach the ServiceInvokeCompleted event to your new small incrementing service and then on the composer side, just create a subscription to that property change.  

Announcements