Closed tong3jie closed 1 week ago
Please provide stream info
and consumer info
so we can be sure about the subject filters.
@Jarema thanks
the config of stream
jsconfig := &nats.StreamConfig{
Name: "ABC",
Subjects: []string{ "ABC.*"},
}
the config of consumer
consumerConfig := &nats.ConsumerConfig{
Durable: "test",
AckPolicy: nats.AckExplicitPolicy,
DeliverPolicy: nats.DeliverAllPolicy,
AckWait: time.Second * 10,
MaxDeliver: 5,
MaxAckPending: 100,
FilterSubject: "ABC.test",
MaxRequestBatch: 100,
}
the data of message
message := &nats.Msg{
Subject: "ABC.test",
Data: msg,
Header: nheaders,
}
_, err := ns.js.PublishMsg(message)
return err
}
thanks
@tong3jie it is worth checking if there is a "Slow consumer detected" in the logs. This may be due to the large values of maxBatch and maxPullBytes. It is worth trying to set these values lower. Judging by the internal size of the queue in nats (64 MB), maxPullBytes should be no more than 64 MB
@tong3jie Please check the actual config of stream and consumer in the server (by checking the returned info or using the CLI nats stream info
and nats consumer info
). It is really easy to make a mistake. Server won't complain if consumer does not match subjects in stream.
Also, Checking len
of Messages()
, which returns a channel probably will always return 0 if called immediately after FetchBatch
- messages might not yet start flowing in, as the FetchBatch
returns immediately after sending the request to the server and do not wait for anything.
You do not need to check the channel length either - channel is closed when fetch completes.
Seeing your logic, I think you should migrate to the new API and use Consume
or Messages
from its API - it will handle all the logic of sending you Fetches after previous finished etc.
https://github.com/nats-io/nats.go/blob/main/jetstream/README.md
I checked the consumer and fond that the number of ack_pending was so slow .
thanks ,I'll try new api .
If I understood you correctly, this issue can be closed. If I'm mistaken, feel free to reopen it with a follow up.
Observed behavior
NATS consumers can't pull any messages from Jetstream
Expected behavior
example: the name of stream is ABC the topic of message is ABC.ORDER the topic of sub Messages is ABC.ORDER
I can't get any message.
Server and client version
server: v2.10.22 client: v1.37.0
Host environment
No response
Steps to reproduce