Message driven beans and asynchrony

Practice for Bonus Materials

By now, you will have gained a great deal of confidence and skill in Java EE.

Each week, you have built a simple application that demonstrates the essential ideas of a technology in the Java EE specifications.

Your challenge for the bonus materials is to come up with your own activity.

Create a simple project that demonstrates either message driven beans and/or asynchronous methods.

Hints

You can send messages to a message driven bean, even before you've written the bean. Can you write and run code that sends a message, then after you've sent the message, write some code that will recieve the message?

For asynchronous, can you create an EJB method that is slow (e.g., Thread.sleep(10000);) but eventually outputs data to the log file. What happens when you annotate that method with @Asynchronous?

If your asynchronous method returns a future, how long does it take to call and wait for several asynchronous methods to return?

You can measure time in Java as follows:

long start = System.currentTimeMillis();
// ... do some slow processing, then ...
long durationInMilliseconds = System.currentTimeMillis() - start;