diff --git a/Driver/Internal/MongoConnection.cs b/Driver/Internal/MongoConnection.cs index 6ed1671e9f..25efb84683 100644 --- a/Driver/Internal/MongoConnection.cs +++ b/Driver/Internal/MongoConnection.cs @@ -61,6 +61,7 @@ namespace MongoDB.Driver.Internal { private DateTime createdAt; private DateTime lastUsedAt; // set every time the connection is Released private int messageCounter; + private int requestId; private Dictionary authentications = new Dictionary(); #endregion @@ -105,6 +106,13 @@ namespace MongoDB.Driver.Internal { get { return messageCounter; } } + /// + /// Gets the RequestId of the last message sent on this connection. + /// + public int RequestId { + get { return requestId; } + } + /// /// Gets the server instance this connection is connected to. /// @@ -378,6 +386,8 @@ namespace MongoDB.Driver.Internal { ) { if (state == MongoConnectionState.Closed) { throw new InvalidOperationException("Connection is closed."); } lock (connectionLock) { + requestId = message.RequestId; + message.WriteToBuffer(); CommandDocument safeModeCommand = null; if (safeMode.Enabled) {