users@glassfish.java.net

env-entry with injection-target required for multiinstance MDB (single class,

From: <forums_at_java.net>
Date: Thu, 16 Jun 2011 13:22:34 -0500 (CDT)

I have several MDBs (same class) different descriptor, basically for doing
the same thing on multiple destinations, this is excerpt from ejb-jar.xml

<message-driven> <ejb-name>Incoming1</ejb-name>
<ejb-class>X.ejb.Incoming</ejb-class> <activation-config>
<activation-config-property>
<activation-config-property-name>destination</activation-config-property-name>
<activation-config-property-value>QUEUE1</activation-config-property-value>
</activation-config-property> <activation-config-property>
<activation-config-property-name>destinationType</activation-config-property-name>
<activation-config-property-value>javax.jms.Queue</activation-config-property-value>
</activation-config-property> <activation-config-property>
<activation-config-property-name>transportType</activation-config-property-name>
<activation-config-property-value>BINDINGS</activation-config-property-value>
</activation-config-property> <activation-config-property>
<activation-config-property-name>queueManager</activation-config-property-name>
<activation-config-property-value>QM</activation-config-property-value>
</activation-config-property> <activation-config-property>
<activation-config-property-name>maxMessages</activation-config-property-name>
<activation-config-property-value>1</activation-config-property-value>
</activation-config-property> <activation-config-property>
<activation-config-property-name>maxPoolDepth</activation-config-property-name>
<activation-config-property-value>1</activation-config-property-value>
</activation-config-property> <activation-config-property>
<activation-config-property-name>poolTimeout</activation-config-property-name>
<activation-config-property-value>300000</activation-config-property-value>
</activation-config-property> </activation-config> <env-entry>
<env-entry-name>X.ejb.Incoming/source</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>queue://QUEUE</env-entry-value> <injection-target>
<injection-target-class>X.ejb.Incoming</injection-target-class>
<injection-target-name>source</injection-target-name> </injection-target>
</env-entry> <env-entry>
<env-entry-name>X.ejb.Incoming/destination</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>OTHERQUEUE</env-entry-value> <injection-target>
<injection-target-class>X.ejb.Incoming</injection-target-class>
<injection-target-name>destination</injection-target-name>
</injection-target> </env-entry> </message-driven> <message-driven>
<ejb-name>Incoming2</ejb-name> <ejb-class>X.ejb.Incoming</ejb-class>
<activation-config> <activation-config-property>
<activation-config-property-name>destination</activation-config-property-name>
<activation-config-property-value>QUEUE2</activation-config-property-value>
</activation-config-property> <activation-config-property>
<activation-config-property-name>destinationType</activation-config-property-name>
<activation-config-property-value>javax.jms.Queue</activation-config-property-value>
</activation-config-property> <activation-config-property>
<activation-config-property-name>transportType</activation-config-property-name>
<activation-config-property-value>BINDINGS</activation-config-property-value>
</activation-config-property> <activation-config-property>
<activation-config-property-name>queueManager</activation-config-property-name>
<activation-config-property-value>QM</activation-config-property-value>
</activation-config-property> <activation-config-property>
<activation-config-property-name>maxMessages</activation-config-property-name>
<activation-config-property-value>1</activation-config-property-value>
</activation-config-property> <activation-config-property>
<activation-config-property-name>maxPoolDepth</activation-config-property-name>
<activation-config-property-value>1</activation-config-property-value>
</activation-config-property> <activation-config-property>
<activation-config-property-name>poolTimeout</activation-config-property-name>
<activation-config-property-value>300000</activation-config-property-value>
</activation-config-property> </activation-config> <env-entry>
<env-entry-name>X.ejb.Incoming/source</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>queue://QUEUE</env-entry-value> <injection-target>
<injection-target-class>X.ejb.Incoming</injection-target-class>
<injection-target-name>source</injection-target-name> </injection-target>
</env-entry> <env-entry>
<env-entry-name>X.ejb.Incoming/destination</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>OTHERQUEUE</env-entry-value> <injection-target>
<injection-target-class>X.ejb.Incoming</injection-target-class>
<injection-target-name>destination</injection-target-name>
</injection-target> </env-entry> </message-driven>
and excerpt from X.ejb.Incoming.java

public class Incoming implements MessageListener @Resource private
MessageDrivenContext context; @Resource private String source; @Resource
private String destination;
How do I properly specify env-entry injection? Above code is the only one
which works for setup which one class, multiple instance MDB (I mean multiple
instance with different configuration) i.e. destination and source will be
set to correct env-entry.

If I have just one instance this (below) works as well, i.e. I can remove
injection-target:

<message-driven> <ejb-name>Incoming2</ejb-name>
<ejb-class>X.ejb.Incoming</ejb-class> <activation-config>
<activation-config-property>
<activation-config-property-name>destination</activation-config-property-name>
<activation-config-property-value>QUEUE2</activation-config-property-value>
</activation-config-property> <activation-config-property>
<activation-config-property-name>destinationType</activation-config-property-name>
<activation-config-property-value>javax.jms.Queue</activation-config-property-value>
</activation-config-property> <activation-config-property>
<activation-config-property-name>transportType</activation-config-property-name>
<activation-config-property-value>BINDINGS</activation-config-property-value>
</activation-config-property> <activation-config-property>
<activation-config-property-name>queueManager</activation-config-property-name>
<activation-config-property-value>QM</activation-config-property-value>
</activation-config-property> <activation-config-property>
<activation-config-property-name>maxMessages</activation-config-property-name>
<activation-config-property-value>1</activation-config-property-value>
</activation-config-property> <activation-config-property>
<activation-config-property-name>maxPoolDepth</activation-config-property-name>
<activation-config-property-value>1</activation-config-property-value>
</activation-config-property> <activation-config-property>
<activation-config-property-name>poolTimeout</activation-config-property-name>
<activation-config-property-value>300000</activation-config-property-value>
</activation-config-property> </activation-config> <env-entry>
<env-entry-name>X.ejb.Incoming/source</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>queue://QUEUE</env-entry-value> </env-entry> <env-entry>
<env-entry-name>X.ejb.Incoming/destination</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>OTHERQUEUE</env-entry-value> </env-entry> </message-driven>
However I cannot remove injection-target for multinstance MDB, otherwise
>@Resource String destination, source< will be null. Is injection-target the
correct way to achieve what I want? Thanks

 


--
[Message sent by forum member 'petino']
View Post: http://forums.java.net/node/813034