Discussions

EJB programming & troubleshooting: Interruping/Aborting a remote EJB method call

  1. Interruping/Aborting a remote EJB method call (5 messages)

    Is it possible to interrupt a remote EJB method call in a Java Client or a servlet by e.g interrupting the context thread?

    If yes whats the excepcted behavior of a the EJB mehtod? Will it complete the transaction or will it rollback the transaction?

    Thx
    Toby
  2. There is no standard way to interupt EJB operations from a client. The EJB server does not allow you control over EJB threads. If you want interruptable remote operations, I suggest you use a messaging architecture rather than EJBs. Messaging works better for long run operations anyway.
  3. There is no standard way to interupt EJB operations from a client. The EJB server does not allow you control over EJB threads. If you want interruptable remote operations, I suggest you use a messaging architecture rather than EJBs. Messaging works better for long run operations anyway.


    How can I contact someone of the mysterious ;-) bean writers or the JCP team to suggest to integrate it into the upcomming spec releases (I guess for 2.1 its to late :( ).

    JMS or maybe some JINI/JavaSpace stuff is fine, but it seems to be harder to create a request-response style processing build on top on JMS. :-)
  4. EJBs are designed to be synchronous operations. In other words, the client blocks until the EJB operation is complete. Since the client can't perform any work until the EJB method returns, there is no straightforward way for the client to interrupt the EJB. In light of that fact it is extremely unlikely that the EJB specification will ever support operation interruption.

    If you want to have long running operations that can be interrupted, an asynchronous, message-based system is a much better way to go. Building request/response operation in JMS is not, in fact, particular hard (using reply-to queues), and it will be a much better solution than EJB for interruptable remote operations.
  5. EJBs are designed to be synchronous operations. In other words, the client blocks until the EJB operation is complete. Since the client can't perform any work until the EJB method returns, there is no straightforward way for the client to interrupt the EJB. In light of that fact it is extremely unlikely that the EJB specification will ever support operation interruption.

    >
    > If you want to have long running operations that can be interrupted, an asynchronous, message-based system is a much better way to go. Building request/response operation in JMS is not, in fact, particular hard (using reply-to queues), and it will be a much better solution than EJB for interruptable remote operations.

    Okay then we have a a possible solution for this. Another related question: What happens if the user kills, close or crash? The current EJB method is still active on server, isn't it? As far as I know the bean spec does not talks about this????
  6. If client dies while an EJB method calls is being executed, the EJB method should still complete. EJB methods will only terminate abnormally for server-side errors. Most of the time, this is a good thing.

    This is typically behavior for client/server applications. Servlets behave the same way, as do JMS applications, web services, etc ...