mule-发送json数据到jms queue
2016-07-10 07:55
357 查看
这个示例中,一段json的销售数据以字节流的格式向HTTP接口发送请求,转换器将之转换成字符。发送成功的报文会被打印并且增加到JMS queue中等待被消费。
最后到达JMS queue的报文可以在activeMQ的后台管理界面中被查看到。
<?xml version="1.0" encoding="UTF-8"?> <mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:jms="http://www.mulesoft.org/schema/mule/jms" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd"> <jms:activemq-connector doc:name="Active MQ" name="Active_MQ" validateConnections="true" brokerURL="tcp://localhost:61616"/> <http:listener-config doc:name="HTTP Listener Configuration" host="localhost" name="HTTP_Listener_Configuration" port="8081" /> <flow name="json-to-jmsFlow"> <http:listener allowedMethods="POST" config-ref="HTTP_Listener_Configuration" doc:name="HTTP" path="sales1" /> <byte-array-to-string-transformer doc:name="Convert Byte Array to String" /> <jms:outbound-endpoint connector-ref="Active_MQ" doc:name="Send to JMS queue" name="jms" queue="sales" /> <logger doc:name="Logger" level="INFO" /> </flow> </mule>
操作步骤
1.启动mule应用
2.启动activMQ
2.用postman 向HTTP 服务地址http://localhost:8081/sales1 发送POST请求 json数据
{"ITEM_ID"= 001, "ITEM_NAME" = "Shirt", "QTY" = 1, "PRICE" = 20}
3.执行成功后访问 http://localhost:8161/admin/queues.jsp
相关文章推荐
- 源码推荐(0710):iOS左滑菜单栏,UItableViewCell 自适应 (SDAutoLayout)
- how to use the MySQL subquery to write complex queries
- RabbitMQ中 exchange、route、queue的关系
- 利用xcodebuild命令行进行打包
- 电子原理 半波整流与桥式整流Protues仿真电路
- The current request is not a multipart request
- requireJS之define()
- Tkinter模块GUI
- UITableView错题集
- The Values You Can Mak CF687C(简单DP)
- php include include_once require require_once 的区别与联系
- 307. Range Sum Query - Mutable
- 当UITableViewCell被选中时,上面的自定义view消失的问题
- 当UITableViewCell被选中时,上面的自定义view消失的问题
- 304. Range Sum Query 2D - Immutable
- 303. Range Sum Query - Immutable
- Java中toString(),(String),valueOf()的区别与联系
- UIPickerView简单实用
- 300. Longest Increasing Subsequence
- 生成器模式(Builder)