-
1. Re: Message Driven Bean in JBoss
koltar Nov 14, 2002 1:01 AM (in response to koltar)I'm trying to make a this client code work from a JSP. The code goes through without throwing an exception I was able to fix the ConnectionFactory error but using ConnectionFactory and added loginAuditQueue to the jbossmq-destination.xml.
The code runs through without an error but I am not abel to get a System.out.println or logging to file. It is as if the Message Driven Bean I created is not listening to the Queue and the onMessage is not getting called. I'm not sure what piece I am missing.
Any help would be apprciated greatly!
JSP Code that runs without error
Context context = new InitialContext();
QueueConnectionFactory queueFactory = (QueueConnectionFactory)context.lookup("ConnectionFactory");
QueueConnection queueConnection = queueFactory.createQueueConnection();
QueueSession queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = (Queue)context.lookup("queue/loginAuditQueue");
QueueSender queueSender = queueSession.createSender(queue);
ObjectMessage message = queueSession.createObjectMessage();
message.setObject("Login: TESTING");
queueSender.send(queue, message);
queueSession.close();
queueConnection.close();
HelloWorld MessageDriven Bean
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBException;
import javax.ejb.RemoveException;
import javax.ejb.MessageDrivenBean;
import javax.ejb.MessageDrivenContext;
import javax.jms.Message;
import javax.jms.MessageListener;
/**
* Message Driven Bean Template
*
* @ejb:bean name="LoginAuditMDB"
* display-name="Message Driven Login Audit Bean"
* transaction-type="Container"
* acknowledge-mode="Auto-acknowledge"
* destination-type="javax.jms.Queue"
* subscription-durability="NonDurable"
*
* @jboss:destination-jndi-name name="queue/loginAuditQueue"
**/
public class LoginAuditMDB
implements MessageDrivenBean, MessageListener {
// -------------------------------------------------------------------------
// Static
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
// Members
// -------------------------------------------------------------------------
private MessageDrivenContext mContext;
// -------------------------------------------------------------------------
// Methods
// -------------------------------------------------------------------------
/**
* This method is called by the JMS implementation when a message is
* ready to be delivered.
*
* @param pMessage Message send by JMS
**/
public void onMessage( Message pMessage ) {
Log log = new Log();
log.setFilepath("/usr/local/jboss-3.0.4_tomcat-4.1.12/logs");
log.setFilename("test.log");
log.setLogIdentity("LOGINAUDIT");
log.setPrefix("ERROR");
log.setMessage("LoginAuditMDB.onMessage() got message " + pMessage);
try {log.save();} catch (Exception e) {}
System.out.println("LoginAuditMDB.onMessage() got message " + pMessage );
}
/**
* Create the Session Bean
*
* @throws CreateException
**/
public void ejbCreate() {
System.out.println("ejbCreate() called");
}
/**
* Describes the instance and its content for debugging purpose
*
* @return Debugging information about the instance and its content
**/
public String toString() {
return "LoginAuditMDB [ " + " ]";
}
// -------------------------------------------------------------------------
// Framework Callbacks
// -------------------------------------------------------------------------
public void setMessageDrivenContext( MessageDrivenContext aContext )
throws
EJBException {
mContext = aContext;
System.out.println("setMessageDrivenContext called");
}
public void ejbRemove() {
System.out.println("ejbRemove() called");
}
} -
2. Re: Message Driven Bean in JBoss
koltar Nov 14, 2002 2:01 AM (in response to koltar)I have found part of the problem looking through the build from ant it is only showing the template test entries in the message-driven bean tags. Where is the ant script writing the META-INF xml files from? I can not seem to find them in the source. How do I get the ant script to accept my new files. The above code shows the xdoclet changes I made but when I build nothing new is coming in the build. I even edited the entry pointing to test/message/** to mytest/message/**.
Any suggestions? If someone knows about some good documentation that would be cool. Everything is bits and pieces with no complete reference. -
3. Re: Message Driven Bean in JBoss
koltar Nov 14, 2002 9:46 PM (in response to koltar)Anyone ever successfully implemented MDB on JBoss that was not the template? If so what should I use for a resource I'm still stuck...
-
4. Re: Message Driven Bean in JBoss
juha Nov 15, 2002 1:01 PM (in response to koltar)weelll.. where's your code that sends the message?
-
5. Re: Message Driven Bean in JBoss
koltar Nov 16, 2002 11:51 AM (in response to koltar)2nd Message, I thought that sent the message with the line: queueSender.send(queue, message); Tells what que it goes in and what message to send? Is that not correct?
-
6. Re: Message Driven Bean in JBoss
juha Nov 16, 2002 12:17 PM (in response to koltar)oops, I musta been blind