Home Help Center

TimeoutException:

JiangyubaoJiangyubao Member Yubao JiangOrganization: www.gliet.edu.cnProject: integrate OSGi & Ice to provice service for PHP ✭✭
Hi, all.

We deploy our Java application to ice grid node, and use PHP as ice client to call on proxy object's method to perform a transaction, for example, submit an order.

At PHP client site, we set the ice_timeout to 20000 ms, when Java proforms a long_time transaction or the database is locked by another process(we use SELECT FOR UPDATE statement to acquire to lock on a record), and the TimeoutException may be throwed, client user can see the transaction fail message.

But at server side, the Java program will continue to perform the transaction and submit it to database at last.

Will anybody know how to resolve this problem?

It seems that C/S program(for example, PHP as Client and Java as Server) can not avoid this problem. But B/S program can avoid it, when a transaction timeout(or wait for lock timeout at mysql), client user can see error message, and nothing is submited to database.

Comments

  • michimichi Member Michi HenningOrganization: Triodia TechnologiesProject: I have a passing interest in Ice :-) ✭✭✭
    If I understand you correctly, you are setting a timeout on the client side, so if an invocation takes too long, it fails with a TimeoutException, but there is no corresponding timeout in the server?

    As far as I can see, your problem is caused by setting the timeout on the client side only, so the user ends up with error information that doesn't correspond with reality.

    The thing to do would be to set a timeout on the server side and, if the transaction on the server side times out, throw a TransactionTimeoutException or some such that is propagated back to the client.

    Cheers,

    Michi.
  • JiangyubaoJiangyubao Member Yubao JiangOrganization: www.gliet.edu.cnProject: integrate OSGi & Ice to provice service for PHP ✭✭
    Yes, you are right.

    I only set timeout at client site.

    How to set ice timeout at server side? When ice timeout at server side? And when timeout occurs, will the transaction roll back?
  • michimichi Member Michi HenningOrganization: Triodia TechnologiesProject: I have a passing interest in Ice :-) ✭✭✭
    There is no such thing as a timeout on the server side. After all, it is your application thread that is in control, and it will take however long it takes.

    What you should do is either find a way to have the server's transaction with the database time out if it takes too long or, failing that, not set a timeout for the client.

    As is, things cannot possibly work because the timeout on the client side tells the client a story that is not true.

    Cheers,

    Michi.
  • JiangyubaoJiangyubao Member Yubao JiangOrganization: www.gliet.edu.cnProject: integrate OSGi & Ice to provice service for PHP ✭✭
    Thanks for your reply.
    Now I know how to resolve such problem:
    long start = System.currentTimeMillis();
    //perform a transaction
    long end = System.currentTimeMillis();
    if (end - start > transactionTimeLimit) {
    	throw new RuntimeException("throw a runtime exception for SpringFramework to roll back this transaction");
    }
    
Sign In or Register to comment.