use of com.mongodb.event.ConnectionMessagesSentEvent in project mongo-java-driver by mongodb.
the class InternalStreamConnection method sendMessage.
@Override
public void sendMessage(final List<ByteBuf> byteBuffers, final int lastRequestId) {
notNull("stream is open", stream);
if (isClosed()) {
throw new MongoSocketClosedException("Cannot write to a closed stream", getServerAddress());
}
writerLock.lock();
try {
int messageSize = getMessageSize(byteBuffers);
stream.write(byteBuffers);
connectionListener.messagesSent(new ConnectionMessagesSentEvent(getId(), lastRequestId, messageSize));
} catch (Exception e) {
close();
throw translateWriteException(e);
} finally {
writerLock.unlock();
}
}
Aggregations