consumer.close() will ensure the background thread has completed its
The close will wait for the background thread to stop.
The problem with closing the connection is that it tags the connection/session
as closed to avoid further use of them during the close.
Many thanks for that.
That's got it.