Example #1
0
        /// <summary>
        /// Get a list of valid offsets (up to maxSize) before the given time.
        /// </summary>
        /// <param name="topic">The topic to check.</param>
        /// <param name="time">time in millisecs (if -1, just get from the latest available)</param>
        /// <param name="maxNumOffsets">That maximum number of offsets to return.</param>
        /// <param name="correlationId"></param>Id used by the client to identify this transaction. Returned in the response
        /// <param name="clientId"></param>Name to identify the client. Used in server logs
        /// <param name="partitionId">The partition on the topic.</param>
        /// <returns>OffseRersponse</returns>
        public OffsetResponse GetOffsetResponse(string topic, long time, int maxNumOffsets, int correlationId, string clientId, int partitionId)
        {
            var request = new OffsetRequest(correlationId, clientId);

            request.AddTopic(topic, partitionId, time, maxNumOffsets);
            return(GetOffsetResponseBefore(request));
        }
Example #2
0
        /// <summary>
        /// Get a list of valid offsets (up to maxSize) before the given time.
        /// </summary>
        /// <param name="topic">The topic to check.</param>
        /// <param name="clientId"></param>Name to identify the client. Used in server logs
        /// <param name="partitionId">The partition on the topic.</param>
        /// <returns>OffseRersponse containing the first offser for the topic</returns>
        public OffsetResponse GetStartOffset(string topic, string clientId, int partitionId)
        {
            var request = new OffsetRequest(DefaultCorrelationId, clientId);

            request.AddTopic(topic, partitionId, OffsetRequest.EarliestTime, 1);
            return(GetOffsetResponseBefore(request));
        }
Example #3
0
        /// <summary>
        /// Create an OffsetRequest to get the message offset for each requsted topic/partition
        /// </summary>
        /// <param name="topics"></param>List of topics to get offset for
        /// <param name="time"></param>Used to ask for all messages before a certain time (ms). Specify -1 to receive the latest offsets and -2 to receive the earliest available offset. Note that because offsets are pulled in descending order, asking for the earliest offset will always return you a single element.
        /// <param name="maxNumOffsets"></param>Max number of offsets to receive. Returns 2 when time = -1 firsrt and current. Returns 1 when time = -2
        /// <param name="correlationId"></param>Id used by the client to identify this transaction. Returned in the response
        /// <param name="clientId"></param>Name to identify the client. Used in server logs
        /// <param name="partitionId"></param>Requested partition
        /// <returns></returns>
        public OffsetResponse GetOffsetResponse(List <string> topics, long?time, int maxNumOffsets, int correlationId, string clientId, int partitionId)
        {
            var requestTime = time.GetValueOrDefault(OffsetRequest.LatestTime);

            var request = new OffsetRequest(correlationId, clientId);

            foreach (var topicName in topics)
            {
                request.AddTopic(topicName, partitionId, requestTime, maxNumOffsets);
            }
            return(GetOffsetResponseBefore(request));
        }