我有两个JMS服务器,它们在一个独立的完整ha环境中作为JMS集群链接在一起。这些服务器承载着我的JMS目的地(让我们称之为JMS)。
此外,还有一个服务器被配置为独立完整的服务器(让我们将其命名为JMS-从服务器)。这个服务器有一个到JMS主题的JMS桥。
对于这个配置,我在JMS从服务器上创建了两个套接字绑定到远程服务器:
<outbound-socket-binding name="remote-server-1">
<remote-destination host="a.b.c.d" port="8080"/>
</outbound-socket-binding>
<outbound-socket-binding name="remote-server-2">
<remote-destination host="a.b.c.d" port="18080"/>
</outbound-socket-binding>我在消息子系统配置中的两个http-连接器上使用它们:
<http-connector name="remote-1-http-connector" socket-binding="remote-server-1" endpoint="http-acceptor"/>
<http-connector name="remote-2-http-connector" socket-binding="remote-server-2" endpoint="http-acceptor"/>我创建了一个连接工厂:
<pooled-connection-factory name="remote-connection" entries="java:/jms/remoteCF" connectors="remote-1-http-connector remote-2-http-connector" user="testuser" password="testpassword" failover-on-initial-connection="true"/>最后,我配置JMS-Bridge:
<jms-bridge name="HelloWorldQueue-jms-bridge" quality-of-service="DUPLICATES_OK" failure-retry-interval="5000" max-retries="-1" max-batch-size="10" max-batch-time="100">
<source connection-factory="ConnectionFactory" destination="queue/HelloWorldQueue"/>
<target connection-factory="jms/RemoteConnectionFactory" destination="queue/HelloWorldQueue" user="heinz" password="becker" >
<target-context>
<property name="java.naming.factory.initial" value="org.jboss.naming.remote.client.InitialContextFactory"/>
<property name="java.naming.provider.url" value="http-remoting://a.b.c.d:8080, http-remoting://a.b.c.d:18080"/>
</target-context>
</target>
</jms-bridge>结果:
我正在寻找一种配置,在崩溃后JMS“重新连接”到可用节点,而不让它进入与JMS相同的集群。
我怎样才能做到这一点?还有其他的可能性来得到类似的行为吗?还是有一个完全不同的设置方案?
发布于 2018-02-06 17:22:49
我想我自己找到了两种可能的解决方案。但两者都有一些缺点。
第一种方法是使用JMS Bridge。请参阅在Red文档中配置核心桥
不要混淆核心桥和JMS桥。核心桥用于桥接任何两个JBoss EAP消息传递实例,并使用核心API。JMS桥可用于桥接任何两个兼容JMS1.1的JMS提供者,并使用JMS。只要有可能,最好使用核心桥而不是JMS桥。
核心桥或多或少是从盒子里跳过的.已经有了一个连接器,它将自动完成故障转移。它在第一次连接期间检索群集拓扑,并在其生存期内使用它。为了能够在JMS关闭时启动桥,我们可以添加额外的连接器:
<subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
<server name="default">
....
<bridge name="my-core-bridge" static-connectors="remote-1-http-connector remote-2-http-connector" queue-name="jms.queue.HelloWorldQueue" user="username" password="pwd"/>
</server>
...
</subsystem>核心桥的缺点似乎是它不支持JMS。只有JMS队列似乎没有开销。
但也可以配置JMS,将其重新连接到另一台服务器。为了建立连接,JMS对属性"java.naming.provider.url“配置的一个服务器进行JNDI查找。此查找是在启动时执行的,一旦完成,它将使用检索到的远程连接工厂(此处命名为RemoteConnectionFactory)进行连接和重新连接。但是它使用的是JMS的RemoteConnectionFactory!因此,有必要在那里配置这个连接工厂:
<connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="master-1-http-connector master-2-http-connector" ha="true" block-on-acknowledge="true" reconnect-attempts="-1"/>如果此RemoteConnectionFactory有到每个JMS的连接器,JMS将检索所有必要的信息,以便在必要时重新连接到另一台服务器。我的问题的桥接结构现在是不经修改的:
<jms-bridge name="HelloWorldQueue-jms-bridge" quality-of-service="DUPLICATES_OK" failure-retry-interval="5000" max-retries="-1" max-batch-size="10" max-batch-time="100">
<source connection-factory="ConnectionFactory" destination="queue/HelloWorldQueue"/>
<target connection-factory="jms/RemoteConnectionFactory" destination="queue/HelloWorldQueue" user="username" password="pwd" >
<target-context>
<property name="java.naming.factory.initial" value="org.jboss.naming.remote.client.InitialContextFactory"/>
<property name="java.naming.provider.url" value="http-remoting://a.b.c.d:8080, http-remoting://a.b.c.d:18080"/>
</target-context>
</target>
</jms-bridge>我的“jms-桥配置”的缺点是它的复杂性。
https://stackoverflow.com/questions/48561115
复制相似问题