All Products
Search
Document Center

Microservices Engine:Add custom interfaces to Microservices Governance

Last Updated:Mar 11, 2026

Microservices Engine (MSE) automatically detects framework-level interfaces such as Spring MVC endpoints and Dubbo services. For business logic that falls outside these frameworks -- batch jobs, scheduled tasks, or internal validation routines -- you can register custom interfaces using the Sentinel SDK. Once registered, these interfaces appear in the MSE console and support throttling, circuit breaking, and isolation rules.

Governance for a custom interface requires two independent steps:

  1. Instrument your code -- wrap the target code block with the Sentinel API to register it as a resource.

  2. Configure rules in the MSE console -- apply throttling, circuit breaking, or isolation rules to the resource.

This topic covers step 1. After the instrumentation is in place, the custom interface appears in the MSE console whenever it receives traffic. You can then configure governance rules from the console.

Prerequisites

Before you begin, ensure that you have:

  • An application with Microservices Governance enabled

  • MSE Java agent version 3.2.9 or later

Note

For agent version details, see Release notes for the Java agent. To pin a specific version, see Specify the agent version.

Visibility requires traffic

Only custom interfaces that receive traffic appear in Microservices Governance due to the limitations of programming patterns. If the instrumented code block has not been invoked, it will not show up in the console.

Add the SDK dependency

Add the Sentinel core library to your pom.xml:

<dependency>
  <groupId>com.alibaba.csp</groupId>
  <artifactId>sentinel-core</artifactId>
  <version>1.8.7</version>
</dependency>

Wrap your business logic

Use SphU.entry() in a try-with-resources block to register a code section as a Sentinel resource. The resource name identifies this interface in the MSE console.

import com.alibaba.csp.sentinel.Entry;
import com.alibaba.csp.sentinel.SphU;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.alibaba.csp.sentinel.EntryType;

// "HelloWorld" is the resource name displayed on the monitoring page and in the interface list in the MSE console.
// EntryType.IN marks it as an ingress resource for inbound traffic.
try (Entry entry = SphU.entry("HelloWorld", EntryType.IN)) {
    // Protected business logic
    System.out.println("Hello MSE Sentinel!");
} catch (BlockException e) {
    // Throttling or circuit breaking triggered.
    // Handle with a fallback response or log the event.
}

The try-with-resources pattern automatically releases the entry on exit. This prevents resource leaks that can occur when you call entry.exit() manually in a finally block.

Parameter reference

ParameterDescription
resourceNameIdentifier displayed on the monitoring page and in the interface list. Maximum 1,024 characters. Recommended characters: hyphens (-), underscores (_), periods (.), and colons (:)
EntryType.INInbound traffic. Marks the resource as an ingress resource. System rules apply only to ingress resources. The MSE console counts only EntryType.IN traffic toward an application's total traffic
EntryType.OUTOutbound traffic

Verify the result

  1. Log on to the MSE console.

  2. In the left-side navigation pane, choose Microservices Governance > Application Governance.

  3. On the Application list page, confirm that the resource card of your application appears and reports data.

    image.png

  4. Generate traffic on the custom interface, then open the interface details page and select the Custom Interface tab to confirm the interface is listed.

What's next

Apply governance rules to the custom interface: