Hi Guys,
Little Help Needed here, You tips would be helpful.
I am sending a messgae from the
Servlet to the Queue and have configured QueueConnectionFactory and Queue in the jms.xml file in OC4J.
A MDB has been deployed within the same EAR. Servlet can successfully send the messages to the queue but for some reason MDB is not responding or seems to be doing anything in response. I tried to write some console output but seems like messages are not being delivered to the MDB.
I have doubt on configuration. Do i have to add any entry for the Queue in the MDB deployment desctriptors!
Regards
Salman
<?xml version = '1.0' encoding = 'windows-1252'?>
<!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>
<description>Message Driven Bean</description>
<display-name>MessageDrivenEJB</display-name>
<ejb-name>MessageDrivenEJB</ejb-name>
<ejb-class>voa.rsa.messaging.MessageDrivenEJBBean</ejb-class>
<transaction-type>Container</transaction-type>
<acknowledge-mode>Auto-acknowledge</acknowledge-mode>
<message-driven-destination>
<destination-type>javax.jms.Queue</destination-type>
<subscription-durability>Durable</subscription-durability>
</message-driven-destination>
<security-identity/>
</message-driven>
</enterprise-beans>
<assembly-descriptor/>
</ejb-jar>
Servlet Call:
private void sendMessageToQueue(
String msg) {
TextMessage message;
try {
InitialContext ic = new InitialContext();
QueueConnectionFactory qcf = ( QueueConnectionFactory)ic.lookup("jms/MyQueueConnectionFactory");
Queue queue = (Queue)ic.lookup("jms/MyQueue");
QueueConnection qc = qcf.createQueueConnection();
QueueSession qs = qc.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
QueueSender qSender = qs.createSender(queue);
message = qs.createTextMessage();
for (int x = 0 ; x < 6; x++) {
message.setText(" Sending This Message: " + msg + " : "+(x + 1 ));
System.out.println("Sending message: " + message.getText());
qSender.send(message);
}
} catch(NamingException ne) {
System.out.println("NamingException in JMSQueueServlet: " + ne.getMessage());
ne.printStackTrace();
} catch(Exception ex) {
System.out.println("Exception in JMSQueueServlet: " + ex.getMessage());
ex.printStackTrace();
}
}