Sunday, July 9, 2017

12. An EJB application that demonstrates MDB (with appropriate business logic).

Services->glassfishserver3.1->right click start->right click view admin console->JMS Resource-
>Click on Connection Factories->New->
Pool Name: jms/queue -> Resource Type: javax.jms.QueueConnectionFactory
Click on Destination Resources -> New ->
JNDI Name: jms/dest -> Resource Type: javax.jms.Queue minimize the window
File -> NewProject -> Java EE -> EnterpriseApplication -> next -> Java EE Version: select Java
EE 5 ->
Check Create EJB module and Web Application module -> finish
In EJB Module
Right click EJB module -> select new message driven bean -> give EJB Name as MyBean and
package name as com -> Select server destinations as jms/dest
Type the following code in the method onMessage()
TextMessage tmsg=null;
tmsg=(TextMessage)message;
System.out.println(tmsg.getText()); /*Left click on error indicator and select surround statement
with try catch*/
In war Module
Select index.jsp file and type the following code inside body tag
<form action="NewServlet">
<table border="1">
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Enter message</td>
<td><input type="text" name="msg" value="" /></td>
</tr>
</tbody>
</table>
<input type="submit" value="submit" />
</form>
Right Click on war module -> New -> Servlet -> write servlet name and package name -> finish
In NewServlet before try block of processRequest() method ->right click select insert code -
>Select send JMS message ->Connection factory : jms/queue
Before try block of processRequest type
String str=request.getParameter("msg");
sendJMSMessageToDest(str); /*Left click on error indicator and select surround statement with
try catch*/
clean and build application
deploy EJB module
In glass fish server select Applications click deployed file
Run war file

1 comment:

  1. Tiki Pendant - Titanium Fidget Spinner - Tipster - The
    The Tiki Tiki Pendant is tungsten titanium a new and authentic Tiki style titanium body armor piece titanium camping cookware that titanium glasses frames has been designed by Tipster and is perfect for titanium nipple barbells table games of all skill levels.

    ReplyDelete