Flush message queue instead of discarding them on shutdown
The default destroyMethod for a Bean is inferred, and uses the close or shutdown method on the object.
But since the shutdown method of the analytics class stops processing of messages, there's a chance that this would discard messages.
By calling flush it should be able to process the messages before shutdown.
Even better might be to implement the blocking flush for the spring boot starter? (https://github.com/segmentio/analytics-java/blob/master/analytics-sample/src/main/java/sample/BlockingFlush.java)
Let me know what you think!
I looked a bit further, and could it be that the shutdown method also performs a final request with the remaining messages? https://github.com/segmentio/analytics-java/blob/9e9492faa71486a7c4a133422d6ca57ded3f8093/analytics/src/main/java/com/segment/analytics/internal/AnalyticsClient.java#L306-L314