Hi maciej,

comments inline.

On 9/5/07, Maciej Szefler <[EMAIL PROTECTED]> wrote:
>
> Hi Rajith,
>
> See my  commments inline.
>
> On 9/4/07, Rajith Attapattu < [EMAIL PROTECTED]> wrote:
> >
> >
> >
> > Sorry if I was not clear enough. When I said session per service, I
> > meant session per service instance (where it make sense). So no need to
> > serialize access.
> > Ex. If you have a service with scope='soap-session' and there are two
> > clients talking to it, then you would have two instances of the service and
> > would be using two JMS sessions (or two XA sessions). So each web service
> > instance can run transactions independently of the other.
> >
> Ok,  I think we are on same page.
>
>
> > In the use case where services with scope='request' sharing sessions
> > underneath, a given JMS session will only be used by one and only one
> > service instance at a given time. (This will be tricky to implement, and
> > only be worth if there is a high traffic scenario).
> >
> > Going direct, we still have a problem with receving messages. As far I
> > > know, it is not possible to do a JTA receive using the async 
> > > MessageListener
> > > interface. One would need to either poll, or  use the MessageConsumer
> > > interfaces.
> >
> >
> > Async or sync message receive is orthogonal to the transactions. Can you
> > elaborate a bit more
> >
>
> Sure... When receiving messages when not using JTA, you can simply set up
> a MessageListener via the MessageConsumer (as is the current practice in
> AXIS). In the JTA case there is the compilication that the JTA transaction
> needs to be started before the message is consumed. So you can do something
> like this (ugly):
>
> jta.begin();
> session.receive(timeout);
> if (timeout)
>    jta.rollback();
> else
>   do some stuff...
>   jta.commit();
>

I get what you mean. You need your service invocation (jms message
consumption) as part of a transaction.
How about if we call xaSession.getXAResource().start() as soon as we create
the session? then every message it consumes and sends will be within that
transaction until it commits or rolls it back.

However transactions will have an impact on the client who does the
invocation. If rollback happens. Any messages u consume will be enqueued
again by the provider. What are we going to do with that message?
Also how are we going to notify the client? In that case are we supposed to
send the client a seperate axis2 fault?

Actually there a few things to consider and I am not sure I have figured out
all those complications.
Maybe we should rethink about implementing transactions in the JMS transport
for axis2 as it will complicate the interactions.

Actually can you explain your use case a bit more? Can you not use
WS-Transactions? Perhaps there is a simple way to solve your problem

Regards,

Rajith

