Creating multiple instances of one MessageDriven Bean
I'm using a MessageDriven Bean in two different applications, and I'd like th开发者_如何学编程em to be separate instances using separate Queues.
This SO question confirmed my notion that I should be able to set this up in the deployment descriptors (ejb-jar.xml? glassfish-ejb-jar.xml?). Maybe simply overriding the mappedName
in the MDB's annotation is enough?
I'd be thankful if someone could point me to a good example of how to do this in Glassfish (or clarify matters if I'm confusing things here).
UPDATE:
To clarify, there's the MDB called AnalyzerBean
and the Resource called AnalyzerHelper
(the former reads from the Queue, the latter writes into it). Am I correct to assume that <ejb-ref-name>
corresponds to the name
attribute and <jndi-name>
corresponds to the mappedName
attribute?
My glassfish-ejb-jar.xml now looks something like this. I'm trying to give unique JNDI names to Resource and MDB, but I keep getting errors:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-ejb-jar PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 EJB 3.1//EN" "http://glassfish.org/dtds/glassfish-ejb-jar_3_1-1.dtd">
<glassfish-ejb-jar>
<enterprise-beans>
<ejb>
<ejb-name>analyzerBean</ejb-name>
<jndi-name>analyzerBean</jndi-name>
<ejb-ref>
<ejb-ref-name>analyzerBean</ejb-ref-name>
<jndi-name>analyzerBeanQueue1</jndi-name>
</ejb-ref>
<resource-ref>
<res-ref-name>analyzerHelper</res-ref-name>
<jndi-name>analyzerHelperResource1</jndi-name>
</resource-ref>
</ejb>
</enterprise-beans>
</glassfish-ejb-jar>
精彩评论