Next is used to retrieve the next message from the stream. This method will block until the message is retrieved or timeout is reached. It is not efficient to use Next with on an ordered consumer, as it will reset the consumer for each subsequent Fetch call. Consider using [Consumer.Consume] or [Co
(opts ...FetchOpt)
| 526 | // reset the consumer for each subsequent Fetch call. |
| 527 | // Consider using [Consumer.Consume] or [Consumer.Messages] instead. |
| 528 | func (c *orderedConsumer) Next(opts ...FetchOpt) (Msg, error) { |
| 529 | res, err := c.Fetch(1, opts...) |
| 530 | if err != nil { |
| 531 | return nil, err |
| 532 | } |
| 533 | msg := <-res.Messages() |
| 534 | if msg != nil { |
| 535 | return msg, nil |
| 536 | } |
| 537 | if res.Error() == nil { |
| 538 | return nil, nats.ErrTimeout |
| 539 | } |
| 540 | return nil, res.Error() |
| 541 | } |
| 542 | |
| 543 | func serialNumberFromConsumer(name string) int { |
| 544 | if len(name) == 0 { |