Unsubscribe subscriber in notification 2.0

Product/components used and version/fix level:

Detailed explanation of the problem:

Hey guys

I have a multitenant microservice which uses the notification 2.0 API to subscribe to measurements for devices. The issue is that once the microservice is unsubscribed I would want to delete all the subscriptions and the subscriber so that the platform does not run out of resources.

The issue is that once the microservice is unsubscribed, I have added a hook to capture the microservice unsubscribe event. Now when i try to perform the cleanup, it results in a 401 error. The issue is that by the time i get the unsubscribe event, the microservice credentials are already deleted. How can I automate this? I dont want to manually delete/ run a script before the unsubscribe is called for the microservice.

Arsalan Mahmood Siddiqi

1 Like


I just wanted to chime in here and kind of add a +1 for your issue, since i’m facing a similar problem with cleanup after a tenant has unsubscribed from a microservice. In my case i would still just need to delete some stored managed objects containing configurations, but especially in the context of still open notification 2.0 subscriptions that will never get read this seems like a very important issue.

One solution would be to create a seperate “cleanup” microservice, but it would be nice if the service users could still be used in the context of the unsubscribe event.

Hi guys,

did you check the example to notification 2.0? I haven’t tested it but there it is implemented that on Microservice unsubscribe the subscriptions are revoked. Not sure if the Token API needs a valid authentication or the token is sufficient (again haven’t tested it).

This will not work for any other API that needs full authentication of course.

the solution suggested by stefan works. It does makes sense, the tokenAPi.unsubscribe still works since it uses the token and not the service credentials. Even when the service credentials are gone, the call works. As per the comments (in the example code on github), even an expired token works to unsubscribe (which i did not try yet)

Arsalan Mahmood Siddiqi

1 Like