Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recreate topology after reconnection #17

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions pkg/amqp/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,6 @@ func (s *Subscriber) Subscribe(ctx context.Context, topic string) (<-chan *messa
exchangeName := s.config.Exchange.GenerateName(topic)
logFields["amqp_exchange_name"] = exchangeName

if err := s.prepareConsume(queueName, exchangeName, logFields); err != nil {
return nil, errors.Wrap(err, "failed to prepare consume")
}

s.subscriberWaitGroup.Add(1)
s.connectionWaitGroup.Add(1)

Expand Down Expand Up @@ -192,7 +188,7 @@ func (s *Subscriber) SubscribeInitialize(topic string) (err error) {

s.logger.Info("Initializing subscribe", logFields)

return errors.Wrap(s.prepareConsume(queueName, exchangeName, logFields), "failed to prepare consume")
return nil
}

// Close closes all subscriptions with their output channels.
Expand Down Expand Up @@ -238,6 +234,11 @@ func (s *Subscriber) runSubscriber(
}
}()

if err = s.prepareConsume(queueName, exchangeName, logFields); err != nil {
s.logger.Error("Failed to prepare consume", err, logFields)
return
}
Comment on lines +237 to +240
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@reva2 The issue here might be that you won't receive this error on the first subscriber run (it's just logged). Perhaps it makes sense to run s.prepareConsume in all these cases?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although that might cause duplicated logs so it's also not an elegant solution. 🤔


notifyCloseChannel := channel.NotifyClose(make(chan *amqp.Error, 1))

sub := subscription{
Expand Down