开发者

How to prevent ActiveMQ CPP send method from blocking forever?

开发者 https://www.devze.com 2023-04-09 19:44 出处:网络
I am developing a software that uses ActiveMQ C++ library. The problem that I have is, when I try to send a message and the network is down, the send method (method of cms::MessageProducer class) bloc

I am developing a software that uses ActiveMQ C++ library. The problem that I have is, when I try to send a message and the network is down, the send method (method of cms::MessageProducer class) blocks forever and I need to recover the control in this case.

I am using pe开发者_高级运维rsistent deliver mode (It is compulsory, I can't avoid it).


Do you set the sendTimeout when you create ActiveMQConnectionFactory? It is set to 0 by default, which means "infinite".

auto_ptr<ActiveMQConnectionFactory> connectionFactory(
     new ActiveMQConnectionFactory( brokerURI ) );
connectionFactory->setSendTimeout( 1000 ); // number of milliseconds
// ...
// creating Session and MessageProducer as usually
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号