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 #25

Merged
merged 1 commit into from
Jun 27, 2024
Merged
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
9 changes: 9 additions & 0 deletions pkg/amqp/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func (s *Subscriber) Subscribe(ctx context.Context, topic string) (<-chan *messa
s.subscriberWaitGroup.Done()
}()

reconnecting := false
ReconnectLoop:
for {
s.logger.Debug("Waiting for s.connected or s.closing in ReconnectLoop", logFields)
Expand All @@ -153,6 +154,12 @@ func (s *Subscriber) Subscribe(ctx context.Context, topic string) (<-chan *messa
// not closing yet
}

if reconnecting {
if err := s.prepareConsume(queueName, exchangeName, logFields); err != nil {
s.logger.Error("Failed to prepare consume", err, logFields)
}
}

select {
case <-s.connected:
s.logger.Debug("Connection established in ReconnectLoop", logFields)
Expand All @@ -167,6 +174,8 @@ func (s *Subscriber) Subscribe(ctx context.Context, topic string) (<-chan *messa
}

time.Sleep(time.Millisecond * 100)

reconnecting = true
}
}(ctx)

Expand Down
Loading