Пример #1
0
        /// <summary>
        /// Writes a producer request to the server.
        /// </summary>
        /// <remarks>
        /// Write timeout is defaulted to infitite.
        /// </remarks>
        /// <param name="request">The <see cref="ProducerRequest"/> to send to the server.</param>
        public void Write(AbstractRequest request)
        {
            this.EnsuresNotDisposed();
            Guard.NotNull(request, "request");
            if (this.socketPollingLevel == SocketPollingLevel.DOUBLE)
            {
                PollSocket();
            }

            this.Write(request.RequestBuffer.GetBuffer());

            if (this.socketPollingLevel == SocketPollingLevel.SINGLE ||
                this.socketPollingLevel == SocketPollingLevel.DOUBLE)
            {
                PollSocket();
            }
        }
Пример #2
0
        /// <summary>
        /// Writes a producer request to the server asynchronously.
        /// </summary>
        /// <param name="request">The request to make.</param>
        public void BeginWrite(AbstractRequest request)
        {
            this.EnsuresNotDisposed();
            Guard.NotNull(request, "request");

            try
            {
                NetworkStream stream = client.GetStream();
                byte[]        data   = request.RequestBuffer.GetBuffer();
                stream.BeginWrite(data, 0, data.Length, asyncResult => ((NetworkStream)asyncResult.AsyncState).EndWrite(asyncResult), stream);
            }
            catch (InvalidOperationException e)
            {
                throw new KafkaConnectionException(e);
            }
            catch (IOException e)
            {
                throw new KafkaConnectionException(e);
            }
        }
Пример #3
0
 /// <summary>
 /// Writes a producer request to the server.
 /// </summary>
 /// <remarks>
 /// Write timeout is defaulted to infitite.
 /// </remarks>
 /// <param name="request">The <see cref="ProducerRequest"/> to send to the server.</param>
 public void Write(AbstractRequest request)
 {
     this.EnsuresNotDisposed();
     Guard.NotNull(request, "request");
     this.Write(request.RequestBuffer.GetBuffer());
 }