Re: Fwd: Postgres JDBC, WS and commit

Поиск
Список
Период
Сортировка
От Radosław Smogura
Тема Re: Fwd: Postgres JDBC, WS and commit
Дата
Msg-id 8f62136f2ac19fb44383745705190955@mail.softperience.eu
обсуждение исходный текст
Ответ на Re: Fwd: Postgres JDBC, WS and commit  (mephysto <mephystoonhell@gmail.com>)
Список pgsql-jdbc
On Wed, 9 May 2012 12:11:19 -0700 (PDT), mephysto wrote:
> Hi Kevin,
> I will try to explain my scenario: with my application, many users
> exchange
> message within them. User1 send message to user2 by a web service.
> This web
> service send message and wait the response from user 2 before end and
> send
> notice to user1. I can't know how many time is needed for response,
> so, I
> would to save te state in a table on database to prevent accidental
> disconnection of client from web service.
>
> But I found that, if transaction are not closed until web service
> operation
> end, my table are not update, and I can't know the wait state of
> user1 and I
> can't take back he to his request.
> Moreover, if transaction lock my table, and other user, user3, send a
> message to user4, I can't save his state until user1 operation end.
>
> Is it clear enough?
>
> Is there any wrong in my reasoning? Is there anything I ignore in
> pool
> functionality?
>
> Thanks in advance.
>
> Mephysto
>
> --
> View this message in context:
>
> http://postgresql.1045698.n5.nabble.com/Postgres-JDBC-WS-and-commit-tp5697657p5698263.html
> Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.

Hello,

In Java there are two main ways for Webservices EJB+WS or HTTP+WS
(JAX-WS, etc). I assume you use EJB+WS, if not give more details. You
should not manipulate connections pools and transactions manually
because you will break something.

According to your scenario I guess you use container managed
transactions in EJB+WS. In this scenario transaction will not be
committed until method ends, so locks etc, will be preserved, as well
others will not see Users 1 changes till commit. You should rewrite (a
little bit) your code, use @TransactionManagement(BEAN), and
EJBContext.getUserTransactions() or manipulate with
@TransactionManagement(CONTAINER) (this is default) and
@TransactionAttribute(REQUIRES_NEW) /your state saving method should be
in REQUIRES_NEW/ - here I'm not quite sure if in EJB3 to call bean
method form same bean you need self-inject same bean, or just normal
Java call is enough.

Please bear in mind, that long running connections (as well JDBC, HTTP,
IIOP) and transactions may be treated as damaged and closed by server.

Regards,
Radosław Smogura

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Dave Cramer
Дата:
Сообщение: Re: Fwd: Postgres JDBC, WS and commit
Следующее
От: Mephysto
Дата:
Сообщение: Re: Fwd: Postgres JDBC, WS and commit