Experience in using message bus in lesson 5 of Qpid
The qpid-broker server uses Java language version 6.1.4
Related materials
Http://qpid.apache.org/documentation.html
Question 1)
Whether the message sent to the qpid server is always saved in memory if it is not consumed by other clients
May cause the server to run out of memory and crash, because the server's memory is set to 512MB in the first place
Solution: specify the timeout of the message, and delete it if it times out
Question 2)
For messages sent to the qpid server, will a similar problem occur if the client disconnects due to a timeout?
Qpid C++ programming example
Http://qpid.apache.org/releases/qpid-cpp-1.36.0/messaging-api/cpp/examples/client.cpp.html
Download the version of qpid-cpp-1.35.0
Detailed compilation reference can be found in the source code file INSTALL-WINDOWS.txt
Code
Int HandleQPID ()
{
Std::string connectionOptions = ""
Connection connection (192.168.1.12 7070 ", connectionOptions)
Connection.setOption ("username", "admin")
Connection.setOption ("password", "admin")
/ / in the case of true, an attempt to reconnect will result in subsequent blocking
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
/ / if Duration is not specified, if the message received by the server has not been returned, it will always be blocked here!
If (receiver.fetch (response, Duration (300))
{
Info.strRecvContext = response.getContent ()
Std::cout