Reputation: 100290
I just want Confirm mode for a single request, not to affect the entire channel (other requests made with that channel).
This bit of code modifies the channel:
/// Enable Confirm mode
if err := ch.Confirm(false); err != nil {
log.Fatalf("Error enabling Confirm mode: %s", err)
}
/// Create a confirmation channel
confirms := ch.NotifyPublish(make(chan amqp.Confirmation, 1))
/// publish the message
err := ch.PublishWithContext(
toCtx,
virl_const.RMQMainExchange,
routingKey,
false,
false,
amqp.Publishing{
ContentType: "application/json",
Body: v,
DeliveryMode: amqp.Transient,
Headers: map[string]interface{}{
"x-vibe-type": 1,
},
},
)
if err != nil {
log.Fatalf("Error publishing message: %s", err)
}
// Wait for confirmation
select {
case confirmed := <-confirms:
if confirmed.Ack {
fmt.Println("Message confirmed by server")
} else {
fmt.Println("Message not confirmed by server")
}
case <-time.After(time.Second * 5):
fmt.Println("Timed out waiting for confirmation")
}
but I want to just modify the one request. Is it possible to do so?
Upvotes: 0
Views: 149