Skip to content
Open

fix #17

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/ProducerImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,14 @@ Future<Result, bool> ProducerImpl::connectionOpened(const ClientConnectionPtr& c
// Keep a reference to ensure object is kept alive.
auto self = shared_from_this();
setFirstRequestIdAfterConnect(requestId);
newProducerRequestId_ = requestId;
cnx->sendRequestWithId(cmd, requestId)
.addListener([this, self, cnx, promise](Result result, const ResponseData& responseData) {
.addListener([this, self, cnx, promise, requestId](Result result, const ResponseData& responseData) {
if (!newProducerRequestId_ || newProducerRequestId_.get() != requestId) {
LOG_WARN(getName() << "Received response for an old request, ignoring");
return;
}

Result handleResult = handleCreateProducer(cnx, result, responseData);
if (handleResult == ResultOk) {
promise.setSuccess();
Expand Down Expand Up @@ -977,6 +983,7 @@ bool ProducerImpl::encryptMessage(proto::MessageMetadata& metadata, SharedBuffer
void ProducerImpl::disconnectProducer(const boost::optional<std::string>& assignedBrokerUrl) {
LOG_INFO("Broker notification of Closed producer: "
<< producerId_ << (assignedBrokerUrl ? (" assignedBrokerUrl: " + assignedBrokerUrl.get()) : ""));
newProducerRequestId_.reset();
resetCnx();
scheduleReconnection(assignedBrokerUrl);
}
Expand Down
2 changes: 2 additions & 0 deletions lib/ProducerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ class ProducerImpl : public HandlerBase, public ProducerImplBase {
ProducerInterceptorsPtr interceptors_;

bool retryOnCreationError_;

boost::optional<uint64_t> newProducerRequestId_;
};

struct ProducerImplCmp {
Expand Down