Is there an easy way to get a managed object of the microservice application with Java SDK? Or how do I get application id using JavaSDK?
Use case:
My microservice reacts to operations. As the operation deviceId id I use the managed object of the microservice application (every micro service gets one). In order to read out all of the pending operations, I need to know the id of this managed object.
With REST API one would get the application ID of the microservice and then use it to query for the managed object representation as follows:
{{url}}/inventory/managedObjects?type=c8y_Application_33175
The ideal way to identify a managedObject would be by externalId (if you don't have the ID already).
ExternalIds are guaranteed to be unique in a tenant so you don't run into the risk that when querying for it you receive more than one result.
Note that in general it is not recommended to "use" internally generated structures for your custom solutions. Especially if they are not documented. You don't know what will happen to these structures in the future (they may be deleted, have different values, ...).
So best you create an own managedObject to represent your microservice and assign an externalId to it. e.g.:
(there is no defined meaning behind the type so you can also put there what you want. The tuple of type and externalId however needs to be unique within the tenant)
Essentially this is the same mechanism that is also used by devices to identify there managedObjects in the platform.