Rajesh Kottayil

Greenhorn
+ Follow
since Jun 21, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Rajesh Kottayil

Dear friends,

If anyone knows the working of object locking, its implementation in enterprise applications, please give your suggestions.

regards,
RajeshKR

Cameron Wallace McKenzie wrote:What did you try that didn't work? What was the error that was generated?

-Cameron McKenzie





Hello Cameron,

There was no error. But the locking was not worked as expected. Scenario is,

I am using the lock method of OpenJPAEntityManager like this:

openjpainstance.lock(entityinstance,LockModeType.Write, -1);

and after this ... i am updating the entity and merging it.

then before commit() statement , i put the thread to sleep for 10sec. so that i can start another

client thread to modify the same entity. And it also executes up to the sleep method.

But, what i expected that , it will be blocked when execution gets to :

openjpainstance.lock(entityinstance,LockModeType.Write,4000); line of code.

And this doesn't happened. As its described in theories.

please provide your great thoughts....


regards,
Rajesh


Hello Frndz.

I tried to optimize concurrency control through Object Locking at application level. Overriding Database Locking by default. But, the Object Locking doesn't worked. And the default database locking worked. But I wanted application level locking of object/record/column of a table and not the commit time locking.

Can anyone give working example to Object Locking???

regards,
RajeshKR

Rajesh Kottayil wrote:
Hello friends,

I am facing bottle neck with Object Locking for an Entity bean using OpenJPA Persistence Manager under Weblogic 10.0 application server deployments.

I want to block [ for the specific method ] entity bean being accessed from other client programs when they invoke common method in a Stateless Session EJB. Particularly, Consider the situation:

Client1: Modifying Customer entity with id: 100. Then I locked that entity using OpenJPA Entity Manager within the transaction block. And i entered that thread to sleep before committing the transaction.

At this time, started new thread, Client2: Modifying the same Customer entity with id:100. I expected this thread will be get blocked when control pass to the lock() method. But it doesn't happened. It goes through the line of codes and also put into sleep.

After thread sleep timeout, first thread Client1 commit successfully. But the second gets Rollback Exception due to optimistic lock exception occurring since customer entity is modified in another transaction.

This exception is occurred because of Database level concurrency control for optimistic locking in a weblogic server. Its default to weblogic.

But, what i expected is to assert lock at the object level, thereby the 2nd thread - Client2 will be blocked while Client1 is in the middle of a transaction and then Client2 use modified Customer entity . But it doesn't happened. I used Kodo Persistance Provider as Persistence Unit, OpenJPAEntityManager to do transaction, locking , finding and merging the entity bean.

Can anyone provide help to fine grain this object locking functionality ??? I look forward to your brilliant thoughts......



Rajesh KR
Geojit Technologies







Hello frndz,
I need your help to solve this problem of "Object Locking", please anyone who had worked with object locking of Entity Beans in an enterprise application development, please give light to this thread....



please help......
Rajesh



Hello friends,

I am facing bottle neck with Object Locking for an Entity bean using OpenJPA Persistence Manager under Weblogic 10.0 application server deployments.

I want to block [ for the specific method ] entity bean being accessed from other client programs when they invoke common method in a Stateless Session EJB. Particularly, Consider the situation:

Client1: Modifying Customer entity with id: 100. Then I locked that entity using OpenJPA Entity Manager within the transaction block. And i entered that thread to sleep before committing the transaction.

At this time, started new thread, Client2: Modifying the same Customer entity with id:100. I expected this thread will be get blocked when control pass to the lock() method. But it doesn't happened. It goes through the line of codes and also put into sleep.

After thread sleep timeout, first thread Client1 commit successfully. But the second gets Rollback Exception due to optimistic lock exception occurring since customer entity is modified in another transaction.

This exception is occurred because of Database level concurrency control for optimistic locking in a weblogic server. Its default to weblogic.

But, what i expected is to assert lock at the object level, thereby the 2nd thread - Client2 will be blocked while Client1 is in the middle of a transaction and then Client2 use modified Customer entity . But it doesn't happened. I used Kodo Persistance Provider as Persistence Unit, OpenJPAEntityManager to do transaction, locking , finding and merging the entity bean.

Can anyone provide help to fine grain this object locking functionality ??? I look forward to your brilliant thoughts......



Rajesh KR
Geojit Technologies

brajen mathema wrote:hi,

i have injected the persistence context in my session bean as:

@PersistenceContext(unitName = "Project-PU")
private EntityManager em;




my glassfish setting under resource is as follows


General Settings

Name: mssql/db_mssql
Datasource Classname: com.microsoft.sqlserver.jdbc.SQLServerXADataSource
Resource Type: javax.sqlXADataSource




Pool Settings
Initial and Minimum Pool Size: 10 Connections
Maximum Pool Size: 100 Connections
Pool Resize Quantity: 5 Connections
Idle Timeout: 300 Seconds
Max Wait Time: 60000 Milliseconds

Connection Validation
Connection Validation: not checked(i.e disabled)
Validation Method: auto-commit(selected value)
Table Name: not selected
On Any Failure: not checked
Allow Non Component Callers: not checked


Transaction
Non Transactional Connections: Enabled
Transaction Isolation:not selected
Isolation Level: not selected


in advance tab : default values are used

so what's the problem...

any idea....
what else are the required setting for CMT in glassfish or stateless ejb class

thanks..
-brajen




Hello brajen mathema,

I had one suggestion on database driver configuration you selected,
can you try it with the
com.microsoft.sqlserver.jdbc.SQLServerDataSource driver.

Hello friends,

I am facing bottle neck with Object Locking for an Entity bean using OpenJPA Persistence Manager under Weblogic 10.0 application server deployments.

I want to block [ for the specific method ] entity bean being accessed from other client programs when they invoke common method in a Stateless Session EJB. Particularly, Consider the situation:

Client1: Modifying Customer entity with id: 100. Then I locked that entity using OpenJPA Entity Manager within the transaction block. And i entered that thread to sleep before committing the transaction.

At this time, started new thread, Client2: Modifying the same Customer entity with id:100. I expected this thread will be get blocked when control pass to the lock() method. But it doesn't happened. It goes through the line of codes and also put into sleep.

After thread sleep timeout, first thread Client1 commit successfully. But the second gets Rollback Exception due to optimistic lock exception occurring since customer entity is modified in another transaction.

This exception is occurred because of Database level concurrency control for optimistic locking in a weblogic server. Its default to weblogic.

But, what i expected is to assert lock at the object level, thereby the 2nd thread - Client2 will be blocked while Client1 is in the middle of a transaction and then Client2 use modified Customer entity . But it doesn't happened. I used Kodo Persistance Provider as Persistence Unit, OpenJPAEntityManager to do transaction, locking , finding and merging the entity bean.

Can anyone provide help to fine grain this object locking functionality ??? I look forward to your brilliant thoughts......



Rajesh KR
Geojit Technologies