ActiveMQ的 - 发送消息到一个临时队列使用字符串指定的NMS(在C#) [英] ActiveMQ - Sending a message to a temporary queue specified using a string (NMS in C#)

查看:566
本文介绍了ActiveMQ的 - 发送消息到一个临时队列使用字符串指定的NMS(在C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的系统中的同步消息交易,这个过程大致遵循以下流程:

I have a synchronous message transaction within my system, and the process broadly follows this flow:


  1. 点A创建一个临时队列(目标2)的消息代理;

  2. 信息从A点传送到目的地1(在消息代理标准队列),设定为目的地2的ReplyTo地址;

  3. A点块等待响应目的地2;

  4. b点距离目的地1接收消息;

  5. b点创建工作对象 - 它的属性是目标2(使用的ToString()这项工作对象序列衍生并存储在数据库的名称;

  1. "Point A" creates a temporary queue ("destination 2") on the message broker;
  2. Message sent from point A to destination 1 (a normal queue on the message broker), with the ReplyTo address set as destination 2;
  3. point A blocks waiting for response on destination 2;
  4. point B receives message from destination 1;
  5. point B creates a work object - a property of which is the name of destination 2 (derived using .ToString()". This work object is serialized and stored in the DB;

...


  1. 对象从数据库中检索时,某些参数得到满足,改变ocurr和一个响应发送到目的地2 - 使用SessionUtil派生从存储为工作对象的字符串属性的ReplyTo地址的新IDestination对象;

  2. A点,从目标2临危消息并继续上。

这过程可能需要一个分裂的任何秒到几秒钟才能完成。

This process can take anything from a split second to several seconds to accomplish.

我需要使用返回目的地的名称(目标2),而不是整个IDestination对象,我必须序列在数据库对象和存储。

I need to use the name of the return destination (destination 2), rather than the full IDestination object, as I have to serialize the object and store in the DB.

如果我使用永久队列或主题作为目标2,过程工作正常。然而,它总是失败时尝试使用临时队列的字符串名称创建它。

If I use a permanent queue or a topic as destination 2, the process works fine. However, it always fails when attempting to create it using the string name of the temporary queue.

有没有错误,消息只不过没有到达

There are no errors, the message just fails to arrive

任何想法,为什么

发送显示返回的消息示例代码:

Example code for sending return message shown:

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);
}                
}



(实例为工作对象 - 它包含中的ReplyTo地址等信息)

("instance" is the work object - which contains the ReplyTo address and other information)

推荐答案

一个临时目标,只是,暂时的。一旦创建了临时目标的Connection对象关闭,目的地是自动从代理删除。存储用于以后使用的临时目的地是不是这个原因是个好主意。另外,只有创建的临时目的地的连接被允许消耗就可以了。

A temporary destination is just that, temporary. Once the Connection object that created the Temporary Destination closes, the destination is automatically removed from the broker. Storing the temp destination for later use is not a good idea for this reason. Also, only the Connection that created the temp destination is allowed to consume on it.

这篇关于ActiveMQ的 - 发送消息到一个临时队列使用字符串指定的NMS(在C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