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)
| 790 | // If more fine-grained control of when offsets are committed is required, it |
| 791 | // is recommended to use FetchMessage with CommitMessages instead. |
| 792 | func (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 |