31.4. 基于远程 Artemis 的代理的 JMS 资源配置
在管理 CLI 中,您可以使用 @JMS ConnectionFactoryDefinition 注释或 注释,为基于 Artemis 的远程代理(如红帽 AMQ 7)配置 JMS 资源。您也可以从管理控制台配置资源。
@JMSDestinationDefinition
远程 ActiveMQ 服务器资源不需要本地实例 Artemis。这有助于减少 JBoss EAP 映像的内存占用和 CPU 占用。
31.4.1. 使用 JMSConnectionFactoryDefinition 注解配置的 JMS 资源 复制链接链接已复制到粘贴板!
JBoss EAP 使用 @JMSConnectionFactoryDefinition 注释来定义连接工厂。此连接工厂可以连接到本地或远程 Artemis 代理。@JMSConnectionFactoryDefinition 注释的 resourceAdapter 元素随后引用 messaging- subsystem 中定义的 pooled-connection-factory 的名称,该名称可以连接到远程 Artemis 代理。resourceAdapter 元素定义用于创建连接工厂的资源适配器,或者定义连接工厂的资源适配器。
当 @JMSConnectionFactoryDefinition 注释中未定义 resourceAdapter 元素时,messaging-activemq 子系统将默认使用连接工厂的 JNDI 名称。这称为默认绑定。默认绑定使用 /subsystem=ee/service=default 属性来定义。如果指定了 -bindings 中的jms-connection- factoryresourceAdapter 元素,或者可以从 jms-connection-factory 的默认绑定定义 resourceAdapter 元素,如果 它是一个 pooled-connection-factory 到远程代理,您可以使用它连接到远程代理。
如果 messaging-activemq 子系统中没有定义 resourceAdapter,或者无法从 jms-connection-factory 的默认绑定获取,则创建 JMS 资源的任务将委派给 resource-adapters 子系统,它基于资源适配器的 admin-objects 和 connection-definitions 资源。
以下小节提供了如何配置和使用 @JMSConnectionFactoryDefinition 注释的示例。
Configuring @JMSConnectionFactoryDefinition Using the Default Resource Adapter
创建连接器:
/subsystem=messaging-activemq/remote-connector=remote-amq:add(socket-binding="messaging-remote-throughput")创建池连接工厂:
/subsystem=messaging-activemq/pooled-connection-factory=activemq-ra-remote:add(entries=["java:/jms/remote-amq/JmsConnectionFactory"],connectors=["remote-amq"]为
ee子系统定义默认的 JMS 连接工厂:/subsystem=ee/service=default-bindings:write-attribute(name=jms-connection-factory, value="java:/jms/remote-amq/JmsConnectionFactory")在应用程序代码中使用
@JMSConnectionFactoryDefinition注释:@JMSConnectionFactoryDefinition( name="java:app/myCF"
使用远程 Artemis Broker 配置 @JMSConnectionFactory 定义
创建连接器:
/subsystem=messaging-activemq/remote-connector=remote-amq:add(socket-binding="messaging-remote-throughput")创建池连接工厂:
/subsystem=messaging-activemq/pooled-connection-factory=activemq-ra-remote:add(entries=["java:/jms/remote-amq/JmsConnectionFactory"],connectors=["remote-amq"])为
ee子系统定义默认的 JMS 连接工厂:/subsystem=ee/service=default-bindings:write-attribute(name=jms-connection-factory, value="java:/jms/remote-amq/JmsConnectionFactory")在应用程序代码中使用
@JMSConnectionFactoryDefinition注释:@JMSConnectionFactoryDefinition( name="java:app/myCF" resourceAdapter="myPCF" )
Configuring @JMSConnectionFactoryDefinition Using a Third-party JMS Resource Adapter
创建连接器:
/subsystem=messaging-activemq/remote-connector=remote-amq:add(socket-binding="messaging-remote-throughput")创建池连接工厂:
/subsystem=messaging-activemq/pooled-connection-factory=activemq-ra-remote:add(entries=["java:/jms/remote-amq/JmsConnectionFactory"],connectors=["remote-amq"])为
ee子系统定义默认的 JMS 连接工厂:/subsystem=ee/service=default-bindings:write-attribute(name=jms-connection-factory, value="java:/jms/remote-amq/JmsConnectionFactory")在应用程序代码中使用
@JMSConnectionFactoryDefinition注释:@JMSConnectionFactoryDefinition( name="java:app/myCF" resourceAdapter="wsmq" )