【问题标题】:Publishing and Accessing OSGI Service with JBoss Fuse Fabric使用 JBoss Fuse Fabric 发布和访问 OSGI 服务
【发布时间】:2019-09-21 09:18:40
【问题描述】:

我有一个 OSGi 服务,我公开并部署在 jboss fuse fabric 上。 现在我需要从部署在 jboss fuse fabric 中另一个容器上的另一个包访问此服务。但在客户端容器中无法访问该服务。 jboss fuse V6.3

当我在 fuse Fabric 的同一个容器中部署 OSGi 服务包和客户端包时,它可以工作,但是当我将它们部署在不同的容器中时,它不起作用并显示错误: 由于未解决的依赖关系[(objectClass=org.fusesource.example.service.HelloWorldSvc)],无法启动捆绑包 com.osgi.app.bean-camel-client10/1.0.0 的蓝图容器

在客户端:

POM.xml:

<dependency>
    <groupId>com.osgi.app</groupId>
    <artifactId>bean-app-service1</artifactId>
    <version>1.0</version>
</dependency>

config.xml:

<reference id="helloWorld"
    interface="org.fusesource.example.service.HelloWorldSvc"/>
<camelContext xmlns="http://camel.apache.org/schema/blueprint" >
<route>
  <from uri="timer:foo?period=5000"/>
  <to uri="bean:org.fusesource.example.service.HelloWorldSvc?method=sayHello"/>

  <log message="The message contains: ${body}"/>
 </route>

在服务提供者中:

pom.xml:

<groupId>com.osgi.app</groupId>
<artifactId>bean-app-service2</artifactId>
<version>1.0</version>
<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <version>${version.maven-bundle-plugin}</version>
    <extensions>true</extensions>
    <configuration>
      <instructions>
        <Bundle-SymbolicName>${pom.groupId}.${pom.artifactId}</Bundle-SymbolicName>
        <Export-Package>org.fusesource.example.service</Export-Package>
      </instructions>
    </configuration>
  </plugin>

config.xml:

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
         http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
         http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<bean id="hello" class="org.fusesource.example.service.impl.HelloWorldSvcImpl"/>

 <service ref="hello" interface="org.fusesource.example.service.HelloWorldSvc"/>
 </blueprint>

如何通过骆驼上下文访问部署在 fuse Fabric 中另一个容器中的服务?

【问题讨论】:

    标签: osgi-bundle jbossfuse fusefabric


    【解决方案1】:
    <service ref="hello" interface="org.fusesource.example.service.HelloWorldSvc"/>
    

    就是这个意思:致电BundleContext.registerService("org.fusesource.example.service.HelloWorldSvc", object, properties)。

    注册后,您在本地 OSGi 注册表中注册了一个服务,该服务由单个 JVM 实例限定 - 这绝不意味着该服务可在不同的 JVM 中访问。

    如果您希望服务在不同的 JVM 中可用(== 在不同的 OSGi 注册表中),您需要某种远程处理 - 尝试使用 CXF 端点或远程骆驼组件之一(骆驼- cxf,骆驼休息,...)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-05-05
      • 2016-07-30
      • 1970-01-01
      • 2017-10-17
      • 2017-04-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多