You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//To use the delay feature, an exchange with type 'x-delayed-message' must be there.
var pubDelayStruct = queuelib.PublishStruct{
Exchange: "amqp.delay",
Key: "testKey",
Mandatory: false,
Immediate: false,
ContentType: "text/plain",
Message: []byte("Testing Delayed Publish()"),
Delay: 15000, //15 sec. delay
}
result, err := rmq.Publish(pubDelayStruct)
Subscribing Queue and Acknowledge
var subStruct = queuelib.SubscribeStruct{
Queue: "testQueue",
Consumer: "",
AutoAck: false,
Exclusive: false,
NoLocal: false,
NoWait: false,
PrefetchCount: 10, //Allows batching of messages
}
chForever := make(chan bool)
msgs, err := rmq.Subscribe(subStruct)
go func() {
for msg := range msgs {
log.Printf("Received a message: %s", msg.Body)
result, err := rmq.Acknowledge(msg)
}
}()
<-chForever