Skip to content

Retry example for Spring #3238

@robert-s-lee

Description

@robert-s-lee

Title

Spring txn retry example

Description

https://stackoverflow.com/questions/49339135/org-hibernate-transactionexception-in-simple-crud-app-with-cockroachdb

Outline

Copying and pasting from the stackoverflow. @bdarnell Would this work and if so add more description or suggest as best practice?

Solved it by adding org.springframework.retry as a dependency (org.springframework.retry:spring-retry:1.2.2.RELEASE), importing the needed annitations

import org.springframework.retry.annotation.EnableRetry
import org.springframework.retry.annotation.Retryable
and replacing

@SpringBootApplication
with

@SpringBootApplication
@EnableRetry
and

@PutMapping("/thing/")
with

@PutMapping("/thing/")
@Retryable

Expected Audience

Developers

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions