I'm writing an application which interfaces with multiple brokers using the springboot java framework. I'm leveraging JMS to browse/read messages which are older than 4 hours. The main issue is trying to generate a unit test for this functionality. This is because the test would have to send an old message to the broker and based on the article I read here, which explains that altering the Timestamp does nothing since it resets once the message is sent to the broker. Basically the article rendering any chance of the message being old. Does anyone have some work around? or know of a way I can achieve this?
I've already tried setting the JMSTimestamp message.setJMSTimestamp(System.currentTimeMillis() - 14400000)
. At run time it shows the timestamp being 4 hours old but checking the message in jconsole only shows it as the current date/time (Ex. Wed Apr 14 13:41:27 EDT 2021
).