Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

my MDB does not recives any messages

 
Yashar Kalantari
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone

I have two ejbs deployed on jboss and it seems that they working fine .the first one is a mdb listening for text messages as follow

code:

package log;

import javax.ejb.MessageDrivenBean;
import javax.ejb.MessageDrivenContext;
import javax.ejb.EJBException;
import javax.jms.MessageListener;
import javax.jms.Message;
import javax.jms.TextMessage;
import javax.jms.JMSException;

/**
* Created by IntelliJ IDEA.
* User: Yashar Kalantari
* Date: Oct 20, 2004
* Time: 4:19:47 PM
*/
public class LogBean implements MessageDrivenBean, MessageListener {

MessageDrivenContext ctx;

public void ejbRemove() throws EJBException {
System.out.println("ejbRemove() Called.");
}

public void setMessageDrivenContext(MessageDrivenContext messageDrivenContext) throws EJBException {
System.out.println("setMessageDrivenContext() Called.");
this.ctx = messageDrivenContext;
}

public void ejbCreate() {
System.out.println("ejbCreate() Called.");
}

public void onMessage(Message message) {
System.out.println("a new Message!!!");
if(message instanceof TextMessage) {
TextMessage tm = (TextMessage)message;
try {
String text = tm.getText();
System.out.println("Recieved new message : " + text);
} catch (JMSException e) {
e.printStackTrace();
}
}
}
}

ejb-jar.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>
<ejb-jar>
<enterprise-beans>
<message-driven>
<ejb-name>Log</ejb-name>
<ejb-class>log.LogBean</ejb-class>
<transaction-type>Container</transaction-type>
<message-driven-destination>
<destination-type>javax.jms.Topic</destination-type>
</message-driven-destination>
</message-driven>
</enterprise-beans>
</ejb-jar>

jboss.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS//EN" "http://www.jboss.org/j2ee/dtd/jboss.dtd">
<jboss>
<secure>false</secure>
<enterprise-beans>
<message-deriven>
<ejb-name>Log</ejb-name>
<destination-jndi-name>ejb/Log</destination-jndi-name>
</message-deriven>
</enterprise-beans>
</jboss>

and the second one is a session bean that sends the message it seems the message is sending with no problem but the mdb is unable to recive it. maybe something is wrong with my jboss configuration? any suggestion?

thanks and regards
yashar
 
M Burke
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use WebSphere, so I don't know exactly where to look. But check your JMS server properties. Also, make sure your topic or queue settings are correct and the JNDI names match.

Also, you do need a JMS message service running for this to work. I am using IBM MQ. Make sure your message service is up and running.
[ December 28, 2004: Message edited by: M Burke ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic