This week's book giveaway is in the Java in General forum.
We're giving away four copies of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 and have ishori Sharan & Adam L Davis on-line!
See this thread for details.
Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

JMS, MDB, Session bean dan comand patern

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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();
}
}

 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
reply
    Bookmark Topic Watch Topic
  • New Topic