MCPcopy Create free account
hub / github.com/codealong-dev/ride-sharing / setupDeadLetterExchange

Method setupDeadLetterExchange

shared/messaging/rabbitmq.go:150–191  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

148}
149
150func (r *RabbitMQ) setupDeadLetterExchange() error {
151 // Declare the dead letter exchange
152 err := r.Channel.ExchangeDeclare(
153 DeadLetterExchange,
154 "topic",
155 true, // durable
156 false, // auto-deleted
157 false, // internal
158 false, // no-wait
159 nil, // arguments
160 )
161 if err != nil {
162 return fmt.Errorf("failed to declare dead letter exchange: %v", err)
163 }
164
165 // Declare the dead letter queue
166 q, err := r.Channel.QueueDeclare(
167 DeadLetterQueue,
168 true, // durable
169 false, // delete when unused
170 false, // exclusive
171 false, // no-wait
172 nil, // arguments
173 )
174 if err != nil {
175 return fmt.Errorf("failed to declare dead letter queue: %v", err)
176 }
177
178 // Bind the queue to the exchange with a wildcard routing key
179 err = r.Channel.QueueBind(
180 q.Name,
181 "#", // wildcard routing key to catch all messages
182 DeadLetterExchange,
183 false,
184 nil,
185 )
186 if err != nil {
187 return fmt.Errorf("failed to bind dead letter queue: %v", err)
188 }
189
190 return nil
191}
192
193func (r *RabbitMQ) setupExchangesAndQueues() error {
194 // First setup the DLQ exchange and queue

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected