Skip to content

Commit

Permalink
NATS: add default ack wait timeout (#26)
Browse files Browse the repository at this point in the history
* NATS: add default ack wait timeout

The lack of default value causes ACK timeout immediately, if not supplied.
  • Loading branch information
m110 authored and roblaszczak committed Dec 20, 2018
1 parent c99b3f5 commit b161620
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions message/infrastructure/nats/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,16 @@ func (c *StreamingSubscriberConfig) setDefaults() {
if c.CloseTimeout <= 0 {
c.CloseTimeout = time.Second * 30
}
if c.AckWaitTimeout <= 0 {
c.AckWaitTimeout = time.Second * 30
}

c.StanSubscriptionOptions = append(
c.StanSubscriptionOptions,
stan.SetManualAckMode(), // manual AckMode is required to support acking/nacking by client
stan.AckWait(c.AckWaitTimeout),
)

if c.AckWaitTimeout != 0 {
c.StanSubscriptionOptions = append(c.StanSubscriptionOptions, stan.AckWait(c.AckWaitTimeout))
}
if c.DurableName != "" {
c.StanSubscriptionOptions = append(c.StanSubscriptionOptions, stan.DurableName(c.DurableName))
}
Expand Down

0 comments on commit b161620

Please # to comment.