| 622 | } |
| 623 | |
| 624 | func ExampleAckWait() { |
| 625 | nc, _ := nats.Connect("localhost") |
| 626 | js, _ := nc.JetStream() |
| 627 | |
| 628 | // Set custom timeout for a JetStream API request. |
| 629 | js.AddStream(&nats.StreamConfig{ |
| 630 | Name: "FOO", |
| 631 | Subjects: []string{"foo"}, |
| 632 | }) |
| 633 | |
| 634 | // Wait for an ack response for 2 seconds. |
| 635 | js.Publish("foo", []byte("Hello JS!"), nats.AckWait(2*time.Second)) |
| 636 | |
| 637 | // Create consumer on 'foo' subject that waits for an ack for 10s, |
| 638 | // after which the message will be delivered. |
| 639 | sub, _ := js.SubscribeSync("foo", nats.AckWait(10*time.Second)) |
| 640 | msg, _ := sub.NextMsg(2 * time.Second) |
| 641 | |
| 642 | // Wait for ack of ack for 2s. |
| 643 | msg.AckSync(nats.AckWait(2 * time.Second)) |
| 644 | } |
| 645 | |
| 646 | func ExampleMsg_AckSync() { |
| 647 | nc, _ := nats.Connect("localhost") |