第 32 章 后向和转发兼容性
JBoss EAP 支持与将 HornetQ 用作消息传递代理(如 JBoss EAP 6)的传统 JBoss EAP 版本向后兼容。这两种兼容性模式由 JBoss EAP 内置消息传递服务器 ActiveMQ Artemis 提供,其支持 HornetQ 的核心协议。
32.1. forward Compatibility 复制链接链接已复制到粘贴板!
向前兼容性不需要更改旧版 JBoss EAP 6 JMS 客户端的代码。JBoss EAP messaging-activemq 子系统及其资源提供支持。为了支持向前兼容性,需要对 JBoss EAP 7 服务器的配置进行以下更改:每个步骤都提供了单机服务器的管理 CLI 命令示例:
创建
socket-binding,侦听远程传统客户端的端口 4447。/socket-binding-group=standard-sockets/socket-binding=legacy-remoting:add(port=4447)
/socket-binding-group=standard-sockets/socket-binding=legacy-remoting:add(port=4447)Copy to Clipboard Copied! Toggle word wrap Toggle overflow 创建一个传统的
remote-connector,它将使用上一步中创建的socket-binding。JNDI 查找需要此项。/subsystem=remoting/connector=legacy-remoting-connector:add(socket-binding=legacy-remoting)
/subsystem=remoting/connector=legacy-remoting-connector:add(socket-binding=legacy-remoting)Copy to Clipboard Copied! Toggle word wrap Toggle overflow 设置一个传统的消息传递
套接字绑定,侦听端口 5445。/socket-binding-group=standard-sockets/socket-binding=legacy-messaging:add(port=5445)
/socket-binding-group=standard-sockets/socket-binding=legacy-messaging:add(port=5445)Copy to Clipboard Copied! Toggle word wrap Toggle overflow 在
messaging,该子系统使用上一步中的绑定。-activemq 子系统中设置acceptorremote-connector和 remote-/subsystem=messaging-activemq/server=default/remote-connector=legacy-messaging-connector:add(socket-binding=legacy-messaging) /subsystem=messaging-activemq/server=default/remote-acceptor=legacy-messaging-acceptor:add(socket-binding=legacy-messaging)
/subsystem=messaging-activemq/server=default/remote-connector=legacy-messaging-connector:add(socket-binding=legacy-messaging) /subsystem=messaging-activemq/server=default/remote-acceptor=legacy-messaging-acceptor:add(socket-binding=legacy-messaging)Copy to Clipboard Copied! Toggle word wrap Toggle overflow 在 messaging-
activemq子系统的legacy-connection-factory 元素中创建传统的 HornetQ JMS ConnectionFactory。/subsystem=messaging-activemq/server=default/legacy-connection-factory=legacy-discovery:add(entries=[java:jboss/exported/jms/LegacyRemoteConnectionFactory], connectors=[legacy-messaging-connector])
/subsystem=messaging-activemq/server=default/legacy-connection-factory=legacy-discovery:add(entries=[java:jboss/exported/jms/LegacyRemoteConnectionFactory], connectors=[legacy-messaging-connector])Copy to Clipboard Copied! Toggle word wrap Toggle overflow 创建传统的 HornetQ JMS 目的地,并将
legacy-entries属性包含到jms-queueorjms-topic资源。jms-queue add --queue-address=myQueue --entries=[java:jboss/exported/jms/myQueue-new] --legacy-entries=[java:jboss/exported/jms/myQueue] jms-topic add --topic-address=myTopic --entries=[java:jboss/exported/jms/myTopic-new] --legacy-entries=[java:jboss/exported/jms/myTopic]
jms-queue add --queue-address=myQueue --entries=[java:jboss/exported/jms/myQueue-new] --legacy-entries=[java:jboss/exported/jms/myQueue] jms-topic add --topic-address=myTopic --entries=[java:jboss/exported/jms/myTopic-new] --legacy-entries=[java:jboss/exported/jms/myTopic]Copy to Clipboard Copied! Toggle word wrap Toggle overflow 您可以按照以下示例所示,在现有队列或主题中添加
legacy-entries。/subsystem=messaging-activemq/server=default/jms-queue=myQueue:write-attribute(name=legacy-entries,value=[java:jboss/exported/jms/myQueue])
/subsystem=messaging-activemq/server=default/jms-queue=myQueue:write-attribute(name=legacy-entries,value=[java:jboss/exported/jms/myQueue])Copy to Clipboard Copied! Toggle word wrap Toggle overflow 虽然这些
条目属性供 JBoss EAP 消息 JMS 客户端使用,但legacy-entries供传统的 HornetQ JMS 客户端使用。旧版 JMS 客户端查找此传统的 JMS 资源,以与 JBoss EAP 7 通信。注意为避免旧 JMS 客户端中任何代码更改,
messaging-activemq子系统中配置的旧 JNDI 条目必须与传统 JMS 客户端预期的查找匹配。
管理 CLI 迁移操作
当您运行管理 CLI 迁移 操作以更新 消息传递 子系统配置时,如果布尔值参数 add-legacy-entries 设为 true,delay -activemq 子系统会创建 legacy-connection-factory 资源,并将 legacy-entries 添加到 jms-queue 和 jms-topic 资源。迁移的 messaging-activemq 子系统中的传统条目将与传统 消息传递 子系统中指定的条目对应,而常规条目则使用 -new 后缀创建。
如果在运行 迁移 操作时将布尔值参数 add-legacy-entries 设置为 false,则 messaging-activemq 子系统中不会创建传统资源,并且传统的 JMS 客户端将无法与 JBoss EAP 7 服务器通信。