13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

21.2 Expanding to EJBs481One further word. This is by no means an established doctrine, but itseems to be comm<strong>on</strong> practice to keep entity beans hidden behind sessi<strong>on</strong> beans.In other words, it seems to be comm<strong>on</strong>place to not allow clients (Web applicati<strong>on</strong>s,Java applicati<strong>on</strong>s) to communicate directly with entity beans, but ratherto have sessi<strong>on</strong> beans perform all entity bean operati<strong>on</strong>s. This is probably becausethe idea of sessi<strong>on</strong> beans is to decouple business process from implementati<strong>on</strong>details, and entity beans, no matter how much they hide the underlyingdatabase, are still rather tightly coupled to the implementati<strong>on</strong> of the datastorage.Why you would use them. Essentially, they allow you to write your dataaccess layer exactly <strong>on</strong>ce, and then reuse it any number times without worryingabout capacity and management. Also, by trying to keep the most often useddata in fast memory, they can, when running <strong>on</strong> a powerful c<strong>on</strong>tainer or clusterof c<strong>on</strong>tainers, keep many client operati<strong>on</strong>s running much faster than a strictwrite-read update back end.21.2.2.3Message BeansWhat they are. We’re going to gloss over message beans in our book, butyou should know what they are. A message bean represents an interface to amessage queue. An entity bean represents a transacti<strong>on</strong> where completi<strong>on</strong> ofthe call tells you the operati<strong>on</strong> has fully completed. A message queue, <strong>on</strong> theother hand, is an interface where you are given the firm promise that systemwill get to this when it can. The client doesn’t know where or when the messagewill be handled. It doesn’t know if it was successful or not. But it does knowthat it is the problem of the queue reader.There are many such operati<strong>on</strong>s in large enterprises. And there are manyproducts that implement such functi<strong>on</strong>ality. Microsoft offers Message QueueServer (MSMQ). IBM has MQSeries. Message queues are comm<strong>on</strong> with operati<strong>on</strong>sthat take time, or need to be batched, or require human interventi<strong>on</strong>.Why you would use them. Let’s go back to our shopping cart idea. Managementmight want a daily sales report. You could send each and every itempurchased to a message bean. Then a process to read that queue might bekicked off <strong>on</strong>ce a day and the report produced without hitting the database thatsupports all the current Web users. That’s a good example of how a messagequeue (and thus a message bean) might be used. Again, we’re not going to workwith message beans here.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!