MicroserviceSubscription AddedEvent vs MicroserviceSubscriptions InitializedEvent

What product/components do you use and which version/fix level are you on?

C8Y MS SDK 1009.0.12

What are you trying to achieve? Please describe it in detail.

I wonder what the difference is between MicroserviceSubscriptionAddedEvent vs MicroserviceSubscriptionsInitializedEvent and when to use which one. I found Create tenant option if it is not presented. (Java microservice SDK) which explains the MicroserviceSubscriptionAddedEvent quite good, but not the difference.

I have a suspicion based on the sparse documentation (com.cumulocity.microservice.subscription.model (Cumulocity Microservice SDK)), but I don’t want to use something wrong so I’d like to get the experts input here.

Thanks a lot!
Michael

Hi Michael,
the difference is following:

MicroserviceSubscriptionsInitializedEvent: This event is only triggered once, after the microservice is starting up and initialised its subscriptions. This is independent on the number of subscribed tenants.

MicroserviceSubscriptionAddedEvent: This event is triggered any time a tenant is subscribed to a microservice:

  1. After the microservice started up, one event for each subscribed tenant.
  2. When a tenant is subscribed to it any time later during runtime. Same applies for the MicroserviceSubscriptionRemovedEvent in case tenants are unsubscribed.

In general the difference is only useful in a multi-tenant microservice (isolation level MULTI_TENANT). A single tenant (PER_TENANT) microservice instance is anyway shut down after the single tenant is unsubscribed and only starts if the single tenant is subscribed, hence in PER_TENANT mode there is no difference. Nevertheless the MicroserviceSubscriptionRemovedEvent could be useful here too.

Regards Kai

2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.