3.2. 运行第一个示例


该示例为名为 exampleQueue 的队列创建使用者和制作者。它发送一条文本消息,然后再次接收该消息,将收到的消息打印到控制台。

流程

  1. 在 < install-dir> /examples/protocols/openwire/queue 目录中运行以下命令来构建示例。

    $ mvn clean package dependency:copy-dependencies -DincludeScope=runtime -DskipTests
    Copy to Clipboard Toggle word wrap

    添加 dependencies :copy-dependencies 会导致依赖项被复制到 target/dependency 目录中。

  2. 使用 java 命令运行示例。

    对于 Linux 或 UNIX:

    $ java -cp "target/classes:target/dependency/*" org.apache.activemq.artemis.jms.example.QueueExample
    Copy to Clipboard Toggle word wrap

    在 Windows 上:

    > java -cp "target\classes;target\dependency\*" org.apache.activemq.artemis.jms.example.QueueExample
    Copy to Clipboard Toggle word wrap

在 Linux 上运行它会产生以下输出:

$ java -cp "target/classes:target/dependency/*" org.apache.activemq.artemis.jms.example.QueueExample
Sent message: This is a text message
Received message: This is a text message
Copy to Clipboard Toggle word wrap

示例的源代码位于 < install-dir> /examples/protocols/openwire/queue/src 目录中。< install-dir&gt; /examples/protocols/openwire 目录中提供了 其他示例。

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat