Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Experience in using message bus in lesson 5 of Qpid

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report