This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Message driven bean with limited backend uptime  RSS feed

 
Thomas Olausson
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to create a interface to a service with a limited uptime.
In my case, the backend is only open say 9am-5pm.
If a request is received outside of these hours, queue the msg and work on it when the uptime window comes back.

So I thought a asynchronous approach with a JMS queue (point to point) would be good.
client -> work queue -> message bean (MDB)

But how do I solve the time aspect of the service?

I would like to use the JMS framework here, but can't use a message selector, because it only looks at the timestamp of the message, not the current time.

I've thought of three workarounds, but neither flies well, any tips here?

1. Control the message listener port to be up only 9-5.
We're using Webspher App Server, so I could script something that would turn off and on the listener port, via cron.

2. Use two queues: the client puts the message on a "stage queue", and a special message bean decides if the message was received during uptime,
if so, put it on the work queue where the regular message bean runs.
if not, don't acknowledge the message and keep retrying until the time window comes back.

3. The message bean itself knows what the uptime is and sleeps for 5 minutes before trying again. It keeps doing so until the uptime window is back.
If I have 10 MDB in the pool and 10 messages, 10 threads will just sit there in this wait loop.

/Thomas
[ March 21, 2005: Message edited by: Thomas Olausson ]
 
Thomas Olausson
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hehe,
I love when I post something here and figure out the solution myself.
Solved it this way:

Websphere App Server has a scriptable interface to the Mbean server, via a command line tool called wsadmin.
So, to turn on and off a message listener port, one's gotta do this:

First, login to the mbean server with wsadmin


Stop the message listener port called "MyPort"


Start it:


Add a cron job that takes up and down the port, or script it with Quartz
[ March 22, 2005: Message edited by: Thomas Olausson ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!