MCPcopy
hub / github.com/segmentio/kafka-go / ReadMessage

Method ReadMessage

reader.go:792–805  ·  view source on GitHub ↗

ReadMessage reads and return the next message from the r. The method call blocks until a message becomes available, or an error occurs. The program may also specify a context to asynchronously cancel the blocking operation. The method returns io.EOF to indicate that the reader has been closed. If

(ctx context.Context)

Source from the content-addressed store, hash-verified

790// If more fine-grained control of when offsets are committed is required, it
791// is recommended to use FetchMessage with CommitMessages instead.
792func (r *Reader) ReadMessage(ctx context.Context) (Message, error) {
793 m, err := r.FetchMessage(ctx)
794 if err != nil {
795 return Message{}, fmt.Errorf("fetching message: %w", err)
796 }
797
798 if r.useConsumerGroup() {
799 if err := r.CommitMessages(ctx, m); err != nil {
800 return Message{}, fmt.Errorf("committing message: %w", err)
801 }
802 }
803
804 return m, nil
805}
806
807// FetchMessage reads and return the next message from the r. The method call
808// blocks until a message becomes available, or an error occurs. The program

Calls 3

FetchMessageMethod · 0.95
useConsumerGroupMethod · 0.95
CommitMessagesMethod · 0.95