File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes messageListenerInterface doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "messageListenerInterface doubt" Watch "messageListenerInterface doubt" New topic
Author

messageListenerInterface doubt

Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637
EJB 3.0 Core Specification
If the message-driven bean class implements more than one interface other than java.io.Serializable,
java.io.Externalizable, or any of the interfaces defined by the javax.ejb package,the message listener interface must be specified by the messageListenerInterface element of the MessageDriven annotation or the messaging-type element of the message-driven
deployment descriptor element.

Well i had this inherant feeling like my most of the quesions on Session beans, that the above statement will again contradict my code experience
and it did.

I have a MDB as shown below




ShippingRequestProcessorMDB MDB implements javax.ejb.SessionBean and javax.ejb.MessageDriven interface and it does not specify the message listener
via messageListenerInterface element of MessageDriven nor through any elements in DD. Still things worked perfectly fine.

22:52:34,750 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=chapter4.ear,jar=chapter4-ejb.jar,name=ShippingRequestMessageConsumer,service=EJB3 with dependencies:
22:52:34,812 INFO [EJBContainer] STARTED EJB: com.ejb3inaction.actionbazaar.buslogic.ShippingRequestProcessorMDB ejbName: ShippingRequestMessageConsumer
22:52:34,812 WARN [MessagingContainer] Could not find the queue destination-jndi-name=queue/ShippingRequestQueue
22:52:34,812 WARN [MessagingContainer] destination not found: queue/ShippingRequestQueue reason: javax.naming.NameNotFoundException: ShippingRequestQueue not bound
22:52:34,828 WARN [MessagingContainer] creating a new temporary destination: queue/ShippingRequestQueue
22:52:34,843 INFO [ShippingRequestQueue] Bound to JNDI name: queue/ShippingRequestQueue
22:52:34,906 INFO [EJB3Deployer] Deployed: file:/E:/DJ/Certifications/Java/SCBCD/Application Servers/JBOSS/jboss-4.2.3.GA/server/default/tmp/deploy/tmp37578chapter4.ear-contents/chapter4-ejb.jar
22:52:35,109 INFO [EARDeployer] Started J2EE application: file:/E:/DJ/Certifications/Java/SCBCD/Application Servers/JBOSS/jboss-4.2.3.GA/server/default/deploy/chapter4.ear
22:52:35,265 INFO [Http11Protocol] Starting Coyote HTTP/1.1 on http-127.0.0.1-8080
22:52:35,296 INFO [AjpProtocol] Starting Coyote AJP/1.3 on ajp-127.0.0.1-8009
22:52:35,343 INFO [Server] JBoss (MX MicroKernel) [4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)] Started in 27s:781ms
22:53:26,250 INFO [STDOUT] INSERT INTO SHIPPING_REQUESTS(ITEM, SHIPPING_ADDRESS, SHIPPING_METHOD, INSURANCE_AMOUNT) VALUES ( 10101, '101 Easy Street', ' Snail mail', 101.0)
22:53:26,250 INFO [STDOUT] Shipping request processed.


Have i done something wrong??? Why is this contradicting behavior?


SCJP, SCWCD, SCBCD
Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637
Please take time to respond to this question.
Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637
Experts/Ranchers, Please take time and reply.
Chaminda Amarasinghe
Ranch Hand

Joined: May 17, 2006
Posts: 402
Deepak Jain wrote:Experts/Ranchers, Please take time and reply.


Please give time to reply

About your issue?

1. Seems you have not created the specified destination. Before you deploy a MDB, queue or topic which mdb is listening should be available.
1. Dont implemetn SessionBean
2. Did you implemented onMessage correctly?

Regards
Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637
My whole idea here was to test this sentence from EJB 3.0 specification.

f the message-driven bean class implements more than one interface other than java.io.Serializable, java.io.Externalizable, or any of the interfaces defined by the javax.ejb package,the message listener interface must be specified by the messageListenerInterface element of the MessageDriven annotation or the messaging-type element of the message-driven deployment descriptor element.


As i said "ShippingRequestProcessorMDB MDB implements javax.ejb.SessionBean and javax.ejb.MessageDriven interface and it does not specify the message listener via messageListenerInterface element of MessageDriven or through any elements in DD. Still things worked perfectly fine."
I was expecting the MDB not to work, but still everything worked perfectly.
I even tried the below code


In the above MDB it implements MyInterface1 and MyInterface2, which do not belong to javax.ejb. package. Which means according to Spec , I should have specfied the message listener interface MessageListener in the messageListenerInterface element of MessageDriven, which i did not. And still everything worked perfectly.
The above code is violating EJB Spec.

Again i have used JBoss to test the code. And like most of other questions that i have posted on spec violation, I think Jboss is violating the Spec left and right. I think i should not have started using JBoss as a novice EJB developer.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: messageListenerInterface doubt