Skip to content

Commit

Permalink
use QueueDeclarePassive (#1209)
Browse files Browse the repository at this point in the history
Co-authored-by: Iiqbal2000 <[email protected]>
  • Loading branch information
knative-prow-robot and Iiqbal2000 authored Aug 25, 2023
1 parent 7031a4e commit 3704acb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion pkg/adapter/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,14 @@ func (a *Adapter) PollForMessages(stopCh <-chan struct{}) error {

for {
if channel := a.rmqHelper.GetChannel(); channel != nil {
if queue, err = channel.QueueInspect(a.config.QueueName); err == nil {
if queue, err = channel.QueueDeclarePassive(
a.config.QueueName,
true,
false,
false,
false,
amqp.Table{},
); err == nil {
connNotifyChannel, chNotifyChannel := a.rmqHelper.GetConnection().NotifyClose(make(chan *amqp.Error)), channel.NotifyClose(make(chan *amqp.Error))
if msgs, err = a.ConsumeMessages(&queue, channel, logger); err == nil {
loop:
Expand Down
2 changes: 1 addition & 1 deletion pkg/rabbit/connections_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type RabbitMQChannelInterface interface {
Confirm(bool) error
Consume(string, string, bool, bool, bool, bool, amqp091.Table) (<-chan amqp091.Delivery, error)
PublishWithDeferredConfirm(string, string, bool, bool, amqp091.Publishing) (*amqp091.DeferredConfirmation, error)
QueueInspect(string) (amqp091.Queue, error)
QueueDeclarePassive(string, bool, bool, bool, bool, amqp091.Table) (amqp091.Queue, error)
}

type RabbitMQConnectionHandler struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/rabbit/connections_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func Test_InvalidSetupRabbitMQ(t *testing.T) {
t.Errorf("unexpected closed connection error")
}

if _, err := rabbitMQHelper.Channel.QueueInspect("test"); err != nil {
if _, err := rabbitMQHelper.Channel.QueueDeclarePassive("test", true, true, true, true, amqp091.Table{}); err != nil {
t.Errorf("unexpected queue inspect error")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/rabbit/rabbit_mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (rm *RabbitMQChannelMock) Confirm(a bool) error {
return nil
}

func (rm *RabbitMQChannelMock) QueueInspect(string) (amqp.Queue, error) {
func (rm *RabbitMQChannelMock) QueueDeclarePassive(name string, durable, autoDelete, exclusive, noWait bool, args amqp.Table) (amqp.Queue, error) {
return amqp.Queue{}, nil
}

Expand Down

0 comments on commit 3704acb

Please sign in to comment.