use of org.eclipse.milo.opcua.sdk.client.api.subscriptions.UaSubscriptionManager.SubscriptionListener in project milo by eclipse.
the class SubscriptionWatchdogTimerTest method testSubscriptionWatchdogTimer.
@Disabled("run this test manually")
@Test
public void testSubscriptionWatchdogTimer() throws UaException, InterruptedException {
ManagedDataItem dataItem = subscription.createDataItem(Identifiers.Server_ServerStatus_State);
assertTrue(dataItem.getStatusCode().isGood());
CountDownLatch latch = new CountDownLatch(2);
subscription.addStatusListener(new ManagedSubscription.StatusListener() {
@Override
public void onSubscriptionWatchdogTimerElapsed(ManagedSubscription subscription) {
System.out.println("onWatchdogTimerElapsed() id=" + subscription.getSubscription().getSubscriptionId());
latch.countDown();
}
});
client.getSubscriptionManager().addSubscriptionListener(new SubscriptionListener() {
@Override
public void onSubscriptionWatchdogTimerElapsed(UaSubscription subscription) {
System.out.println("onWatchdogTimerElapsed() id=" + subscription.getSubscriptionId());
latch.countDown();
}
});
UInteger subscriptionId = subscription.getSubscription().getSubscriptionId();
server.getSubscriptions().get(subscriptionId).deleteSubscription();
System.out.printf("deleted subscription id=%s on server...%n", subscriptionId);
System.out.println("waiting for watchdog timer to elapse...");
assertTrue(latch.await(15, TimeUnit.SECONDS));
}
Aggregations