Skip to content

Commit

Permalink
Fix: do not declare queue on publish
Browse files Browse the repository at this point in the history
  • Loading branch information
runabol committed Dec 12, 2023
1 parent 353065a commit 177c15e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 0 additions & 3 deletions mq/rabbitmq.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,6 @@ func (b *RabbitMQBroker) PublishTask(ctx context.Context, qname string, t *tork.
return errors.Wrapf(err, "error creating channel")
}
defer ch.Close()
if err := b.declareQueue(exchangeDefault, keyDefault, qname, ch); err != nil {
return errors.Wrapf(err, "error (re)declaring queue")
}
return b.publish(ctx, exchangeDefault, qname, t)
}

Expand Down
8 changes: 6 additions & 2 deletions mq/rabbitmq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ func TestRabbitMQGetQueues(t *testing.T) {
b, err := NewRabbitMQBroker("amqp://guest:guest@localhost:5672/")
assert.NoError(t, err)
qname := fmt.Sprintf("%stest-%s", QUEUE_EXCLUSIVE_PREFIX, uuid.NewUUID())
err = b.PublishTask(ctx, qname, &tork.Task{})
err = b.SubscribeForTasks(qname, func(t *tork.Task) error {
return nil
})
assert.NoError(t, err)
qis, err := b.Queues(ctx)
assert.NoError(t, err)
Expand All @@ -51,7 +53,9 @@ func TestRabbitMQGetQueuesMgmtURL(t *testing.T) {
b, err := NewRabbitMQBroker("amqp://guest:guest@localhost:5672/", WithManagementURL("http://localhost:15672"))
assert.NoError(t, err)
qname := fmt.Sprintf("%stest-%s", QUEUE_EXCLUSIVE_PREFIX, uuid.NewUUID())
err = b.PublishTask(ctx, qname, &tork.Task{})
err = b.SubscribeForTasks(qname, func(t *tork.Task) error {
return nil
})
assert.NoError(t, err)
qis, err := b.Queues(ctx)
assert.NoError(t, err)
Expand Down

0 comments on commit 177c15e

Please sign in to comment.