Skip to main content

JCA Connection Association problem (Glassfish v3)

3 replies [Last post]
rpolozov
Offline
Joined: 2003-07-15
Points: 0

Hello,

I try to implement my own JCA resource adapter, but face the problem connected to connection association.

My resource adapter should provide the possibility to connect to undefined number of EIS.
So I try to transfer connection settings in ConnectionSpec structure (instead of defining them in Connection Pool settings).

That resource adapter is used in Session Bean.

If session bean creates and uses just one connection everything works fine.

But if session bean in one method creates and tries to use two connections with different parameters, then second connection is associated with the same ManagedConnection as the first Connection (this is a problem).
This works this way:
- AS try to find any matched ManagedConnection in the pool, but my ManagedConnectionFactory.matchManagedConnections implementation always returns null, because connection settings are different.
- AS creates new ManagedConnection with new connection settings
- AS try to find any matched ManagedConnection in the pool and finds new one (matchManagedConnections returns it)
- AS calls ManagedConnection.associateConnection of first Managed Connection and associate new Connection with it (but it was created with different connection settings...)
- AS returns Connection to my session bean
- When my sesion bean closes connection, AS calls ManagedConnection.associateConnection of last Managed Connection and restores association of second Connection with correct Managed Connection.

Could anybody please help with this problem or just explain why this happens?
Is it possible to prevent connection reassociation in this case?

Thanks in advance,
Roman

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jr158900
Offline
Joined: 2005-04-13
Points: 0

This behavior is due to connection sharing.

You can refer :
1) Connector Specification 1.6 (JSR 322) :
Section : 7.9 Connection Sharing
2) http://blogs.sun.com/JagadishPrasath/entry/connectionsharinginglassfish

a)
The implementation under discussion uses same connection factory to talk to 2 external systems which can be an issue if the resource-adapter's transaction support that will be offered by this connection-factory (and hence the connection pool) is "LocalTransaction".

For LocalTransaction capable resources (connections), connection sharing will always be done as multiple resources cannot be used in a LocalTransaction.

b)
If the implementation under discussion has XATransaction capability, then you can specify
Unshareable in the "resource-ref" of ejb-jar/web.xml

c)
If the implementation does not need to take part in transaction, you can create a non-transactional connection pool (--transactionsupport attribute).

For (b) and (c) sharing will not happen.

sam_sepassi
Offline
Joined: 2010-12-16
Points: 0

I have a misunderstanding regarding the connection handle sharing in JCA.

I want to know if the connection sharing only happens during a phase of transaction ( multiple components call ) or the connection sharing is possible amongst multiple clients accessing a component that has the same EIS destination.

I created my own resource adapter on Glassfish application server 3.1. The problem is the resource adapter doesn't perform any connection sharing (no associateConnection method call).

Thanks

mgainty
Offline
Joined: 2004-05-21
Points: 0

you'll need to acquire either a DataSource object OR a ConnectionFactory object

http://publib.boulder.ibm.com/infocenter/ieduasst/v1r1m0/index.jsp?topic...

which object are you acquiring?
Martin Gainty
______________________________________________
Jogi és Bizalmassági kinyilatkoztatás/Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
Ez az
üzenet bizalmas. Ha nem ön az akinek szánva volt, akkor kérjük, hogy
jelentse azt nekünk vissza. Semmiféle továbbítása vagy másolatának
készítése nem megengedett. Ez az üzenet csak ismeret cserét szolgál és
semmiféle jogi alkalmazhatósága sincs. Mivel az electronikus üzenetek
könnyen megváltoztathatóak, ezért minket semmi felelöség nem terhelhet
ezen üzenet tartalma miatt.

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.

> To: users@glassfish.java.net
> Subject: Re: JCA Connection Association problem (Glassfish v3)
> From: forums@java.net
> Date: Sun, 23 Sep 2012 07:30:14 -0500
>
> I have a misunderstanding regarding the connection handle sharing in JCA. I
> want to know if the connection sharing only happens during a phase of
> transaction ( multiple components call ) or the connection sharing is
> possible amongst multiple clients accessing a component that has the same EIS
> destination. I created my own resource adapter on Glassfish application
> server 3.1. The problem is the resource adapter doesn't perform any
> connection sharing (no associateConnection method call). Thanks
>
> --
>
> [Message sent by forum member 'sam_sepassi']
>
> View Post: http://forums.java.net/node/701392
>
>