...
The data got inserted into user table and got updated as above batch execution
...
.
The WriteTimeoutException.getWriteType() == BATCH, ensures data is inserted into the table
Approach
To handle above WriteTimeoutException
we can use BatchStatement.Type
Code Block |
---|
BatchStatement batchStatement = new BatchStatement(BatchStatement.Type.UNLOGGEDLOGGED); |
Below are the two batch types we executed for partial writes
LOGGED
UNLOGGED
...
In cassandra doc it specifies that to increase the performance UNLOGGED type should be used.
...
With LOGGED type the data got inserted and updated after WriteTimeoutException
.
...
Batch type of LOGGED, guarantees atomic insertion of data, and WriteTimeoutException.getWriteType() == BATCH, eventually written to the appropriate replicas and the developer doesn't have to do anything.
Thus, the above two checks handles partial write.