Skip to content

io microsphere alibaba sentinel common SentinelContext

github-actions[bot] edited this page May 24, 2026 · 1 revision

SentinelContext

Type: Class | Module: microsphere-alibaba-sentinel-commons | Package: io.microsphere.alibaba.sentinel.common | Since: 1.0.0

Source: microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/common/SentinelContext.java

Overview

The context of Sentinel

Declaration

public class SentinelContext

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.2.0-SNAPSHOT

Version Compatibility

This component is tested and compatible with the following Java versions:

Java Version Status
Java 17 ✅ Compatible
Java 21 ✅ Compatible
Java 25 ✅ Compatible

Usage

Maven Dependency

Add the following dependency to your pom.xml:

<dependency>
    <groupId>io.github.microsphere-projects</groupId>
    <artifactId>microsphere-alibaba-sentinel-commons</artifactId>
    <version>${microsphere-alibaba-sentinel.version}</version>
</dependency>

Tip: Use the BOM (microsphere-alibaba-sentinel-dependencies) for consistent version management. See the Getting Started guide.

Import

import io.microsphere.alibaba.sentinel.common.SentinelContext;

API Reference

Public Methods

Method Description
getResourceName The execution result, if null, it means the execution does not return any value.
getContextName Get the context name
getOrigin Get the origin
getEntry Get the entry
setResult Set the result of the execution.
getResult Set the result of the execution.
setFailure Set the failure of the execution.
getFailure Set the failure of the execution.
setAttribute Set the attribute name and value.
hasAttribute Check whether the attribute exists by name.
getAttribute Get the attribute value by name.
getAttribute Get the attribute value by name.
removeAttribute Remove the attribute by name.
removeAttributes Remove all attributes.
withinContext Get the attributes.
getContext Get the current SentinelContext
setContext Set the current SentinelContext
removeContext Remove and return the current SentinelContext
doInContext Do something in the current SentinelContext
doInContext Do something in the current SentinelContext

Method Details

getResourceName

public String getResourceName()

The execution result, if null, it means the execution does not return any value. /

removeContext

public static SentinelContext removeContext()

Remove and return the current SentinelContext

doInContext

public static void doInContext(@Nonnull Consumer<SentinelContext> contextConsumer)

Do something in the current SentinelContext

doInContext

public static void doInContext(@Nonnull Consumer<SentinelContext> contextConsumer, boolean forRemoval)

Do something in the current SentinelContext


This documentation was auto-generated from the source code of microsphere-alibaba-sentinel.

Clone this wiki locally