除SimpleMessageListenerContainer
选项外,不会为临时队列创建使用者。 我不会为一些问题用SimpleMessageListenerContainer
面临here.为什么消费者不是为ActiveMQ Temp Queue创建的?
下面的代码是不工作...(是不是即使在创建临时队列)
using (IConnection connection = connectionFactory.CreateConnection())
using (ISession session = connection.CreateSession())
{
IDestination destination = SessionUtil.GetDestination(session, aQueueName);
var replyDestination = session.CreateTemporaryQueue();
// Create a consumer and producer
using (IMessageProducer producer = session.CreateProducer(destination))
{
// Start the connection so that messages will be processed.
connection.Start();
IBytesMessage request = session.CreateBytesMessage(aMsg);
request.NMSReplyTo = replyDestination;
IMessageConsumer consumer = session.CreateConsumer(replyDestination);
consumer.Listener += new MessageListener(this.OnAckRecieved);
// Send a message
producer.Send(request);
ack = this.autoEvent.WaitOne(this.msgConsumeTimeOut, true);
consumer.Close();
consumer.Dispose();
ConnectionFactoryUtils.GetTargetSession(session).DeleteDestination(replyDestination);
}
connection.Close();
session.Close();
Flollowing代码工作: - 但是队列似乎是永久队列不一个临时队列
using (IConnection connection = connectionFactory.CreateConnection())
using (ISession session = connection.CreateSession())
{
IDestination destination = SessionUtil.GetDestination(session, aQueueName);
var replyDestination = session.CreateTemporaryQueue();
// Create a consumer and producer
using (IMessageProducer producer = session.CreateProducer(destination))
{
// Start the connection so that messages will be processed.
connection.Start();
IBytesMessage request = session.CreateBytesMessage(aMsg);
request.NMSReplyTo = replyDestination;
IDestination tempDestination = this.destinationResolver.ResolveDestinationName(session, request.NMSReplyTo.ToString());
IMessageConsumer consumer = session.CreateConsumer(tempDestination);
consumer.Listener += new MessageListener(this.OnAckRecieved);
// Send a message
producer.Send(request);
ack = this.autoEvent.WaitOne(this.msgConsumeTimeOut, true);
consumer.Close();
consumer.Dispose();
ConnectionFactoryUtils.GetTargetSession(session).DeleteDestination(tempDestination);
}
connection.Close();
session.Close();
与上面的代码(使用NmsDestinationAccessor的)它是working.but它创建一个永久队列。因此,当我直接使用临时队列答复目标时,它不起作用。
你的意思是什么“未创建”,CreateConsumer()抛出任何异常或只是返回null? –
根本没有错误。当我在webconsole上看到时,即使不为第二个代码创建临时队列。对于第三个代码,只有消费者未被创建。 –
在NMS项目中增加了一个示例NUnit测试,以显示它的实际应用。 –