Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JMS, MDB, Session bean dan comand patern  RSS feed

 
agam agam
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, i'm new in JMS and MDB,
I have a problem working with MDB.
I have a batch to generate report,this batch is a thread, if it done
to generate report it will sleep for a few time. To Generate report
this thread call the SessionBean, so exactly report is generate by Session bean, thread just a caller.
than I have an idea to use MDB rather than using thread, the Idea is:
1. I put initial message to queue, than i set the queue so it
will be view the message to MDB in some period, EG: 5 minutes
2. MDB will aware this message(asynchronous) and call session bean, same as
the tread do, to generate report.
3. After generate report is finish, MDB will Put a message to queue again.
I use command pattern so i just cut and paste existing code in the thread to
MDB, logically it not to be a problem, but in reality it has.
I'm using weblogic 8.1 and here is the code:
ALTERNATIF 1:
try{
ctx = new InitialContext();
CommandServerLocalHome commandServerLocalHome = (CommandServerLocalHome)ctx.lookup("CommandServerBeanLocal");
CommandServerLocal cmd = commandServerLocalHome.create();
ProcessBatchCommand batch = new ProcessBatchCommand();
cmd.executeCommand(batch);
}
catch(Exception e){
e.printStackTrace();
}
finally{
PushMessageToQueue.push("ekiosk-process-queue");
}
ALTERNATIF 2.
try{
PushMessageToQueue.push("ekiosk-report-queue");
}
catch(Exception e){
}
finally{
try{
ctx = new InitialContext();
(CommandServerLocalHome)ctx.lookup("CommandServerBeanLocal");
ProcessReportCommand batch = new ProcessReportCommand();
batch.execute();
}
catch(Exception e){
e.printStackTrace();
}
}

 
Sergiu Truta
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
put initial message to queue, than i set the queue so it
will be view the message to MDB in some period, EG: 5 minutes

I'm not really sure if you can set the queue to give the message to the MDB after a certain ammount of time. As far as I know you put the message into the queue and this can be taken and processed by the MDB at any time.
It might be a feature of some applications servers though, that you may configure the message queue to make the messages available only after a certain ammount of time, but I haven't heard of this before. Does any of you guys know of such a feature?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!