+ All Categories
Home > Documents > Lab - Message Driven Beans

Lab - Message Driven Beans

Date post: 29-Nov-2014
Category:
Upload: alvin-jay-reyes
View: 783 times
Download: 3 times
Share this document with a friend
26
Creating Message Driven Beans Alvin Reyes
Transcript
Page 1: Lab - Message Driven Beans

Creating Message Driven Beans

Alvin Reyes

Page 2: Lab - Message Driven Beans

Agenda

• Install Pre-requisite Softwares and DB Connection

• Develop a simple Message Driven Bean.

Page 3: Lab - Message Driven Beans

Pre-requisites

• Eclipse IDE (Bundled with JBoss 6)• Jboss Server (

http://sourceforge.net/projects/jboss/files/JBoss/JBoss-6.0.0.Final/)

Page 4: Lab - Message Driven Beans

Eclipse IDE

http://www.eclipse.org/

http://www.jboss.org/tools/download/

Eclipse IDE Download

Jboss Eclipse Plugin

Page 5: Lab - Message Driven Beans

JBoss Server

• Download the Application Server:http://sourceforge.net/projects/jboss/files/JBos/JBoss-6.0.0.Final/

Default Username: adminDefault Password: admin

Page 6: Lab - Message Driven Beans

JBoss Server Installation

Install Jboss Server on your Eclipse IDE.Step 1: Go to New > Server > ServerStep 2: Choose Jboss AS 6.0Step 3: Define the Location of the Jboss AS

Page 7: Lab - Message Driven Beans

JBoss Server

Define the Home directoryof JBoss AS and click Finish.

Page 8: Lab - Message Driven Beans

Project Overview

For this session: We’ll create a Simple Message Driven Bean.

Page 9: Lab - Message Driven Beans

Create Topic• Open the Jboss Administrator Console (http://localhost:8080/admin-console

)• Create new Topic with JNDI name: jms/sampletopic

Page 10: Lab - Message Driven Beans

Create TopicCreate new Topic with JNDI name: jms/sampletopic

Name: sampletopic / JNDI Name: jms/sampletopic

Page 11: Lab - Message Driven Beans

Create TopicAdd Roles to the Topic:

Click OK > return to Topic Configuration > Click Save.

Page 12: Lab - Message Driven Beans

Create TopicSuccessfully Created the Topic:

Make sure that the Status is UP. This ensure us that the Topic is ready to serve message request from clients.

Page 13: Lab - Message Driven Beans

Create Enterprise Java Bean Project

Note: You can skip the Project creation if you already have an existing EJBproject.

1. Go to > New > EJB > EJB Project2. Name: ejbsampleproject_<name>3. Target: JBoss 6.4. Create EAR Project5. Create Client Project6. Click Next to Finish

We will now create the EJB that will serve as the consumer of the requests

Page 14: Lab - Message Driven Beans

EJB Project – Message Driven Bean

Generated:– EJB Project– Client Project– EAR

Page 15: Lab - Message Driven Beans

EJB Project – Message Driven BeanMake sure that:

– Jboss Library is included on the Build Path of EJB and Client.

Page 16: Lab - Message Driven Beans

Create new Message Driven BeanJava Package: com.gradu.ejb.samplebeansClass name: SampleMessageDrivenBeanTopic

EJB Project: Develop the Bean

Page 17: Lab - Message Driven Beans

Create new Message Driven Bean

Click Finish

EJB Project: Develop the Bean

Page 18: Lab - Message Driven Beans

Create new Message Driven BeanThe Wizard Generated the following:

1. Session Bean named “SampleMessageDrivenBeanTopic”

EJB Project: Develop the Bean

Page 19: Lab - Message Driven Beans

Create new Message Driven BeanGenerated Session Bean:

EJB Project: Develop the Bean

Page 20: Lab - Message Driven Beans

Create new Message Driven BeanAdd a Activation Configuration to include our Queue

EJB Project: Develop the Bean

Page 21: Lab - Message Driven Beans

Create a new Client Class

Create a new class on the client project. This client will be the one calling our Message Driven Bean from the Application Server.

EJB Project: Develop the Client

Java Package: com.gradu.ejb.clientClass name: SampleTopicProducerClient

Page 22: Lab - Message Driven Beans

Modify the Client Class to Call our BeanCreate a new class on the client project. This client will be the one calling our Session Bean from the Application Server.

EJB Project: Develop the Client

Page 23: Lab - Message Driven Beans

Deploy the Session Bean

We need to deploy the session bean first before executing the Sample Client.

EJB Project: Develop the Client

Run the EAR file on the server to deploy the EJB Components.

Page 24: Lab - Message Driven Beans

Verify Deployment from Console

After running the EAR file (deployment), we need to verify if the Application ServerIndeed deployed our beans.

EJB Project: Develop the Client

If the above lines are shown on the Console, then the Session Bean was successfully deployed.

Page 25: Lab - Message Driven Beans

Test the Session Bean using the Client ClassRun the Client Class.

EJB Project: Testing the Bean

If you were able to see the value thrown from the Session Bean, that means you have successfully called the Bean from the Application Server.

Page 26: Lab - Message Driven Beans

Check Topic MetricsRun the Client Class.

EJB Project: Testing the Bean

If you were able to see the value thrown from the Session Bean, that means you have successfully called the Bean from the Application Server.


Recommended