1

如标题中所述,我想在 OSGI 环境中使用远程服务。所以我决定用 eclipse ECF 来处理这个问题。在我看来,这是一个处理 OSGI 远程服务的非常好的项目。所以对于发现提供者,我使用 Zoodiscovery。服务使用通用服务属性注册。此外,Zoodiscovery 以集中模式使用,中心 IP 通过网络广播发布。我得到了一切工作。但经过一段时间后,服务消费者失去了远程服务。

发现远程服务时显示此消息:

[log;+0000 2016.04.22 15:26:03:564;DEBUG;org.eclipse.ecf.provider.zookeeper;Service Discovered: ServiceInfo[uri=ecfosgirsvc://192.168.178.21:32565/osgirsvc_AMIsPeVObufIp5v5cV6pHNIvzGM=;id=ServiceID[type=ServiceTypeID[typeName=_ecfosgirsvc._default.default._iana];location=ecfosgirsvc://192.168.178.21:32565/osgirsvc_AMIsPeVObufIp5v5cV6pHNIvzGM=;full=_ecfosgirsvc._default.default._iana@ecfosgirsvc://192.168.178.21:32565/osgirsvc_AMIsPeVObufIp5v5cV6pHNIvzGM=];priority=0;weight=0;props=ServiceProperties[{objectClass=de.custom.service.api.IManagerService, endpoint.id=e9dc7ac1-708d-43a6-b2fa-539beff6c732, remote.intents.supported=passByValue exactlyOnce ordered, ecf.endpoint.id=ecftcp://192.168.178.21:2121/server, ecf.rsvc.id=3, endpoint.service.id=174, service.imported.configs=ecf.generic.server, ecf.endpoint.ts=1461329304080, ecf.generic.server.hostname=192.168.178.21, ecf.endpoint.id.ns=org.eclipse.ecf.core.identity.StringID, remote.configs.supported=ecf.generic.server, endpoint.package.version.de.custom.api=1.0.0, endpoint.framework.uuid=70eaf65a-8608-0016-13af-dcea8562a726}]]]

未发现远程服务时会显示此消息:

[log;+0000 2016.04.22 15:28:53:125;DEBUG;org.eclipse.ecf.provider.zookeeper;Service Undiscovered: ServiceInfo[uri=ecfosgirsvc://192.168.178.21:32565/osgirsvc_AMIsPeVObufIp5v5cV6pHNIvzGM=;id=ServiceID[type=ServiceTypeID[typeName=_ecfosgirsvc._default.default._iana];location=ecfosgirsvc://192.168.178.21:32565/osgirsvc_AMIsPeVObufIp5v5cV6pHNIvzGM=;full=_ecfosgirsvc._default.default._iana@ecfosgirsvc://192.168.178.21:32565/osgirsvc_AMIsPeVObufIp5v5cV6pHNIvzGM=];priority=0;weight=0;props=ServiceProperties[{objectClass=de.custom.service.api.IManagerService, endpoint.id=e9dc7ac1-708d-43a6-b2fa-539beff6c732, remote.intents.supported=passByValue exactlyOnce ordered, ecf.endpoint.id=ecftcp://192.168.178.21:2121/server, ecf.rsvc.id=3, endpoint.service.id=174, service.imported.configs=ecf.generic.server, ecf.endpoint.ts=1461329304080, ecf.generic.server.hostname=192.168.178.21, ecf.endpoint.id.ns=org.eclipse.ecf.core.identity.StringID, remote.configs.supported=ecf.generic.server, endpoint.package.version.de.custom.api=1.0.0, endpoint.framework.uuid=70eaf65a-8608-0016-13af-dcea8562a726}]]]

但是:在主机系统上一切都很好,服务在线。如果我在消费者端重新启动 OSGI 框架,一切都会再次正常工作,直到这个 Undiscovery 事件。发现和未发现之间的时间长度相等。

似乎有一个超时未发现服务。如果我通过调用方法来使用服务,则没有不同的行为。有谁知道发生了什么?

感谢您的帮助和最诚挚的问候!

更新:

好的一个更新:当发现远程服务时,我在客户端的本地参数中获取它。当远程服务在客户端未发布时(不是在服务器端,如我之前的帖子中所述),我可以从获取的实例中调用方法。所以代理仍然可用并且它工作正常,直到我在服务器端取消发布远程服务。因此代理仅在 OSGI 服务注册表中未发布。

此致!

4

0 回答 0