Hi Solace Community,
as long as the SMF API for golang is not available, we would like to create a reference implementation using golang with AMQP and PubSub+.
Instead of QPID, we want to use https://github.com/Azure/go-amqp, because it does not require C bindings and looks way more easy to handle.
The example on github works pretty well, however we’ve ran into a problem with timeouts and keepalives. When creating a client, the idle timeout for connections is 60 seconds by default, which means listening on a queue for more then 60 seconds without activity will result in an read tcp 127.0.0.1:46732->127.0.0.1:5672: i/o timeout
exception.
// stripped all error handling...
client, err := amqp.Dial("amqp://localhost:5672",
amqp.ConnSASLPlain("admin", "admin"),
// amqp.ConnIdleTimeout(20*time.Second),
amqp.ConnIdleTimeout(0),
)
session, err := client.NewSession()
// my queue is called logging and receives system and vpn events with a subscription on #LOG/>
receiver, err := session.NewReceiver(
amqp.LinkSourceAddress("logging"),
amqp.LinkCredit(10),
)
for {
// Receive next message
err = receiver.HandleMessage(ctx, handleMessage) // handleMessage just logs and accepts the message
if err != nil {
return err // <<<---- This is called after ConnIdleTimeout
}
}
Another option is to set ConnIdleTimeout
to 0
. But then the client does not recognize loss of connection, for example if egress of the queue will be disabled and re-enabled, the client still waits in handleMessage
while on the broker messages are piling up.
Of course, one could set a timeout and just reconnect the whole client in an endless loop, or create a sender who creates “hearbeats” every minute to fake activity on the queue, but both feels horribly wrong.
Did we miss some settings? Something in the client-profile that could help?
What golang / amqp API’s are you using?
Other suggestions?
Thanks and regards,
Andreas