打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Getting started with JMS

offers easy-to-use components to connect to Queues and Topics. In today’s example, we’re going to learn how to use ActiveMQ, a leading open source implementation from Apache that supports 1.1 specification.

Here’s an outline of the simple steps required to implement this example:

  • Import ActiveMQ libraries
  • Create an ActiveMQ connector
  • Enqueue to JMS Queue
  • Run the sample

1. Import ActiveMQ Library

Download ActiveMQ binaries from http://activemq.apache.org/download.html. In this example, I am using the ActiveMQ 5.4.3 release. Unzip the compressed file to any folder on your file system. Let’s call it <ACTIVEMQ_HOME>.

Create a new flow in Mule Studio and name it “jms”. To configure the project to use ActiveMQ libraries, right-click on the project -> Properties -> Java Build Path -> Add External JARs. Select “activemq-all-5.4.3.jar” from <ACTIVEMQ_HOME>.

We can see that the ActiveMQ library is now available under Build path.

2. Create an ActiveMQ Connector

Double-click on “jms” flow to bring up the message flow. Click on the “Global Elements” tab. Click on “Create” and locate ActiveMQ under “Connectors -> JMS”. Leave the default values for the Active_MQ connector and click OK.

Mule will initialize the ActiveMQ connector with a default instance of the ActiveMQ connection factory and establish a TCP connection to the remote standalone broker running on a local host and listening on port 61616.

3. Enqueue to JMS Queue

We will use the request payload received from an HTTP inbound endpoint to seed the ActiveMQ Queue. Open the “jms” message flow and drag and drop an HTTP endpoint on to the flow.

Double-click on the HTTP endpoint to bring up the properties dialog. Specify “jms” for Path. This will make the HTTP endpoint accessible using URL  http://localhost:8081/jms.

Drag and drop a JMS endpoint next to the HTTP inbound endpoint.

Double-click the JMS endpoint to bring up the properties dialog. Specify “StudioIN” for Queue name. This dialog also allows specifying properties for transactions and exchange patterns. We will explore these concepts in future lessons.

Click on the References tab and select “Active_MQ” for Connection Reference. We created the “Active_MQ” connector in Step 2.

Click OK to save these properties and return to JMS Message Flow.

We are now ready to run this sample.

4. Run the sample

First, run ActiveMQ using executable “activemq” from <ACTIVEMQ_HOME>/bin folder. Make sure you can access the ActiveMQ admin page using http://localhost:8161/.

In Mule Studio, right-click on “jms” and select “Run as Mule Flow”.

Open http://localhost:8081/jms. This will enqueue the request to the ActiveMQ JMS Queue “StudioIN”.

Verify this by examining the ActiveMQ administration page at http://localhost:8161/admin/queues.jsp. We can see that there is 1 message under the “Messages Enqueued” column.

More details on ActiveMQ integration can be found in the Mule 3 User Guide.

Related posts:

  1. Mule School: Hello World
  2. Mule School: Invoking Java Component over HTTP
  3. Mule School: Using Flow Controls – Choice Router
  4. Getting started with Mule: Free Training, Videos, Tutorials
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Mule : Configuring Jms
目前的开源ESB产品
tomcat下应用JMS - javajohn - BlogJava
所谓ESB
ActiveMQ技术分享
深入掌握JMS(二):一个JMS例子
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服