Reputation: 9479
In Weblogic 12c, how can I have only one instance/thread of Message driven bean.
I can't find the equivalent annotation attribute for "max-beans-in-free-pool" as defined here https://docs.oracle.com/cd/E24329_01/web.1211/e24977/summary.htm#WLMDB1385
Java code:-
@MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "connectionFactoryJndiName", propertyValue = "jms/myConnectionFactory"),
@ActivationConfigProperty(propertyName = "destinationJndiName", propertyValue = "jms/myQueue"),
@ActivationConfigProperty(propertyName = "MaxPoolSize", propertyValue = "1") })
public class JayMDB implements MessageListener {
Extra reference: https://docs.oracle.com/cd/E24329_01/web.1211/e24390/mdbtuning.htm#PERFM271
Upvotes: 0
Views: 1971
Reputation: 9479
Thanks guys for the inputs, Yes I solved this issue with combinations of Work Managers & max-beans-in-free-pool, maxSession attributes. Here is my full code for those who need it latter.
weblogic.xml
<?xml version='1.0' encoding='UTF-8'?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.6/weblogic-web-app.xsd">
<session-descriptor></session-descriptor>
<jsp-descriptor></jsp-descriptor>
<container-descriptor></container-descriptor>
<work-manager>
<name>WorkManager-MDB</name>
<max-threads-constraint>
<name>MaxThreadsConstraint-MDB</name>
<count>1</count>
</max-threads-constraint>
</work-manager>
</weblogic-web-app>
weblogic-ejb-jar.xml
<?xml version='1.0' encoding='UTF-8'?>
<weblogic-ejb-jar xmlns="http://xmlns.oracle.com/weblogic/weblogic-ejb-jar"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-ejb-jar http://www.oracle.com/technology/weblogic/weblogic-ejb-jar/1.1/weblogic-ejb-jar.xsd">
<weblogic-enterprise-bean>
<ejb-name>JayMDB</ejb-name>
<message-driven-descriptor>
<pool>
<max-beans-in-free-pool>1</max-beans-in-free-pool>
</pool>
</message-driven-descriptor>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>
Message Driven Bean
@MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "connectionFactoryJndiName", propertyValue = "jms/myConnectionFactory"),
@ActivationConfigProperty(propertyName = "destinationJndiName", propertyValue = "jms/myQueue"),
@ActivationConfigProperty(propertyName = "maxSession", propertyValue = "1")})
public class JayMDB implements MessageListener {
Upvotes: 0
Reputation: 870
Have you tried to work with weblogic's workmanagers ? From the admin console -> Create one, assign 1 to a new max thread capacity constraint and assign it to your work manager. Use this work manager within your MDB (to set in your weblogic-ra.xml for example).
In this case you will have only one thread by node that your MDB is targeted on.
Upvotes: 1