How to set max pool size in MDB on weblogic 10.3 - weblogic-10.x

I need to set the max pool size on a MDB on weblogic 10.3.
I inserted this annotation on MDB directly
#ActivationConfigProperty(propertyName="MaxPoolSize", propertyValue="1")})
but it seems not to work.
Is there any other option to set?

Try using weblogic work manager settings to constrain the number of concurrent threads. The max-threads-constraint can be applied to a work manager set up for the specific MDB (or as part of a pool if you apply it to more than one bean)
so, for instance in weblogic-application.xml you'd have
<wls:work-manager>
<wls:name>MyMDBWorkManager</wls:name>
<wls:max-threads-constraint-name>MyMDBMaxThreads</wls:max-threads-constraint-name>
</wls:work-manager>
and applied to the beans in weblogic-ejb-jar.xml like so: (this works even when the MDB is annotated)
<wls:weblogic-enterprise-bean>
<wls:ejb-name>MyMDB</wls:ejb-name>
<wls:dispatch-policy>MyMDBWorkManager</wls:dispatch-policy>
</wls:weblogic-enterprise-bean>
The 'MyMDBMaxThreads' constraint can be specified in weblogic-application.xml, or directly in the WL Admin Console so it can be tuned on the fly.

Related

Asynchronous task execution using Spring in container managed environment

