jmsoutboundgateway发送绑定消息时,如何设置Alter Replyto,以使其与ReplyDestination不同?
我们有一个MQ请求/回复模式实现
在这里我们使用IBM MQ群集主机。在这里,双方的请求/回复队列与MQ群集环境相互链接,因为集群中不同系统的队列经理相互对话。
我们的请求者代码使用Spring JMS Integration -JMSoutBoundGateway发送和接收消息 服务提供商是我们无法控制的大型机应用程序。
public class JmsOutboundGatewayConfig {
@Bean
public MessageChannel outboundRequestChannel() {
return new DirectChannel();
}
@Bean
public QueueChannel outboundResponseChannel() {
return new QueueChannel();
}
@Bean
@ServiceActivator(inputChannel = "outboundRequestChannel")
public JmsOutboundGateway jmsTestOutboundGateway(ConnectionFactory connectionFactory) {
JmsOutboundGateway gateway = new JmsOutboundGateway();
gateway.setConnectionFactory(connectionFactory);
gateway.setRequestDestinationName("REQUEST.ALIAS.CLUSTER.QUEUE");
gateway.setReplyDestinationName("REPLY.ALIAS.CLUSTER.QUEUE");
gateway.setReplyChannel(outboundResponseChannel());
gateway.setRequiresReply(true);
return gateway;
}
}
// Requestor - sendAndReceive code
outboundRequestChannel.send(new GenericMessage<>("payload"));
Message<?> response = outboundResponseChannel.receive(10000);
问题: 我们发送消息时面临的问题,网关代码也通过回复 = queue://reply.alias.cluster.queue。
现在,会消耗此消息的大型机程序,被迫回复回复队列。它在大型机方面失败了,因为我们发送的回复队列不属于其MQ MGR/Env。
在发送消息时,我找不到一种方法来删除回复。当jmsoutboundgateway使用我配置的“ ReplyDestinationName”设置此回复。 我们的请求者需要设置“ ReplyDestinationName”,因为我们正在收听此别名群集回复队列以进行回复。
我查看了频道拦截器选项,我只能拦截消息以更改消息,但是没有选择更改回复 。
- 有没有方法可以更改回复 ie回复和回复删除不同?
- 无论如何,在将消息发送到请求队列时,是否有删除/不设置回复?
只是想知道如何使此方法在此类MQ群集环境中工作,在这种情况下,回复队列将不得不保留大型机消费者服务所需的内容,这与 replyDestination 排队不同使用。 考虑到大型机服务使用回复回复。如果未通过,大型机服务将使用其自己的答复队列,该队列链接到我们的回复群集 - alias队列。
有任何意见吗?
谢谢 Saishm
进一步澄清: 我们拥有的集群MQ Env,我们的Spring JMS出站网关正在将请求写入 - “ request.alias.cluster.queue”&amp;聆听“回复。 因此,jmsoutboundgateway设置回复=回复
。在群集env中,“ request.alias.cluster.queue”,其QMGR链接到“ request.local.queue”及其QMGR,所有这些都在群集MQ Env中进行了管理。
消耗请求时的大型机服务看到传入的消息有回复,并试图将答复发送给此回复。 问题是大型机应该回复“ reply.local.queue”,该链接链接到reply.alias.cluster.queue 如果没有答复,它将将答复发送给“ reply.local.queue”。
现在,从JMSOUTBOUNDGATEWAWAY发送消息时,我没有任何选项可以删除答复或将其编辑为“ reply.local.queue”,并继续聆听请求的回复/回复,请访问“ Reply.alias.alias.cluster.queue”。
We have a MQ request/reply pattern implementation
Here we use a IBM MQ Cluster host. Here the request/reply queues on both sides are linked to each other by the MQ cluster environment, as the queue managers of different systems within the cluster talks to each other.
Our Requestor code uses Spring JMS Integration - JmsOutboundGateway to send and receive message
The service provider is a Mainframe application which we have no control.
public class JmsOutboundGatewayConfig {
@Bean
public MessageChannel outboundRequestChannel() {
return new DirectChannel();
}
@Bean
public QueueChannel outboundResponseChannel() {
return new QueueChannel();
}
@Bean
@ServiceActivator(inputChannel = "outboundRequestChannel")
public JmsOutboundGateway jmsTestOutboundGateway(ConnectionFactory connectionFactory) {
JmsOutboundGateway gateway = new JmsOutboundGateway();
gateway.setConnectionFactory(connectionFactory);
gateway.setRequestDestinationName("REQUEST.ALIAS.CLUSTER.QUEUE");
gateway.setReplyDestinationName("REPLY.ALIAS.CLUSTER.QUEUE");
gateway.setReplyChannel(outboundResponseChannel());
gateway.setRequiresReply(true);
return gateway;
}
}
// Requestor - sendAndReceive code
outboundRequestChannel.send(new GenericMessage<>("payload"));
Message<?> response = outboundResponseChannel.receive(10000);
Issue:
The issue we are facing when we send message, the gateway code is also passing the replyTo = queue://REPLY.ALIAS.CLUSTER.QUEUE.
Now the mainframe program that consumes this message , it is forced to reply back to the replyTo queue. It is failing on mainframe side as this replyTo queue which we send is not part of their MQ Mgr/env.
I could not find a way to remove the replyTo when sending message. As JmsOutboundGateway set this replyTo using the "ReplyDestinationName" which I had configured.
Our requestor will need to set the "ReplyDestinationName" as we are listening to this Alias-cluster reply queue for reply back.
I looked at the Channel interceptor options, I could only Intercept the message to alter it, but no option to change the replyTo.
- Is there way to alter the replyTo i.e replyTo and ReplyDestination different?
- Is there anyway to remove/not-set the replyTo when sending message to request queue?
Just wondering how to get this working for such MQ cluster environment where the replyTo queue will have to kept what the mainframe consumer service want, that is different to the replyDestination queue which we use.
Considering that the replyTo is used by the mainframe service to reply back. If it is not passed the mainframe service will use its own reply queue which is linked to our reply-cluster-alias queue.
Any inputs appreciated?
Thanks
Saishm
Further clarification:
The cluster mq env we have, Our spring jms outbound gateway is writing request to - "REQUEST.ALIAS.CLUSTER.QUEUE" & listening to the reply on "REPLY.ALIAS.CLUSTER.QUEUE"
So the jmsOutboundGateway sets the replyTo=REPLY.ALIAS.CLUSTER.QUEUE
Now the mainframe service on the other side is reading the message from "REQUEST.LOCAL.QUEUE". In the cluster env the "REQUEST.ALIAS.CLUSTER.QUEUE" ands its QMGR are linked to "REQUEST.LOCAL.QUEUE" and its QMGR, this is all managed within the cluster MQ env.
The mainframe service when consuming the request, sees that the incoming message had a replyTo and tries to send the response to this replyTo.
The issue is mainframe was supposed to reply to "REPLY.LOCAL.QUEUE" which is linked to REPLY.ALIAS.CLUSTER.QUEUE
If there is no replyTo it would have send the reply to "REPLY.LOCAL.QUEUE".
Now from the jmsOutBoundGateway I dont have any options to remove replyTo when sending mEssage or edit it to "REPLY.LOCAL.QUEUE" and keep listening to the response/reply of the request on "REPLY.ALIAS.CLUSTER.QUEUE"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来不像
jmsoutboundgateway
适合您的IBM MQ群集配置和要求。您只是无法使用该Replyto
功能,因为我们无法绕过JMS协议。考虑分别使用一对
JMSSENGENGENDERMESSAGEHANDLER
和JMSMESSEGEDRINDENDPOINT
组件。您的JMSSENGENDMESSAGEHANDLER
只会将JMS消息发送到request.alias.cluster.queue.queue
and Hosthing。您需要的只是提供jmsheaders.correlation_id
。jmsheadermapper
将填充jmsmessage.setjmscorrelationId()
属性 - 与jmsoutboundgateway
相同的方式相同。在这种情况下,您的大型机服务可以免费使用自己的回复队列,我想它将正确提供我们的corserLationId
。jmsmessagedrivenendpoint
必须订阅revery.alias.cluster.queue.queue
,并且您在请求和回复自己之间进行相关性。例如,映射
conerelationIdId
和Future
在回复返回时实现。Doesn't look like a
JmsOutboundGateway
will fit your IBM MQ cluster configuration and requirements. You just cannot use thatreplyTo
feature since we cannot bypass JMS protocol over here.Consider to use a pair of
JmsSendingMessageHandler
andJmsMessageDrivenEndpoint
components, respectively. YourJmsSendingMessageHandler
will just send a JMS message to theREQUEST.ALIAS.CLUSTER.QUEUE
and forget. Only what you need is to supply aJmsHeaders.CORRELATION_ID
. TheJmsHeaderMapper
will populate ajmsMessage.setJMSCorrelationID()
property - the same way asJmsOutboundGateway
does that by default. In this case your mainframe service is free to use its own reply queue and I guess it will supply ourcorrelationId
correctly.A
JmsMessageDrivenEndpoint
has to be subscribed to theREPLY.ALIAS.CLUSTER.QUEUE
and you do a correlation between request and reply yourself. For example aMap
ofcorrelationId
andFuture
to fulfill when reply comes back.