Hello Alan,
It seems that if the connection is lasting for some time, I don't have the
TIME_WAIT at all.
I was able to bypass the issue and have my producer only open one connection
for all messages but I would like to verify with you it is a correct
approach.
When the producer starts, The main thread creates the proton::container in a
second thread. Both threads share a a queue protected by a common lock.
The main thread produces messages and adds them to the queue.
The 2nd thread will execute "on_sendable" and does the following algorithm:
* If there are messages in the queue he sends them. As there was activity
here, the "on_sendable" will be called a 2nd time.
* If there are no messages, he closes the sender and re-opens it to trigger
another call to "on_sendable".
It seems that closing the sender and re-opening it doesn't close/re-open the
connection. So it works for me.
Is this behavior still true with proton 0.13.x?
void on_start(proton::event &e)
{
std::cout<<"SimpleSenderHandler::on_start " << std::endl;
proton::connection conn = e.container().connect(url);
conn.open_sender(dest);
}
void on_sendable(proton::event &e)
{
proton::sender sender = e.sender();
std::cout<<"SimpleSenderHandler::on_sendable: sender_credit=" <<
sender.credit() <<std::endl;
bool nothingSent = true;
while(sender.credit() && !m_queue.empty()) {
std::cout<<"\tSending msg " << std::endl;
proton::message m = m_queue.pop();
sender.send(m);
nothingSent = false;
}
if (nothingSent) {
e.sender().close();
e.connection().open_sender(dest);
}
}
void on_delivery_accept(proton::event &e)
{
std::cout<<"SimpleSenderHandler::on_delivery_accept" << std::endl;
}
Output
SimpleSenderHandler::on_start
SimpleSenderHandler::on_sendable: sender_credit=100
Sending msg
Sending msg
SimpleSenderHandler::on_sendable: sender_credit=98
SimpleSenderHandler::on_delivery_accept
SimpleSenderHandler::on_delivery_accept
SimpleSenderHandler::on_sendable: sender_credit=100
SimpleSenderHandler::on_sendable: sender_credit=100
Sending msg
SimpleSenderHandler::on_sendable: sender_credit=99
SimpleSenderHandler::on_delivery_accept
SimpleSenderHandler::on_sendable: sender_credit=100
SimpleSenderHandler::on_sendable: sender_credit=100
SimpleSenderHandler::on_sendable: sender_credit=100
Sending msg
SimpleSenderHandler::on_sendable: sender_credit=99
SimpleSenderHandler::on_delivery_accept
SimpleSenderHandler::on_sendable: sender_credit=100
SimpleSenderHandler::on_sendable: sender_credit=100
SimpleSenderHandler::on_sendable: sender_credit=100
Regards,
Adel
--
View this message in context:
http://qpid.2158936.n2.nabble.com/Java-Broker-6-0-1-AMQP-random-errors-when-sending-messages-using-Proton-c-0-12-2-tp7648822p7649176.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]