This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes looking for  MDB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "looking for  MDB " Watch "looking for  MDB " New topic
Author

looking for MDB

prasanna pati
Ranch Hand

Joined: Jan 29, 2005
Posts: 46
hi I want to do a sample project with message driven beans , can anyone send me a step by step guide ? If I can do the sample project then I will be able to add some complexes also .
prasanna pati
Ranch Hand

Joined: Jan 29, 2005
Posts: 46
i have this : http://www.eclipse.org/webtools/community/tutorials/ejbtutorial/buildingejbs.html
but its all for session beans or so......what I am looking for a step by step of message driven bean .
Mahesh Desai
Ranch Hand

Joined: Apr 04, 2007
Posts: 76
Hi,

You can try this: http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/MDB.html

Thanks,
Mahesh

-----------
SCJP 1.4 | SCWCD 1.4 | SCBCD 1.3 | SCEA Part I - In Progress
prasanna pati
Ranch Hand

Joined: Jan 29, 2005
Posts: 46
i have a sample program of Java messaging service . One is sending a message , another is receiving a message . I want to know I should run it using only Jdk or I have to do it using EJB compilation all those stuff . here are those 2:

messageSender.java


/*
* MessageSender.java
*
* Created on April 18, 2007, 9:44 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

/**
*
* @author 278085
*/


import javax.jms.*;
import javax.naming.*;


public class MessageSender {

public static void main(String[] args) {
QueueConnection queueConnection = null;

try {
Context context = new InitialContext();
QueueConnectionFactory queueConnectionFactory =
(QueueConnectionFactory) context.lookup("QueueConnectionFactory");
String queueName = "MyQueue";
Queue queue = (Queue) context.lookup(queueName);
queueConnection =
queueConnectionFactory.createQueueConnection();
QueueSession queueSession =
queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
QueueSender queueSender = queueSession.createSender(queue);
TextMessage message = queueSession.createTextMessage();
message.setText("This is a TextMessage");
queueSender.send(message);
System.out.println("Message sent.");
}
catch (NamingException e) {
System.out.println("Naming Exception");
}
catch (JMSException e) {
System.out.println("JMS Exception");
}
finally {
if (queueConnection != null) {
try {
queueConnection.close();
}
catch (JMSException e) {}
}
}
}
}


MessageReceiver.java


/*
* MessageReceiver.java
*
* Created on April 18, 2007, 12:00 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

/**
*
* @author 278085
*/

import javax.jms.*;
import javax.naming.*;
public class MessageReceiver {
public static void main(String[] args) {
QueueConnection queueConnection = null;
try {
Context context = new InitialContext();
QueueConnectionFactory queueConnectionFactory =
(QueueConnectionFactory) context.lookup("QueueConnectionFactory");
String queueName = "MyQueue";
Queue queue = (Queue) context.lookup(queueName);
queueConnection =
queueConnectionFactory.createQueueConnection();
QueueSession queueSession = queueConnection.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);
QueueReceiver queueReceiver = queueSession.createReceiver(queue);
queueConnection.start();
Message message = queueReceiver.receive(1);
if (message != null) {
if (message instanceof TextMessage) {
TextMessage textMessage = (TextMessage) message;
System.out.println(textMessage.getText());
}
}
}
catch (NamingException e) {
System.out.println("Naming Exception");
}
catch (JMSException e) {
System.out.println("JMS Exception");
}
finally {
if (queueConnection != null) {
try {
queueConnection.close();
}
catch (JMSException e) {}
}
}
}
}


i am getting Naming exception
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

Here's a collection of multimedia tutorials that deal with developing EJBs. Take a look at the tutorial on creating an MDB, and the section on setting up a message queue/topic.

Creating an MDB and a Session Bean to put a message on a queue.


 
It is sorta covered in the JavaRanch Style Guide.
 
subject: looking for MDB
 
Similar Threads
sample project development site
Spring-Eclipse configuration
How the three step of SCEA work?
bpel plugin for eclipse indigo
Deploying Open ESB to JBoss