31.4. 基于远程 Artemis 的代理的 JMS 资源配置


在管理 CLI 中,您可以使用 @JMS ConnectionFactoryDefinition 注释或 @JMSDestinationDefinition 注释,为基于 Artemis 的远程代理(如红帽 AMQ 7)配置 JMS 资源。您也可以从管理控制台配置资源。

远程 ActiveMQ 服务器资源不需要本地实例 Artemis。这有助于减少 JBoss EAP 映像的内存占用和 CPU 占用。

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- factory 属性来定义。如果指定了 resourceAdapter 元素,或者可以从 jms-connection-factory 的默认绑定定义 resourceAdapter 元素,如果 它是一个 pooled-connection-factory 到远程代理,您可以使用它连接到远程代理。

如果 messaging-activemq 子系统中没有定义 resourceAdapter,或者无法从 jms-connection-factory 的默认绑定获取,则创建 JMS 资源的任务将委派给 resource-adapters 子系统,它基于资源适配器的 admin-objectsconnection-definitions 资源。

以下小节提供了如何配置和使用 @JMSConnectionFactoryDefinition 注释的示例。

Configuring @JMSConnectionFactoryDefinition Using the Default Resource Adapter
  1. 创建连接器:

    /subsystem=messaging-activemq/remote-connector=remote-amq:add(socket-binding="messaging-remote-throughput")
  2. 创建池连接工厂:

    /subsystem=messaging-activemq/pooled-connection-factory=activemq-ra-remote:add(entries=["java:/jms/remote-amq/JmsConnectionFactory"],connectors=["remote-amq"]
  3. ee 子系统定义默认的 JMS 连接工厂:

    /subsystem=ee/service=default-bindings:write-attribute(name=jms-connection-factory, value="java:/jms/remote-amq/JmsConnectionFactory")
  4. 在应用程序代码中使用 @JMSConnectionFactoryDefinition 注释:

    @JMSConnectionFactoryDefinition(
            name="java:app/myCF"
使用远程 Artemis Broker 配置 @JMSConnectionFactory 定义
  1. 创建连接器:

    /subsystem=messaging-activemq/remote-connector=remote-amq:add(socket-binding="messaging-remote-throughput")
  2. 创建池连接工厂:

    /subsystem=messaging-activemq/pooled-connection-factory=activemq-ra-remote:add(entries=["java:/jms/remote-amq/JmsConnectionFactory"],connectors=["remote-amq"])
  3. ee 子系统定义默认的 JMS 连接工厂:

    /subsystem=ee/service=default-bindings:write-attribute(name=jms-connection-factory, value="java:/jms/remote-amq/JmsConnectionFactory")
  4. 在应用程序代码中使用 @JMSConnectionFactoryDefinition 注释:

    @JMSConnectionFactoryDefinition(
            name="java:app/myCF"
            resourceAdapter="myPCF"
    )
Configuring @JMSConnectionFactoryDefinition Using a Third-party JMS Resource Adapter
  1. 创建连接器:

    /subsystem=messaging-activemq/remote-connector=remote-amq:add(socket-binding="messaging-remote-throughput")
  2. 创建池连接工厂:

    /subsystem=messaging-activemq/pooled-connection-factory=activemq-ra-remote:add(entries=["java:/jms/remote-amq/JmsConnectionFactory"],connectors=["remote-amq"])
  3. ee 子系统定义默认的 JMS 连接工厂:

    /subsystem=ee/service=default-bindings:write-attribute(name=jms-connection-factory, value="java:/jms/remote-amq/JmsConnectionFactory")
  4. 在应用程序代码中使用 @JMSConnectionFactoryDefinition 注释:

    @JMSConnectionFactoryDefinition(
            name="java:app/myCF"
            resourceAdapter="wsmq"
    )
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部