fix(nats): revert to consumer.messages() — fetch() defaults no_wait:true which skips empty queues
Some checks failed
lint / lint (push) Has been cancelled
test / unit (push) Has been cancelled
test / integration (push) Has been cancelled
lint / lint (pull_request) Failing after 9m21s
test / unit (pull_request) Failing after 10m57s
test / integration (pull_request) Failing after 16m44s
Some checks failed
lint / lint (push) Has been cancelled
test / unit (push) Has been cancelled
test / integration (push) Has been cancelled
lint / lint (pull_request) Failing after 9m21s
test / unit (pull_request) Failing after 10m57s
test / integration (pull_request) Failing after 16m44s
This commit is contained in:
@@ -139,19 +139,14 @@ impl MessageSource for NatsMessageSource {
|
|||||||
tracing::info!("NATS pull consumer ready");
|
tracing::info!("NATS pull consumer ready");
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
// fetch().expires() keeps the request open server-side until messages arrive
|
// consumer.messages() uses long-poll (no no_wait flag) — NATS holds the
|
||||||
// (up to 30 s), then the batch ends and we loop. Without expires, the fetch
|
// request open and delivers messages as they arrive.
|
||||||
// returns immediately with zero messages when the queue is empty.
|
// fetch() in async-nats 0.48 defaults to no_wait:true which returns
|
||||||
let mut messages = match consumer
|
// immediately when the queue is empty, so we avoid it here.
|
||||||
.fetch()
|
let mut messages = match consumer.messages().await {
|
||||||
.max_messages(100)
|
|
||||||
.expires(std::time::Duration::from_secs(30))
|
|
||||||
.messages()
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
tracing::error!("NATS fetch failed: {e}");
|
tracing::error!("NATS messages() failed: {e}");
|
||||||
let _ = tx.send(Err(DomainError::Internal(e.to_string()))).await;
|
let _ = tx.send(Err(DomainError::Internal(e.to_string()))).await;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user