Class AsyncResponseTransaction

java.lang.Object
org.keycloak.transaction.AsyncResponseTransaction
All Implemented Interfaces:
org.keycloak.models.KeycloakTransaction

public class AsyncResponseTransaction extends Object implements org.keycloak.models.KeycloakTransaction
When using AsyncResponse.resume(Object) directly in the code, the response is returned before all changes done withing this execution are committed. Therefore we need some mechanism that resumes the AsyncResponse after all changes are successfully committed. This can be achieved by enlisting an instance of AsyncResponseTransaction into the main transaction using KeycloakTransactionManager.enlistAfterCompletion(KeycloakTransaction).
  • Method Details

    • finishAsyncResponseInTransaction

      public static void finishAsyncResponseInTransaction(org.keycloak.models.KeycloakSession session, jakarta.ws.rs.container.AsyncResponse responseToFinishInTransaction, jakarta.ws.rs.core.Response responseToSend)
      This method creates a new AsyncResponseTransaction instance that resumes provided AsyncResponse responseToFinishInTransaction with given Response responseToSend. The transaction is enlisted to KeycloakTransactionManager.
      Parameters:
      session - Current KeycloakSession
      responseToFinishInTransaction - AsyncResponse to be resumed on KeycloakTransactionManager commit/rollback.
      responseToSend - Response to be sent
    • begin

      public void begin()
      Specified by:
      begin in interface org.keycloak.models.KeycloakTransaction
    • commit

      public void commit()
      Specified by:
      commit in interface org.keycloak.models.KeycloakTransaction
    • rollback

      public void rollback()
      Specified by:
      rollback in interface org.keycloak.models.KeycloakTransaction
    • setRollbackOnly

      public void setRollbackOnly()
      Specified by:
      setRollbackOnly in interface org.keycloak.models.KeycloakTransaction
    • getRollbackOnly

      public boolean getRollbackOnly()
      Specified by:
      getRollbackOnly in interface org.keycloak.models.KeycloakTransaction
    • isActive

      public boolean isActive()
      Specified by:
      isActive in interface org.keycloak.models.KeycloakTransaction