• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Daily WhatsApp notifications through timer functionality (EJB - SLSB vs. MDB)

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello

let's image that an cloud provider wants to send each day the price of the last 24 hours to their customers. The whole business logic for calculating this value and sending it to the customer is out of scope. Let's concentrate on the possibilities how such 24h timer service can be implemented through an EJB. From my understanding this is either possible through a message driven bean (MDB) or a stateless session bean (SLSB). The  SLSB is for me the better choice because no messaging system is involved. On the other hand I read that an MDB will never be called directly from a client, which is also good for this requirement, and for an SLSB this is not true. Still, I would go with the SLSB.

What is your choice?

Regards,
Christian
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's hard to say which is better to use per se without knowing your requirements.

And such tasks don't necessary need to be Java-based like in the real world. A cron job in Linux can do the same thing.

Key factors are a) how often the job needs to run, b) how long each run will take and maybe c) how many threads you going to use.
 
Christian Nicoll
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your input. In real life I totatly agree with you, that the solution can be also something else than Java. For the context of my questions, let's not overthink it and see it more from the part 1. If you have the possibilities MDB and SLSB, which one is better suited, and why?
 
K. Tsang
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh it's for part 1. OK not know the answer choices and assuming it's a single choice answer, I reckon you eliminate the rest except SLSB and MDB.

Hmm Eeny, meeny, miny, moe...

Personally I will go with SLSB because they are definitely easier to use/develop, annotation-based and support asych method invocation.
 
Christian Nicoll
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your input. I've thought also a bit more about it and I would definetly go with the SLSB. For an MDB I need an onMessage() method which doesn't make sense in this scenario. Further in the SLSB I would be able to annotate also private methods with timer-based annotations to ensure that they can't be called directly.
 
Ranch Hand
Posts: 531
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Christian Nicoll wrote:Hello

let's image that an cloud provider wants to send each day the price of the last 24 hours to their customers. The whole business logic for calculating this value and sending it to the customer is out of scope. Let's concentrate on the possibilities how such 24h timer service can be implemented through an EJB. From my understanding this is either possible through a message driven bean (MDB) or a stateless session bean (SLSB). The  SLSB is for me the better choice because no messaging system is involved. On the other hand I read that an MDB will never be called directly from a client, which is also good for this requirement, and for an SLSB this is not true. Still, I would go with the SLSB.

What is your choice?

Regards,
Christian



Hi, Christian,

It sounds like a business process to me. Quartz is a great choice for running periodic business processes and to sending the results out to users.

I would:

a) Use a Quartz-based job to calculate the price and to persist it somewhere.
b) Use a Quartz-based job to retrieve the results and to post them to an MQ broker.
c) Use a Quartz-based job to send the results via your selected method to users by retrieving the messages from the MQ broker and sending them on their way while persisting the results of the send for the application's records.

Something like that should have comprehensive error-checking in order to account for any error conditions.

You are probably way done with this at this point, but maybe it is still helpful.

With warm regards,

Anton.
 
Christian Nicoll
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Anton

thanks a lot for your input.

For all the others, I'm done, so I don't expect any additional inputs concerning this question.

Regards,
Christian
 
reply
    Bookmark Topic Watch Topic
  • New Topic