0

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

Jay
  • 9,189
  • 12
  • 56
  • 96
  • That seems like a bottleneck. Why would you not want a larger pool for those peak times when requests are pouring in? – duffymo Dec 02 '16 at 18:44
  • Did you try this? Might be viable for a WLS 12c http://stackoverflow.com/questions/8939292/how-to-set-max-pool-size-in-mdb-on-weblogic-10-3 – Filip Dec 02 '16 at 18:53
  • @Filip thanks mate I would try that. Actually I have not used weblogic-application.xml and have used no xml and all anotations only. Hope I would be able to mix xml & annotations. – Jay Dec 02 '16 at 19:03
  • @duffymo Thanks. I understand. But the other side third part SOAP Webservices api gets deadlock errors if we pump concurrent calls...hence trying to restrict one call at a time. – Jay Dec 02 '16 at 19:05
  • Web services should be stateless and idempotent. I'd investigate the deadlock and fix it instead of putting a governor on to hobble your system. – duffymo Dec 02 '16 at 19:37
  • @duffymo Thanks. Does stateless & Idempotent applies to SOAP webservices too or is it only for REST API.s ? – Jay Dec 05 '16 at 16:05
  • I think it's advisable for all web services, regardless of REST or SOAP or anything else. – duffymo Dec 05 '16 at 21:54

2 Answers2

1

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.

RVA
  • 790
  • 3
  • 14
  • 33
0

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 {
Jay
  • 9,189
  • 12
  • 56
  • 96