我正在尝试使WebMQ在MULE中同步操作,以便将消息队列转换为内部项目的REST API.不幸的是,我对MULE知之甚少.
经过一番工作后,我开始理解Request-Reply范围,并尝试使用WMQ Connector,只是发现WMQ只在流程结束后发送.
我已尝试使用VM将请求放入不同的流程中以触发它

但到目前为止,只是导致它永远等待WMQ永远不会发生.
我也尝试过来回使用虚拟机:

但它似乎做了与没有相同的事情,它只是忽略了输入.
现在我知道WMQ的输入和输出正在工作,因为我之前设置了一个使用http与自身通信的流程,并让它知道消息何时通过.

我本质上想要的是这个,但使用HTTP而不是AJAX

我最近的,也许最接近的尝试看起来像这样:

XML是:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:http="http://www.mulesoft.org/schema/mule/http" version="EE-3.6.0" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:ajax="http://www.mulesoft.org/schema/mule/ajax" xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:stdio="http://www.mulesoft.org/schema/mule/stdio" xmlns:test="http://www.mulesoft.org/schema/mule/test" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:wmq="http://www.mulesoft.org/schema/mule/ee/wmq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/ajax http://www.mulesoft.org/schema/mule/ajax/current/mule-ajax.xsd
http://www.mulesoft.org/schema/mule/ee/wmq http://www.mulesoft.org/schema/mule/ee/wmq/current/mule-wmq-ee.xsd
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/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/stdio http://www.mulesoft.org/schema/mule/stdio/current/mule-stdio.xsd
http://www.mulesoft.org/schema/mule/test http://www.mulesoft.org/schema/mule/test/current/mule-test.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.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/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd">
<wmq:connector channel="MAGENTO.SVRCONN" doc:name="WMQ Connector" hostName="[ip]" name="wmqConnector" port="1414" queueManager="MAGENTO" transportType="CLIENT_MQ_TCPIP" validateConnections="true" />
<vm:connector name="VM" validateConnections="true" doc:name="VM">
<vm:queue-profile maxOutstandingMessages="500">
<default-persistent-queue-store/>
</vm:queue-profile>
</vm:connector>
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<flow name="Input">
<http:listener config-ref="HTTP_Listener_Configuration" path="/mq" doc:name="HTTP"/>
<set-payload value="#[message.inboundProperties.'http.query.params'.xml]" doc:name="Set Payload"/>
<logger message="Entering Request-Reply Payload: #[payload]" level="INFO" doc:name="Logger"/>
<request-reply doc:name="Request-Reply">
<vm:outbound-endpoint exchange-pattern="one-way" path="mq" connector-ref="VM" doc:name="VM_TriggerSend" />
<vm:inbound-endpoint exchange-pattern="request-response" path="mq-return" connector-ref="VM" doc:name="VM_Receive" />
</request-reply>
<logger message="Request-Reply has ended. Payload: #[payload]" level="INFO" doc:name="Logger"/>
</flow>
<flow name="Send_Message">
<vm:inbound-endpoint exchange-pattern="one-way" path="mq" connector-ref="VM" doc:name="VM_Send"/>
<logger message="(Preparing to Dispatch) Payload: #[payload]" level="INFO" doc:name="Logger"/>
<wmq:outbound-endpoint queue="PUT_QUEUE" connector-ref="wmqConnector" doc:name="WMQ"/>
<logger message="Message presumably being dispatched after this log" level="INFO" doc:name="Logger"/>
</flow>
<flow name="Receive_Message">
<wmq:inbound-endpoint queue="GET_QUEUE" connector-ref="wmqConnector" doc:name="WMQ_Receive" />
<logger message="Triggering Receive" level="INFO" doc:name="Logger"/>
<vm:outbound-endpoint exchange-pattern="request-response" path="mq-return" connector-ref="VM" doc:name="VM_TriggerReceive" />
</flow>
</mule>
Run Code Online (Sandbox Code Playgroud)
这几乎可以工作,但它无限期挂起而不会将响应发送回HTTP服务器.将Request-Reply流中的vm:inbound-endpoint设置为单向使其不挂起,但不发送已接收的新有效负载,而是发送先前的有效负载(就好像它被跳过一样).
任何帮助都将非常感谢!
如果我理解正确的话,您只是试图将队列上的请求和众所周知的队列上的响应公开为 REST api。
那里不需要VM队列,并且作为JMS传输的请求-应答元素都不能模拟请求响应交换模式。
JMS 队列只是一种方式。您必须在不同的队列上进行回复。请求-响应场景背后的逻辑是具有出站属性的出站端点:MULE_REPLYTO。应使用您熟知的回复队列名称来设置此属性:GET_QUEUE(如果未提供此类标头,将创建临时队列)。
JMSReplyTo当服务接收到消息时,MULE_REPLY 标头将成为标准。服务必须遵守此标头,将回复发送回该队列。如果该服务在 Mule 上实现,这将自动发生,否则可能不会发生。您应该仔细检查它是否受到尊重。
如果您想对单向端点使用请求-答复范围而不是一个请求-响应端点,那很好,应该工作相同,但需要更多代码。
| 归档时间: |
|
| 查看次数: |
543 次 |
| 最近记录: |