Package org.keycloak.transaction
Class AsyncResponseTransaction
java.lang.Object
org.keycloak.transaction.AsyncResponseTransaction
- All Implemented Interfaces:
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 Summary
Modifier and TypeMethodDescriptionvoidbegin()voidcommit()static voidfinishAsyncResponseInTransaction(KeycloakSession session, jakarta.ws.rs.container.AsyncResponse responseToFinishInTransaction, jakarta.ws.rs.core.Response responseToSend) This method creates a new AsyncResponseTransaction instance that resumes provided AsyncResponseresponseToFinishInTransactionwith given ResponseresponseToSend.booleanbooleanisActive()voidrollback()void
-
Method Details
-
finishAsyncResponseInTransaction
public static void finishAsyncResponseInTransaction(KeycloakSession session, jakarta.ws.rs.container.AsyncResponse responseToFinishInTransaction, jakarta.ws.rs.core.Response responseToSend) This method creates a new AsyncResponseTransaction instance that resumes provided AsyncResponseresponseToFinishInTransactionwith given ResponseresponseToSend. The transaction is enlisted toKeycloakTransactionManager.- Parameters:
session- Current KeycloakSessionresponseToFinishInTransaction- AsyncResponse to be resumed onKeycloakTransactionManagercommit/rollback.responseToSend- Response to be sent
-
begin
public void begin()- Specified by:
beginin interfaceKeycloakTransaction
-
commit
public void commit()- Specified by:
commitin interfaceKeycloakTransaction
-
rollback
public void rollback()- Specified by:
rollbackin interfaceKeycloakTransaction
-
setRollbackOnly
public void setRollbackOnly()- Specified by:
setRollbackOnlyin interfaceKeycloakTransaction
-
getRollbackOnly
public boolean getRollbackOnly()- Specified by:
getRollbackOnlyin interfaceKeycloakTransaction
-
isActive
public boolean isActive()- Specified by:
isActivein interfaceKeycloakTransaction
-