qpid-broker服务器采用Java语言版本6.1.4
相关资料
http://qpid.apache.org/documentation.html
问题1)
发送到qpid服务器上的消息,如果没有被其他的客户端消费是否一直保存在内存中,
可能导致服务器内存耗尽,服务器崩溃,因为服务器的内存一开始就是设置为512MB
问题2)
发送到qpid服务器上的消息,如果由于超时,客户端断开连接,是否也会出现上述类似的问题
qpid-cpp项目编译参考
http://www.it165.net/admin/html/201406/3341.html
由于复杂以及时间问题,并没有在短时间内编译出来
qpid C++编程例子
http://qpid.apache.org/releases/qpid-cpp-1.36.0/messaging-api/cpp/examples/client.cpp.html
下载版本qpid-cpp-1.35.0
详细的编译参考可以在源码中找到文件INSTALL-WINDOWS.txt
代码
int HandleQPID()
{
std::string connectionOptions = "";
Connection connection("192.168.1.12:7070", connectionOptions);
connection.setOption("username", "admin");
connection.setOption("password", "admin");
//true的情况下,尝试重连会导致后续一直的阻塞
connection.setOption("reconnect", false);
try
{
connection.open();
Session session = connection.createSession();
Sender sender = session.createSender(info.strMessageAddress);
Message request;
request.setContent(info.strSendContext);
session.sync();
Address responseQueue("#response-queue; {create:always, delete:always}");
request.setReplyTo(responseQueue);
sender.send(request);
Receiver receiver = session.createReceiver(responseQueue);
try
{
Message response;
//如果不指定Duration,如果服务器接收到的报文一直没有返回,在这里会一直阻塞!!
if (receiver.fetch(response, Duration(300)))
{
info.strRecvContext = response.getContent();
std::cout << "info" << std::endl;
std::cout << info.strRecvContext << std::endl;
}
session.acknowledge();
}
catch (const std::exception& error)
{
std::cout << "receiver.fetch exception:" << error.what() << std::endl;
session.acknowledge();
session.close();
connection.close();
return -1;
}
session.close();
connection.close();
return 0;
}
catch (const std::exception& error)
{
//std::cout << "E:" << error.what() << std::endl;
info.strRecvContext = "";
connection.close();
return -1;
}
}