Alternatively you can use the ConnectionConsumer / ServerSessionPool
> interfaces which allow one to start a JTA tx before the message is actually
> consumed. This is a bit complicated, and also is an "optional" feature.
>
> Or you can use MessageConsumer and try to enroll the XASession in the
> transaction from the MessageListener.onMessage method. I do not believe
> this to be entirely legal as far as the spec is concerned, but I hear it
> works on some JMS providers.
>
>
>  In either case there is the issue of who begins and commits the JTA
> > > transaction (AXIS2 or the service), and if its the service, it is not 
> > > clear
> > > how that interaction would look.
> > >
> > I'm more inclined toward an  MDB-like model, where AXIS starts the TX,
> > > calls the service, and then barring some indication to the contrary,
> > > attempts to commit.
> >
> >
> > IMO Axis2 should not commit or rollback automatically. Commits or
> > rollbacks can happen based on business decisions as well as system errors.
> > And in the case of a distributed transaction the decision to commit or
> > rollback will come from the distributed transaction manager.
> >
>
> I agree in principle, but to do that, what you'd really need is to
> decouple the notification that a message is available, from the act of
> consuming the message.Something along these lines:
> MyAxisService.onMessageReceived () {
>     jta.begin();
>     MessageContext ctx = consumeMessage() // message is consumed in the
> JTA TX
>     this.doServiceWork();
>     jta.commit ();
> }
>
> Getting something like that may be difficult (per my previous comments
> regarding JTA / session enrollment).
>
> -maciej
>
>  If there are any system(axis2) hiccups then axis2 will/should always
> > throw a fault and the service author will be notified instead of axis2 doing
> > rollback.
> > In the case of a local transaction the service author may rollback and
> > in a distributed transaction the XA resource (XA Session) will throw an
> > exception in the prepare method and the the transaction manager will call
> > rollback.
> >
> > -mbs
> > >
> > > On 9/4/07, Rajith Attapattu <[EMAIL PROTECTED]> wrote:
> > > >
> > > > Maciej,
> > > >
> > > > Currently there are a few problems with doing this. Lets identify
> > > > the issues
> > > > a) We create a new connection for each invocation (sending messages)
> > > > b) Hence we create a new session for each invocation.
> > > > c) When creating a session for receiving as well as sending
> > > > transacted is set to true - no way to configure this.
> > > > d) We currently don't expose the session outside for both transport
> > > > sender/receiver, hence you cannot call commit or rollback on it.
> > > > e) Since u are using JTA I assume it's a distributed transaction. So
> > > > we need to create an XASession instead of a normal session.
> > > >
> > > > This can be done and here are some ideas. I spoke with Asankha
> > > > briefly on this topic once.
> > > >
> > > > a) Asankha pointed out a new connection is created for each
> > > > invocation as each service could have different connection params.
> > > > (different provider, username,..etc)
> > > > The downside of this is that creating new connections is an
> > > > expensive operation. Especially if the same service sends frequent 
> > > > messages
> > > > it will keep recreating connections. We should make this behaviour
> > > > configurable.
> > > > I would like if we could reuse connections where we can. Also in
> > > > most cases a deployment would use a single provider and we can 
> > > > definitely
> > > > optimize for this case.
> > > > For this case we can get away with a single connection per axis2
> > > > instance and session per service (one for sending and one for 
> > > > listening).
> > > >
> > > > If we can name connections then we could reuse them when defining
> > > > services. This way we can check if an existing connection by that name
> > > > exists and reuse it, if not create one.
> > > >
> > > > When we reuse connections there will be keep alive issues. Most
> > > > providers have convenient and cheap ways of sending ping/pongs to keep 
> > > > the
> > > > connection alive.
> > > > So in a case where the service sends messages frequently this will
> > > > help. If the service sends messages rarely and the cost of keep alive is
> > > > greater than the occasional connection creation then the user can 
> > > > disable
> > > > the reuse option.
> > > >
> > > > b) Creating a new session for each invocation is not optimal. Since
> > > > the context hierarchy determines the scope of services and is 
> > > > independent of
> > > > the transport session it's ok to reuse a JMS session underneath where 
> > > > ever
> > > > it makes sense. If we introduce some thing similar to
> > > > scope="transport-session" in HTTP for JMS, then we can allow users to
> > > > directly use the underlying JMS transport similar to the way HTTP 
> > > > session is
> > > > used.
> > > >
> > > > c) We can make the transacted property configurable. By default it
> > > > will be false.
> > > > <http://?auth=DQAAAHcAAABRNsIxA9tiVL3uczzey-x8FmU4gCUONPWKQAnlvhxhlFsCgDWBe2vo5cADP4RK1n0C-wf599ttpb3KuVGEQ1juQ4qqo7J7q47y0qAH12dW5DBAfbWjNSE-kzSN7uva1VddYFgwsvDPJHEKd2xLegIlVRPoMUsCpGd8rccaRUkjtg&shva=1>
> > > > Ex: <parameter name="transport.jms.SessionTransacted
> > > > ">true</parameter>
> > > >
> > > > d) We need to expose the JMS session. Can we put the JMS session
> > > > somewhere in the context hierarchy?
> > > > I also see a getSessionContext in TransportListener interface,
> > > > However SessionContext is written with HTTP in mind and is not generic
> > > > enough.
> > > > If we put it in the content hierarchy then the service author can
> > > > retrieve it and call commit, rollback etc.
> > > >
> > > > e) We can create an XASession  instead of a normal session based on
> > > > configuration, provided the JMS provider supports it.
> > > > Ex. <parameter name="transport.jms.XASession">true</parameter>
> > > >
> > > > Comments are very much appreciated.
> > > >
> > > > Regards,
> > > >
> > > > Rajith
> > > >
> > > > On 9/4/07, Maciej Szefler <[EMAIL PROTECTED]> wrote:
> > > > >
> > > > > Hi,
> > > > >
> > > > > I've been unable to find anything on the topic in Nabble, so I
> > > > > thought I'd ping you all, and Asankha in particular regarding 
> > > > > transactions
> > > > > in the JMS transport implementation.
> > > > > In ODE we'd like to be able to consume/send messages through AXIS'
> > > > > JMS transport. That in itself is not a problem. However, we'd like the
> > > > > send/receive to be in enrolled in a JTA transaction. Any pointers on 
> > > > > how
> > > > > this can be done?
> > > > >
> > > > > -Maciej
> > > > >
> > > >
> > > >
> > >
> >
>

Reply via email to