部署JBI组件至Fuse ESB Enterprise Runtime

ISEESTARS 2012-08-28

     JBI Endpoint Cluster

     Fuse ESB Enterprise提供了一个Cluster Engine,用于使用JMS Broker(ActiveMQ)在JBI Application中指定

     Endpoint. Fuse ESB Enterprise的Cluster Engine通过NMR(Normalized Message Router)进行通信,同时

     使用ActiveMQ配置JBI Endpoint来进行创建Cluster.

     (1) 设置JBI Endpoint Cluster

     A. 安装Cluster Feature: features:install jbi-cluster

          验证安装: features:list

     B. 默认的Cluster Engine配置:jbi-cluster.xml

          位于${ESB_InstallDir}\system\org\apache\servicemix\jbi\cluster下的Bundle:org.apache.servicemix.jbi.

          cluster.config中。

     C. 改变默认的配置

          添加配置文件至Bundle:org.apache.servicemix.jbi.cluster.config, 更该其中的clusterName和destinationName.

     D. 改变JMS Broker

          默认情况下,Fuse ESB Enterprise提供了一个ActiveMQ 实例,可通过${ESB_InstallDir}\deploy下面添加

          XML配置文件。

     E. 在应用程序中使用Cluster

          1. OSGi packaged JBI endpoint

<http:consumer id="myHttpConsumer" service="test:myService" endpoint="myEndpoint" />
<bean class="org.apache.servicemix.jbi.cluster.engine.OsgiSimpleClusterRegistration">
	<property name="endpoint" ref="myHttpConsumer" />
</bean>

          2. JBI packaged endpoint

<http:consumer id="myHttpConsumer" service="test:myService" endpoint="myEndpoint" />
<bean class="org.apache.servicemix.jbi.cluster.engine.OsgiSimpleClusterRegistration">
    <!-- 需添加额外的信息 -->
	<property name="serviceName" value="test:myService" />
	<property name="endpointName" value="myEndpoint" />


</bean> 

     F. 容器之间建立网络链接

     配置${ESB_InstallDir}/conf/activemq.xml文件。

     有两种方式:

             1. Static network connections

<!-- Set the brokerName to be unique for this container -->
<amq:broker id="broker" brokerName="host1_broker1" depends-on="jmxServer">
	<networkConnectors>
		<networkConnector name="host1_to_host2" uri="static://(tcp://host2:61616)"/>
		<!-- A three container network would look like this -->
		<!-- (Note it is not necessary to list the hostname in the uri list) -->
		<!-- networkConnector name="host1_to_host2_host3"
		uri="static://(tcp://host2:61616,tcp://host3:61616)"/ -->
	</networkConnectors>
</amq:broker>

            2. Multicast network connections

<networkConnectors>
	<!-- by default just auto discover the other brokers -->
	<networkConnector name="default-nc" uri="multicast://default"/>
</networkConnectors>

     G. 高可用性

     通过Master-Slave模式进行,Master 处于ACTIVE时,Slave处于STANDBY 状态等待一个失败的时间触发

     Slave生效。可通过配置下面几种方式:

             1. Shared file system master-slave: 需要文件系统支持文件级别的Lock;

             2. JDBC master-slave: Master首先锁定Table,当失败事件发生时释放Lock;

             3. Pure master-slave: Master复制所有的数据至 Slave,需要做额外的工作。

     H. Cluster配置最佳实践

             1. 不要同时使用static和multicast的networkConnectors;

             2. 确保/conf/activemq.xml中的brokerName唯一;

             3. 确保针对每个活跃者的实例有一个对应的持久存储,例如:

<property name="url" value="jdbc:mysql://localhost/broker_activemq_host1?relaxAutoCommit=true"/>

             4. 可在同以主机上设置Network Container,但需要改改JMS Port和 transportConnector Port,避免端口

             冲突;可通过修改/conf/activemq.xml修改其中的rmi.port和activemq.port:

rmi.port = 1098
rmi.host = localhost
jmx.url = service:jmx:rmi:///jndi/rmi://${rmi.host}:${rmi.port}/jmxrmi
activemq.port = 61616
activemq.host = localhost
activemq.url = tcp://${activemq.host}:${activemq.port}

相关推荐