如何在 Jboss 6 中配置 JMS?

Ami*_*Ami 5 java jms jboss6.x

我是 JMS(java 消息服务)的新手。我想使用 jboss 6 运行示例 JMS 应用程序。

我已经厌倦了谷歌搜索,并得到了像这样。这些链接是指 jboss 7。

1.如何在jboss 6中配置JMS?

2.Jboss7有内置JMS吗?还是需要手动配置?

3.使用Jboss 6的示例应用程序?

Jak*_*ski 5

在 Jboss 7(以及 6)中,您捆绑了 HornetQ 服务器。在 Jboss 6 中,它位于 deploy\hornetq.sar。如果你想添加目的地,你可以在 hornetq-jms.xml 文件中指定它:

<topic name="myTopic">
  <entry name="/topic/myTopic"/>
</topic>
<queue name="myQueue">
  <entry name="/queue/myQueue"/>
</queue>
Run Code Online (Sandbox Code Playgroud)

在 Jboss 7 中,它如下所示:

<subsystem xmlns="urn:jboss:domain:messaging:1.1">
  <hornetq-server>
    <jms-destinations>
      <jms-queue name="myQueue">
        <entry name="queue/myqueue"/>
      </jms-queue>
      <jms-topic name="myTopic">
        <entry name="topic/mytopic"/>
      </jms-topic>
    </jms-destinations>
  </hornetq-server>
</subsystem>
Run Code Online (Sandbox Code Playgroud)

您可以在 HornetQ 文档中找到更多信息


Ami*_*Ami 2

最后我得到了使用 Jboss 6.x 的示例 jms 应用程序的链接。有两种方法可以在jboss中配置jms队列 1.在jboss/server/default/deploy/hornetq/hornetq.jms.xm中添加消息队列详细信息

<queue name="myQueue">
  <entry name="/queue/MyQueue"/>
</queue>
Run Code Online (Sandbox Code Playgroud)

2.在工作区中创建xml文件并添加消息队列详细信息

<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="urn:hornetq"
    xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd" >

    <queue name="MyQueue2" >
        <entry name="/queue/MyQueue" />
    </queue>

</configuration>
Run Code Online (Sandbox Code Playgroud)

将此文件保存在工作区的 META-INF 文件夹下。

请参阅此示例应用程序

本例包括1.如何使用hornetq在jboss中配置jms。2.发送消息到jms消息队列 3.显示来自jboss服务器的消息

  • 这里与@Jakub K 的答案有什么不同? (4认同)