Interface DataConn
public interface DataConn
The interface that abstracts a connection per session to an external data service, such as a
database, file system, or messaging service.
Its primary purpose is to enable cohesive transaction operations across multiple external data services within a single transaction context. Implementations of this interface provide the concrete input/output operations for their respective data services.
Methods declared within this interface are designed to handle transactional logic. The AsyncGroup parameter in various methods allows for asynchronous processing when commit or rollback operations are time-consuming.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the connection to the external data service, releasing any associated resources.void
commit
(AsyncGroup ag) Commits the changes made within the current session to the external data service.default void
forceBack
(AsyncGroup ag) Performs a force-back operation to revert the committed changes when this connection had been already committed but the other connection had failed.default void
postCommit
(AsyncGroup ag) Performs any necessary post-commit operations.default void
preCommit
(AsyncGroup ag) Performs any necessary pre-commit operations.void
rollback
(AsyncGroup ag) Rolls back the changes made within the current session, discarding all operations performed since the last commit or rollback.default boolean
Indicates whether a force-back operation should be performed.
-
Method Details
-
commit
Commits the changes made within the current session to the external data service. This method is responsible for finalizing all operations performed since the last commit or rollback.- Parameters:
ag
- AnAsyncGroup
that can be used to perform asynchronous operations if the commit process is time-consuming.- Throws:
com.github.sttk.errs.Exc
- if an error occurs during the commit operation.
-
preCommit
Performs any necessary pre-commit operations. This method is called before thecommit(AsyncGroup)
method.- Parameters:
ag
- AnAsyncGroup
that can be used for asynchronous pre-commit tasks.- Throws:
com.github.sttk.errs.Exc
- if an error occurs during the pre-commit operation.
-
postCommit
Performs any necessary post-commit operations. This method is called after thecommit(AsyncGroup)
method has successfully completed.- Parameters:
ag
- AnAsyncGroup
that can be used for asynchronous post-commit tasks.
-
shouldForceBack
default boolean shouldForceBack()Indicates whether a force-back operation should be performed. A force-back is a mechanism to revert the committed changes when this connection had been already committed but the other connection had failed.- Returns:
true
if a force-back is required,false
otherwise.
-
rollback
Rolls back the changes made within the current session, discarding all operations performed since the last commit or rollback.- Parameters:
ag
- AnAsyncGroup
that can be used to perform asynchronous operations if the rollback process is time-consuming.
-
forceBack
Performs a force-back operation to revert the committed changes when this connection had been already committed but the other connection had failed.- Parameters:
ag
- AnAsyncGroup
that can be used for asynchronous force-back tasks.
-
close
void close()Closes the connection to the external data service, releasing any associated resources. This method should be called to ensure proper resource management.
-