opc-ua - 如何删除 Eclipse Milo 0.3.8 中的订阅项目?
问题描述
我查看了订阅 NodeId 的示例,我想知道之后如何停止/删除订阅。
Eclipse Milo v0.3.8 客户端。
这是我尝试过的。
protected boolean unsubscribe(TransactionDefinition transactionDefinition) {
// Finds the mathing TransactionDefinition from the map where all subscriptions
// are stored, together with the clientHandle.
// private Map<UInteger, TransactionDefinition> subscriptions = new HashMap<>();
try {
UInteger subscriptionClientHandle = null;
for (Map.Entry<UInteger, TransactionDefinition> entry : subscriptions.entrySet()) {
if (entry.getValue().equals(transactionDefinition))
subscriptionClientHandle = entry.getKey();
}
if (subscriptionClientHandle == null) return false;
try {
client.getSubscriptionManager().deleteSubscription(subscriptionClientHandle).get();
return true;
} catch (Exception e) {
log.error("Subscription not found: {}", e.getMessage(), e.getCause());
e.printStackTrace();
}
} catch (ClassCastException e) {
log.error("TransactionDefinition trigger not found. {}", e.getMessage(), e.getCause());
e.printStackTrace();
}
return false;
}
解决方案
UaSubscription
有一个deleteMonitoredItems
方法。
UaSubscriptionManager
有一个deleteSubscription
方法。
UaClient
您还可以通过在实例上调用“原始”服务方法来“手动”调用这些服务中的任何一个。
推荐阅读
- php - 通过蓝图数组映射列表动态地 json 对象返回数组 1 维
- docker - rViz 在 nvidia-docker 容器中
- jquery - CSS div 悬停以通过另一个拖动的 div 更改颜色
- node.js - 如何在 Nodejs 中为 winston 记录器编写单元测试
- pgmpy - 0.1.9 版中的 TreeCPD 在哪里
- html - 如何从 Angular 8 中的 *ngFor 中提取值
- node.js - 依赖 core-js 尝试在 Docker 上运行时出现 NPM 安装后错误
- datastax - Datastax Graph:Gremlin 查询以获取所有没有特定边的顶点
- azure - 在 Azure Databricks 集群中,该工作人员是什么意思?
- html - 可编辑 div 内的不可编辑 div