diff --git a/jetstream/resource_jetstream_consumer.go b/jetstream/resource_jetstream_consumer.go index 6a4463d..bb64a8a 100644 --- a/jetstream/resource_jetstream_consumer.go +++ b/jetstream/resource_jetstream_consumer.go @@ -193,12 +193,13 @@ func resourceConsumer() *schema.Resource { ForceNew: true, }, "max_waiting": { - Type: schema.TypeInt, - Description: "The number of pulls that can be outstanding on a pull consumer, pulls received after this is reached are ignored", - Optional: true, - Default: 512, - ForceNew: false, - ValidateFunc: validation.IntAtLeast(0), + Type: schema.TypeInt, + Description: "The number of pulls that can be outstanding on a pull consumer, pulls received after this is reached are ignored", + Optional: true, + Computed: true, + ConflictsWith: []string{"delivery_subject"}, + ForceNew: false, + ValidateFunc: validation.IntAtLeast(0), }, "headers_only": { Type: schema.TypeBool, @@ -291,7 +292,12 @@ func consumerConfigFromResourceData(d *schema.ResourceData) (cfg api.ConsumerCon if cfg.DeliverSubject != "" { cfg.DeliverGroup = d.Get("delivery_group").(string) } else { - cfg.MaxWaiting = d.Get("max_waiting").(int) + if max_waiting := d.Get("max_waiting").(int); max_waiting == 0 { + // set default value. default cannot be set because this field is computed + max_waiting = 512 + } else { + cfg.MaxWaiting = max_waiting + } } for _, d := range d.Get("backoff").([]any) { diff --git a/jetstream/resource_jetstream_consumer_test.go b/jetstream/resource_jetstream_consumer_test.go index 3a1a676..adc357c 100644 --- a/jetstream/resource_jetstream_consumer_test.go +++ b/jetstream/resource_jetstream_consumer_test.go @@ -51,6 +51,7 @@ resource "jetstream_consumer" "TEST_C2" { stream_sequence = 10 max_ack_pending = 20 filter_subjects = ["TEST.a", "TEST.b"] + max_waiting = 10 } ` @@ -70,6 +71,7 @@ resource "jetstream_consumer" "TEST_C3" { stream_sequence = 10 max_ack_pending = 20 filter_subject = "TEST.a" + delivery_subject = "ORDERS.a" } `