I want to run few tasks asynchronously in a web application. My question is which Spring implementation of task executors i should use in a Container managed environment.
I refereed to this chapter in Spring documentation and found few options.
One option I considered is WorkManagerTaskExecutor. This is very simple and works seamlessly with the IBM Websepher server which I'm currently using but this is very specific to IBM Websphere and Oracle Weblogic servers. I don't want to tie my code specifically to one particular implementation as in some test and local regions we are using Jetty container & this implementation creates problems to run the code in Jetty.
Other options like SimpleThreadPoolTaskExecutor does not seem to be best fit to leverage thread pooling in container managed environment and I don't want to create new thread myself.
Could you pleas suggest how do I go about this. Any pointers to a sample implementation will be great help.
As usual, it depends. If you rely on the container's thread management and want to be able to set thread pools on its admin interface or if you're application is not the only app inside the container or you use specific features like setting thread pool priorities for EJB or JMS you should add support for the WorkManagerTaskExecutor and make it configurable. If not, you can use whatever you want cause in the end threads are just threads. Since Spring is an IOC container you can do it. To use the same app everywhere I wouldn't suggest to change the XML config per app version. Rather
use profiles with configuration to set the executor type and inside your java config return the proper bean type. If you use Jetty you should have a configuration for the thread pool sizes to to be able to tune it.
use spring boot like auto configuration which usually rely on available classes on classpath (#ConditionalOnClass). If your weblogic or websphere specific classes are available or any other container specific thing like env variables you can create the WorkManagerTaskExecutor
With both of these you can deploy the same war everywhere.

How to specify JDBC setting in a struts project?

I am trying to setup a struts project locally. One way I know to set up JDBC settings as to go to administrative console of websphere and create JDBC provider and JNDI and all. But is there any other way to do in the code itself?
There is some resource reference in web.xml. I am totally new to struts.Please help.
DataSourceAlias
javaxsql.Data...... etc etc
If you configured for WAS 6.1and configuration is good you need to stop and start nodeAgents for the changes to get propagated and test the jdbc connection after restarting.....if it was WAS 8 they will be propagated automatically that means you configured improperly

How to set the object pool manager properties in WebSphere?

I created an object pool manager under Resources > Object pool managers in WebSphere Application Server 7.0. How do I set the maxSize and minSize of the pool? Can you direct me to a tutorial on how to set the properties of the pool? Also do you know of a website that list the properties that I can set?
I tried to search for it but I wasn't able to find it. Maybe I'm using the wrong keyword.
Thank you!
The ObjectPool implementation does not expose a mechanism for maximum pool size. The mechanism is somewhat primitive, and you might be better off writing your own. You might consider writing your own CustomObjectPool implementation, which would allow you to specify custom properties from the console.

Tomcat Connection Pool Concept & c3p0 connection pooling?

I have two Java Web Applications running under Tomcat (6.0) and using the Tomcat & c3p0 connection pool as Tomcat Data-source.If I define two Resources (server.xml) for two different Oracle Connection and use c3p0 for connection pool as below which my we applications use, my questions are:
<Resource
name="jdbc/OracleDB"
auth="Container"
type="com.mchange.v2.c3p0.ComboPooledDataSource"
driverClass="oracle.jdbc.OracleDriver"
factory="xxx"
jdbcUrl="jdbc:oracle:thin:#(DESCRIPTION= (LOAD_BALANCE=on)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=xxx) (PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=xxx)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=xxx)))"
maxPoolSize="10"
minPoolSize="0"
maxIdleTime="60"
maxConnectionAge="600"
acquireIncrement="1"
user="xxx="
password="xxx=" />
<Resource name="jdbc/xxx2DB"
auth="Container"
type="com.mchange.v2.c3p0.ComboPooledDataSource"
driverClass="oracle.jdbc.OracleDriver"
factory="xxx"
jdbcUrl="jdbc:oracle:thin:#xxx:1527:xxx"
maxPoolSize="10"
minPoolSize="0"
acquireIncrement="1"
maxIdleTime="60"
maxConnectionAge="600"
user="xxx"
password="xxx"
/>
Q1. Does the below in server.xml mean that two connection pools are existing in the Tomcat
memory to two different Oracle Instances?
Q2. Do I have to specify any configuration properties (ref:http://www.mchange.com/projects/c3p0/index.html#configuration_properties) , in my case I have a connection to an Oracle RAC instance and another to a single instance of Oracle. Should I take into account
any additional configuration properties in an enterprise environment ?
Q3. Are the below setting valid enough?
Q4. How do I enable c3p0 logging (i have only the jar in Tomcat lib and the above setting for now?
Any advice?
Thanks in advance.
A1: Yes.
A2: Not sure if I got the question right, but you should only specify those connection properties which defaults do not make sense to you. It's probably best to do this in the separate c3p0.properties file and specify which connection which property applies to. Answer to 'additional configuration properties' question requires to know the specifics of your environment. I would recommend looking at idle_test_period setting as these can typically have wrong defaults (make sure this matches relevant setting on the DB end).
A3: Yeah, this looks OK.
A4: You need to specify logging preferences in c3p0.properties or define them in dynamically as System properties. Refer to this chapter of the c3p0 manual.
A1: Yes
A2: Looks right at first glance. You need to be careful with RAC in case you would use distributed transactions - then I believe you would have to specify additional properties.
A3: Looks ok but depending on your task and estimated load I would play with maxIdleTime, acquireIncrement and maxPoolSize. For example with current settings after 60 seconds of inactivity your connection will be closed so next operation requesting connection after 60 seconds would incur penalty in waiting for new connection to open.
A4: http://www.mchange.com/projects/c3p0/index.html#configuring_logging
Advice:
There is a better connection pool from Tomcat 7, which could be used in Tomcat 6 as well. Consider it, especially if you need high performance
Consider connection testing so your application don't get (or get less frequently) exception when db connectivity goes down
It might be preferable to package connection pool and it's configuration within your application vs. in Tomcat. This way application WAR would be self contained so it could be just dropped into wabapps dir of tomcat.

ActivationConfig of MDB and ActivationSpec in WebSphere AS 7

I'm currently developing a small EJB 3 application for WebSphere AS 7 with WebSphere-MQSeries. It's a very simple app that mainly consists of one MDB listening on a queue, convert the incoming messages and write the extracted data into a db. I've finally got up it and running, but I'm a bit confused regarding ActivationConfig annotations in the code, the ibm-ejb-jar-bnd.xml and the activation spec in WAS itself. My main question is, why do I need ALL of them? Why should/could I specify things like the queue name or destinaton type via annotation (#ActivationConfigProperty) when I still need a activation spec in WAS where I also specify the destination e.g. Queue-Name? I addition I also need a binding via an xml file? Is that right? Is it also possible to specify the activationspec-name via annotation and thus get rid of the xml binding file? Can I avoid creating the activation spec in WAS?
Hope someone can clarify things, thanks.
You cannot avoid the Activation Spec entity because it is responsible to open connection to your JMS provider, query messages according to various options like the message selector filter.
According to WebSphere 7 InfoCenter EJB-3 annotations can replace activation specification properties from binding file but the properties required by WebSphere are not standard.
So as far as I know, you have to provide:
either the binding file, written manually or edited with the deployer tool
either at deployment setting properties in the administrative console or in automated jython/wsadmin script
Be aware that the Activation Spec is a runtime component that can be stopped, typically after some rollbacks on messages. In that case, it no longer consumes message and your MDB has nothing to process until you re-activate it from the WebSphere console.

Resources