I did a test with
https://svn.java.net/svn/glassfish~svn/trunk/v2/appserv-tests/devtests/ejb/ejb30/hello/mdb/
adding:
Index: ejb/MessageBean.java
===================================================================
--- ejb/MessageBean.java (revision 49273)
+++ ejb/MessageBean.java (working copy)
@@ -33,6 +33,11 @@
@Resource(mappedName="jms/ejb_ejb30_hello_mdb_OutQueue") Queue
clientQueue;
+ @javax.annotation.PostConstruct
+ private void postConstruct() {
+ System.out.println("### In postConstruct of " +
System.identityHashCode(this));
+ }
+
public void onMessage(Message message) {
System.out.println("Got message!!!");
Index: client/Client.java
===================================================================
--- client/Client.java (revision 49273)
+++ client/Client.java (working copy)
@@ -46,7 +46,7 @@
private QueueReceiver queueReceiver;
- private int numMessages = 2;
+ private int numMessages = 100;
public Client(String[] args) {
if( args.length == 1 ) {
I can see PostConstruct is called 20 times (20 unique instances), while
onMessage is called 100 times (grep -i 'got message' server.log | wc
-l). I tested with 3.2 trunk build ( I don't have a v2 install right
now, but I guess it should be the same).
I would check in your app:
1, does onMessage directly or indirectly call PostConstruct?
2, pooling is affected not only by <bean-pool> in glassfish-ejb-jar.xml,
but also activation config properties of the resource adapter, but I'm
not familiar with how wmq adapter interacts with GlassFish.
-cheng
On 9/7/11 8:03 PM, Jackson, Brian R. wrote:
> Cheng,
>
> The MDB is annotated with @MessageDriven and nothing else. My
> sun-ejb-jar.xml is below. We are connecting to Websphere MQ 7 using IBM's
> JCA resource adapter. Anything else that I should be looking at?
>
> ---
> sun-ejb-jar.xml
> ---
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application
> Server 9.0 EJB 3.0//EN"
> "http://www.sun.com/software/appserver/dtds/sun-ejb-jar_3_0-0.dtd">
> <sun-ejb-jar>
> <enterprise-beans>
> <unique-id>1</unique-id>
> <ejb>
> <ejb-name>AlertRouterBean</ejb-name>
> <mdb-resource-adapter>
> <resource-adapter-mid>wmq.jmsra</resource-adapter-mid>
> <activation-config>
> <!-- Props that create a JMS connection -->
> <activation-config-property>
>
> <activation-config-property-name>brokerQueueManager</activation-config-prop
> erty-name>
>
> <activation-config-property-value>QM_EXAM_01</activation-config-property-va
> lue>
> </activation-config-property>
> <activation-config-property>
>
> <activation-config-property-name>channel</activation-config-property-name>
>
> <activation-config-property-value>MY.JMS.PROCESS</activation-config-propert
> y-value>
> </activation-config-property>
> <activation-config-property>
>
> <activation-config-property-name>hostName</activation-config-property-name>
>
> <activation-config-property-value>qm.example.com</activation-config-propert
> y-value>
> </activation-config-property>
> <activation-config-property>
>
> <activation-config-property-name>port</activation-config-property-name>
>
> <activation-config-property-value>1234</activation-config-property-value>
> </activation-config-property>
> <activation-config-property>
>
> <activation-config-property-name>queueManager</activation-config-property-n
> ame>
>
> <activation-config-property-value>QM_EXAM_01</activation-config-property-va
> lue>
> </activation-config-property>
> <!-- Props that create a JMS connection consumer -->
> <activation-config-property>
>
> <activation-config-property-name>destination</activation-config-property-na
> me>
>
> <activation-config-property-value>MY.QUEUE</activation-config-property-valu
> e>
> </activation-config-property>
> <activation-config-property>
>
> <activation-config-property-name>destinationType</activation-config-propert
> y-name>
>
> <activation-config-property-value>javax.jms.Queue</activation-config-proper
> ty-value>
> </activation-config-property>
> <activation-config-property>
>
> <activation-config-property-name>maxPoolDepth</activation-config-property-n
> ame>
>
> <activation-config-property-value>100</activation-config-property-value>
> </activation-config-property>
> </activation-config>
> </mdb-resource-adapter>
> <resource-ref>
> <!-- binds the ref to the actual jndi name,
> they just happen to be the same, but they don't have
> to be -->
> <res-ref-name>jdbc/gAlerts</res-ref-name>
> <jndi-name>jdbc/gAlerts</jndi-name>
> </resource-ref>
> <bean-pool>
> <steady-pool-size>10</steady-pool-size>
> <resize-quantity>2</resize-quantity>
> <max-pool-size>100</max-pool-size>
> <pool-idle-timeout-in-seconds>600</pool-idle-timeout-in-seconds>
> </bean-pool>
>
> </ejb>
>
> </enterprise-beans>
> </sun-ejb-jar>
>
>
>
> On 9/7/11 7:53 PM, "Cheng Fang"<cheng.fang_at_oracle.com> wrote:
>
>> PostConstruct method is invoked when bean instances are created. It
>> should not be invoked when servicing incoming messages. But it's
>> possible your MDB is configured in a way that each incoming message
>> causes a new instance to be created.
>>
>> -cheng
>>
>> On 9/7/11 7:35 PM, Jackson, Brian R. wrote:
>>> I'm using Glassfish 2.1.1 and I've just profiled my app and see that
>>> my @PostConstruct method appears to be called on every message rather
>>> than when the MDB is created in the bean pool. Is this the expected
>>> behavior? Have I configured or coded something incorrectly?
>> Please consider the environment before printing this e-mail.