-
1. Re: how to use @Pool annotation class
jaikiran Sep 29, 2014 2:13 AM (in response to flamant)Here's how it's supposed to be used https://developer.jboss.org/message/639714#639714
-
2. Re: how to use @Pool annotation class
flamant Oct 3, 2014 3:41 AM (in response to jaikiran)Hello jaikiran pai and thank you for your answer.
Could you tell me if it is possible to check, programmaticaly or by an administration way that the size of the pool of the stateless session bean is of a certain size when jboss is running ?
-
3. Re: how to use @Pool annotation class
flamant Oct 3, 2014 7:09 AM (in response to jaikiran)Hello again jaikiran pai,
here is the stateless session bean
@Stateless
@Pool(value="PoolSize500")
public class LibrarySessionBean implements LibrarySessionBeanRemote {
private List<String> bookShelf;
/**
Here is my jboss-ejb3.xml file
<?xml version="1.1" encoding="UTF-8"?>
<jboss:ejb-jar xmlns:jboss="http://www.jboss.com/xml/ns/javaee"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:c="urn:clustering:1.0"
xmlns:p="urn:ejb-pool:1.0"
xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-ejb3-2_0.xsd http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"
version="3.1"
impl-version="2.0">
<enterprise-beans>
<session>
<ejb-name>LibrarySessionBean</ejb-name>
<ejb-class>com.tutorialspoint.sessionbean.stateless.LibrarySessionBean</ejb-class>
</session>
</enterprise-beans>
<assembly-descriptor>
<p:pool>
<ejb-name>LibrarySessionBean</ejb-name>
<p:bean-instance-pool-ref>PoolSize500</p:bean-instance-pool-ref>
</p:pool>
</assembly-descriptor>
</jboss:ejb-jar>
Eclipse mentionned the error described in this post: https://developer.jboss.org/thread/249203
Here is the appropriate part defined in my standalone.xml file
<subsystem xmlns="urn:jboss:domain:ejb3:1.4"> <session-bean> <stateless> <bean-instance-pool-ref pool-name="slsb-strict-max-pool"/> </stateless> <stateful default-access-timeout="5000" cache-ref="simple"/> <singleton default-access-timeout="5000"/> </session-bean> <pools> <bean-instance-pools> <strict-max-pool name="slsb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/> <strict-max-pool name="mdb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/> <strict-max-pool name="PoolSize500" max-pool-size="500" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="SECONDS"/> </bean-instance-pools> </pools> Here the appropriate part in the domain.xml file
<subsystem xmlns="urn:jboss:domain:ee:1.1"> <spec-descriptor-property-replacement>false</spec-descriptor-property-replacement> <jboss-descriptor-property-replacement>true</jboss-descriptor-property-replacement> </subsystem> <subsystem xmlns="urn:jboss:domain:ejb3:1.4"> <session-bean> <stateless> <bean-instance-pool-ref pool-name="slsb-strict-max-pool"/> </stateless> <stateful default-access-timeout="5000" cache-ref="simple"/> <singleton default-access-timeout="5000"/> </session-bean> <pools> <bean-instance-pools> <strict-max-pool name="slsb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/> <strict-max-pool name="mdb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/> <strict-max-pool name="PoolSize500" max-pool-size="500" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>
</bean-instance-pools>
</pools> But when I lookup a stateless session bean the server always returns me the same stateless session bean and not one among the 500 (supposed ?) existing
-
4. Re: how to use @Pool annotation class
flamant Oct 3, 2014 9:06 AM (in response to jaikiran)Hello again,
In fact, i make a tutorial on EJB. I want to show one difference between stateless session bean and statefull session bean. Both have an attribut : private List<String> bookShelf; (which is not appropriate for a stateless session bean, I know)
When I lookup once and again a stateless session bean I thought that jboss would send me back 2 different stateless session bean (coming from the pool), and then I would loose the initialized value from the first call.
But it is not behaving this way. The second lookup send me back the same stateless session bean and I keep my state. Then, my demonstration go up in smoke
-
5. Re: how to use @Pool annotation class
flamant Oct 3, 2014 11:12 AM (in response to jaikiran)Hello again,
I abandoned the pool configuration I tried to make a lookup every ms in a paralell thread, but it still send me back the same stateless session bean
Re-bonjour,
-
6. Re: how to use @Pool annotation class
flamant Oct 9, 2014 1:39 PM (in response to flamant)Hello again,
I finally understood the general problem.
When you make a remote lookup on a SLSB as a client, the server side send back a proxy. When you use a method on that proxy, the server will use a random SLSB from the pool.
When I was making 2 successive call from the client side, the pool from the server side had a size of one SLSB and I used the same SLSB with it own state. When I create 15 SLSB with 15 different thread, and afterwards I make a remote lookup, the proxy will invoque one of the SLSB from the pool that is made of now several instances (in my case 13). The SLSB used by the lookup will be random among the pool instances- (13 in my case). The discussion is resolved.