Я использую верблюда с Карафом в качестве контейнера. Я создал пакет, содержащий конструкцию bean-компонента curatorFramework, который я экспортирую как сервис:
<?xml version="1.0" encoding="UTF-8"?> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.2.0" xmlns:cxf="http://cxf.apache.org/blueprint/core" xsi:schemaLocation=" http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd " default-activation="lazy"> <cm:property-placeholder persistent-id="cluster.zookeepermaster" update-strategy="reload"> <cm:default-properties> <cm:property name="zookeeper-cluster-master.id" value="node-zk" /> <cm:property name="zookeeper-cluster-master.basePath" value="/camel/cluster/tesb" /> <!-- nodes = list of zookeeper nodes separeted bt , ie host1:port1,host2:port2 --> <cm:property name="zookeeper-cluster-master.nodes" value="localhost:2181" /> </cm:default-properties> </cm:property-placeholder> <bean id="curator" class="org.apache.curator.framework.CuratorFrameworkFactory" factory-method="newClient" destroy-method="close" init-method="start"> <argument value="${zookeeper-cluster-master.nodes}"/> <argument value="${zookeeper-cluster-master.session-timeout-ms}"/> <argument value="${zookeeper-cluster-master.connection-timeout-ms}"/> <argument type="org.apache.curator.RetryPolicy"> <bean class="org.apache.curator.retry.ExponentialBackoffRetry"> <argument value="${zookeeper-cluster-master.base-sleep-time-ms}"/> <argument value="${zookeeper-cluster-master.max-retries}"/> <argument value="${zookeeper-cluster-master.max-sleep-ms}"/> </bean> </argument> </bean> <service ref="curator" interface="org.apache.curator.framework.CuratorFramework" /> </blueprint>
Затем в моем маршруте Camel я внедряю экспортированный сервис вкомпонент MasterComponent (ZooKeeper-Master-Component):
<bp:blueprint xmlns:bp="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:camel="http://camel.apache.org/schema/blueprint" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd 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="zookeeper-master" class="org.apache.camel.component.zookeepermaster.MasterComponent"> <property name="curator" ref="curator"/> </bean> <bp:reference id="curator" interface="org.apache.curator.framework.CuratorFramework"/> ... </bp:blueprint>
Когда я изменяю свойства (например, url ==> zookeeper-cluster-master.nodes) в /etc/cluster.zookeepermaster,пакет перезапускается, но изменение не распространяется на компонент MasterComponent. Мой подход хорош или должен быть сделан иначе?