event hub: a start that found no durable on the bus is tried again at the next start, so a part is not lost for the order in which the bus makes its consumer (B7e; issue 1966)
Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
This commit is contained in:
@@ -156,4 +156,31 @@ func TestTheViewsReaderAndTwoHandlersShareTheModulesOneDurable(t *testing.T) {
|
||||
if info, err := cons.Info(ctx); err != nil || info.NumAckPending != 0 {
|
||||
t.Fatalf("a message was left unacknowledged: %+v %v", info, err)
|
||||
}
|
||||
// A hub started before the bus holds its durable says so, and binds at a later start: a module is not lost for the
|
||||
// order in which the bus makes its consumer.
|
||||
late := process.Account{Node: "n1", Module: "late"}
|
||||
lateHub := process.NewEventHub(t.Logf)
|
||||
heard := make(chan string, 1)
|
||||
if err := lateHub.Handle("mesh.mod.l.event.>", func(m jetstream.Msg) { _ = m.Ack(); heard <- m.Subject() }); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer lateHub.Stop()
|
||||
if err := lateHub.Start(ctx, js, late); err == nil {
|
||||
t.Fatal("a hub with no durable on the bus started")
|
||||
}
|
||||
if _, err := js.CreateOrUpdateConsumer(ctx, process.EventsStream, jetstream.ConsumerConfig{Durable: late.EventConsumerName(),
|
||||
AckPolicy: jetstream.AckExplicitPolicy, FilterSubjects: []string{"mesh.mod.l.event.>"}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := lateHub.Start(ctx, js, late); err != nil {
|
||||
t.Fatalf("the hub did not bind at its second start: %v", err)
|
||||
}
|
||||
if _, err := js.Publish(ctx, "mesh.mod.l.event.x", []byte("{}")); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
select {
|
||||
case <-heard:
|
||||
case <-time.After(10 * time.Second):
|
||||
t.Fatal("the hub started late heard nothing")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user