Here's what you can do, you can do this out of the box.
Use a timer bean to open up the JMS port to read messages.
When you connect to a topic, you can filter the results use message selectors.
One of the properties you can use in a selector is the timestamp of the message.
So, your Timer Bean wakes up every hour, makes a connection to the JMS queue, and asks for all messages that have a timestamp of NOW - 60 minutes.
This will give you a flood of messages that happened in the last hour.
But it will eventually "stop" because you'll (ideally) exhaust the messages, meanwhile messages can continue to be coming in to the queue.
Errors you can push back on to the queue. Since they have the current time stamp, they won't immediately come back.
You can set your threshold to whatever you want. If you simply say "all messages before now", and run it every hour, then you can process the messages up to when you started, and all new messages will be skipped until you run again, including your errored messages.
You can't use an MDB for this because it's message selector is hard coded, and can't be dynamic based on something like time. So you would need to use a Timer Bean to poll the queue.
[Message sent by forum member 'whartung' (redrocks_at_sbcglobal.net)]
http://forums.java.net/jive/thread.jspa?messageID=367182