0
ActiveMQ C++ Client有一些code samples,它们是异步的。我正在寻找的是同步消费者。我只想发送和获取消息。我指出的代码使用了异步,并不确定如何从中创建一个同步类。ActiveMQ C++同步消费者
MessageConsumer class表示有一个同步调用,即:recieve()。 当我在我的对象上调用它时失败,如下,我该如何解决这个问题?我如何才能从队列中调用接收器。
ActiveMQConsumer.cc: In member function `virtual void ActiveMQConsumer::getMessage()':
ActiveMQConsumer.cc:62: error: 'class cms::MessageConsumer' has no member named 'recieve'
In file included from ActiveMQWrapper.cc:29:
ActiveMQConsumer.cc: In member function `virtual void ActiveMQConsumer::getMessage()':
ActiveMQConsumer.cc:62: error: 'class cms::MessageConsumer' has no member named 'recieve'
ActiveMQWrapper.cc: In static member function `static std::string ActiveMQWrapper::get()':
ActiveMQWrapper.cc:58: error: base operand of `->' has non-pointer type `ActiveMQConsumer'
这里是代码:
void ActiveMQWrapper::get(){
std:string brokerURI = "tcp://localhost:61613?wireFormat=stomp";
ActiveMQConsumer consumer(brokerURI);
consumer->getMessage();
}
// ActiveMQConsumer class code is following
virtual void getMessage() {
try {
auto_ptr<ConnectionFactory> connectionFactory(ConnectionFactory::createCMSConnectionFactory(brokerURI));
connection = connectionFactory->createConnection();
connection->start();
session = connection->createSession(Session::AUTO_ACKNOWLEDGE);
destination = session->createQueue("TEST.Prototype");
consumer = session->createConsumer(destination);
std::cout<<consumer->recieve();
} catch(CMSException& e) {
e.printStackTrace();
}
}