I am developing a microservice that needs to listen to the device created/deleted notification. Here are the steps I implemented using Notification 2 API with JAVA SKD:
Create a subscription with context = “tenant”, in the filter, I set the api: “managedobjects” (the document stated that with tenant context, I need to set the filterType, but I don’t know what type should be set, so I didn’t set it. Without filterType, the subscription is still created successfully). The subscription looks like this:
{
“context”: “tenant”,
“subscription”: “subscription01”,
“filter”: {
“apis”: [“managedobjects”]
}
}
Go to the platform and try to create/delete a device
After step 2, I can’t see any notifications received.
Note: I tried to subscribe to “mo” context and I can receive measurements/alarms notification.
Error messages / full error message screenshot / log file:
No error, I just can’t see any notifications about device created/deleted
Question related to a free trial, or to a production (customer) instance?
Sorry, it’s just my mistake when copying the example. Below is the response when I query from API:
{
“nonPersistent”: false,
“subscriptionFilter”: {
“apis”: [
“managedobjects”
]
},
“context”: “tenant”,
“self”: “domain/notification2/subscriptions/977163”,
“subscription”: “TenantSubscription”,
“id”: “977163”,
“source”: {
“self”: “domain/inventory/managedObjects/my-tenant-id”,
“id”: “my-tenant-id”
}
}
Of course, I’ve done steps 2 and 3, the websocket is ready.
Actually, I’ve made 2 subscriptions, 1 for “mo” context and 1 for “tenant” context, then created 2 tokens and 2 websocket for them.
I can receive the notification from “mo” context, but only “tenant” context is not working.
That’s hard to debug without the code.
But I could guess: Did you re-use the same subscription name and switched from tenant context to mo (for testing)?
If so this could lead issues when the subscription was in the mo context first but now changed to tenant. Try a new subscription name and subscriber name for the tenant.
If this is still not working afterwards I guess there is something wrong with the websocket message handler not receiving the tenant messages for managed objects.
I am using 2 different names for 2 contexts. And FYI, with “tenant” context, I can receive notification for alarm. I think there is a bug with manageobject.
Hi Khiem, I can’t reproduce your problem. I created two subscriptions and two websocket at the same time but in Python. One with ‘tenant’ context for managedObjects and alarms, one with ‘mo’ context for alarms. They have different subscription names and subscriber names. Both of them can receive expected notifications when I create new alarms and new devices. So the managedObject api works fine for me. Could you check your service and test the ‘tenant’ context by creating new devices again?
Looks like there was something wrong with the APJ environment. I think they have fixed it and now I can see the managedObject notification with tenant context.
But do you know why only the CREATE events are coming, I can’t see the DELETE events with tenant context