Skip to content

Latest commit

 

History

History
62 lines (39 loc) · 1.55 KB

servlet_usage.md

File metadata and controls

62 lines (39 loc) · 1.55 KB

RequestLog Servlet Configuration

Unlike other components that handle external requests in this project, Servlet acts as the service provider.

Common Configuration (Logging, Persistence, Retry, etc.)

Maven Dependency

<dependency>
    <groupId>io.github.requestlog</groupId>
    <artifactId>request-log-servlet-starter</artifactId>
    <version>${latest_stable_version}</version>
</dependency>

Enhance Controller

Use @ReqLog to decorate the endpoint.

import io.github.requestlog.servlet.annotation.ReqLog;

@RestController
public class SomeController {
    
    @ReqLog(whenException = {Exception.class, IOException.class},
            retry = true, retryInterval = 10, retryWaitStrategy = RetryWaitStrategy.FIXED, 
            maxExecuteCount = 10)
    @GetMapping("/some-path")
    public String get() {
        return "some result";
    }
    
}
  • whenException:Specifies which Exception to record.
  • retry:Enable retry.
  • retryInterval:Retry interval.
  • retryWaitStrategy:Retry interval calculation strategy.
  • maxExecuteCount:Maximum expected execution count after enabling retry (including the first execution).

To temporarily disable the functionality, configure request-log.servlet.disable=true


Retry

If rewriting request information is involved during retry, refer to Common Usage - Retry