【发布时间】:2015-10-25 00:20:57
【问题描述】:
我的系统中有一个同步消息事务,该过程大致遵循以下流程:
- “点 A”在消息代理上创建一个临时队列(“目标 2”);
- 消息从 A 点发送到目标 1(消息代理上的一个普通队列),ReplyTo 地址设置为目标 2;
- A 点阻塞等待目的地 2 的响应;
- B 点收到来自目的地 1 的消息;
- 点 B 创建一个工作对象 - 其属性是目标 2 的名称(使用 .ToString()" 派生。此工作对象被序列化并存储在 DB 中;
...
- 当满足某些参数时从 DB 中检索对象,发生更改,并将响应发送到目标 2 - 使用 SessionUtil 从存储为工作对象的字符串属性的回复地址派生新的 Idestination 对象;
- “A 点”收到来自目的地 2 的消息并继续前进。
此过程可能需要几秒钟到几秒钟的时间才能完成。
我需要使用返回目的地的名称(目的地 2),而不是完整的 IDestination 对象,因为我必须序列化对象并存储在数据库中。
如果我使用永久队列或主题作为目标 2,则该过程可以正常工作。但是,尝试使用临时队列的字符串名称创建它时总是失败。
没有错误,只是消息没有到达
有什么想法吗?
显示发送返回消息的示例代码:
IDestination myDestination = SessionUtil.GetDestination(stateSession, instance.ReplyTo, DestinationType.Queue);
stateConnection.Start();
using (IMessageProducer myProducer = stateSession.CreateProducer(myDestination))
{
myProducer.DeliveryMode = MsgDeliveryMode.NonPersistent;
var response = myProducer.CreateTextMessage();
response.NMSCorrelationID = instance.CorrelationID;
response.Properties["RoutingDestination"] = instance.RoutingOriginator;
response.Text = "Test Response";
try
{
myProducerBroadcast.Send(response);
myProducer.Send(response);
Log.InfoFormat("Sent response {0} to {1}", instance.UniqueId, instance.ReplyTo);
}
catch (Exception ex)
{
Log.Error("Unable to send execution update onwards", ex);
}
}
(“instance”是工作对象-包含ReplyTo地址和其他信息)
【问题讨论】:
-
instance.ReplyTo 在本例中设置为“temp-queue://ID:HL003323-52604-634308828390407226-1:1:1”