【发布时间】:2013-12-24 02:47:50
【问题描述】:
我是activemq的新手。 T 想问一个关于 Activemq 主题的问题。我成功地从队列中获取消息。我也可以向主题/队列发送消息,但我无法从主题中获取消息。
我尝试过使用 Java 代码。结果是一样的。
以下是我的核心代码:
connection.ClientId = clientId;
connection.Start();
using (ISession session = connection.CreateSession())
{
ITopic topic = new Apache.NMS.Commands.Topic(topicName);
IDestination destination = SessionUtil.GetDestination(session, topicName,
DestinationType.Topic);
using (IMessageConsumer consumer = **session.CreateDurableConsumer**(topic, "news", null, false))
{
**consumer.Listener += new MessageListener(consumer_Listener);**
//**IMessage iMsg = consumer.Receive();**
// if (iMsg != null)//{
// ITextMessage msg = (ITextMessage)iMsg;
// return msg.Text;
// }
//else
//return iMsg;
}
}
我也使用:IMessage iMsg = consumer.Receive();
IMsg 永远为空(topicname有消息。如何使用主题的消息?
【问题讨论】: