Coming soon ChenAIle — agentic microservices: agents, AI tool calls, machine learning and a metrics-driven rules engine Learn more →
How it works · Proxies

One call, near or far

Service order-service depends on service inventory-service through its interface. A Chenile proxy decides at runtime whether inventory-service lives in the same mini monolith or in another one, carries the caller's headers across, runs the right interceptors, and hands back a result or an exception that looks the same either way.

A Chenile proxy call from order-service to inventory-service, local or remote order-service in mini monolith A calls inventory-service through a Chenile proxy. The proxy looks inventory-service up in the service registry, a separate deployable, and ProxyTypeRouter compares inventory-service's monolith name with A's. If they match, LocalProxyInvoker builds a new exchange and runs inventory-service's chenile-highway (the far interceptors) inside A, skipping the near interceptors. Otherwise the proxy chain runs the near interceptors, HttpInvoker sends an HTTP request to mini monolith B, inventory-service's HttpEntryPoint and highway run there, and the GenericResponse is deserialized; an error response becomes an ErrorNumException in order-service, the same exception a local call would throw. Mini monolith A · orders-app Client chenile-highwayorder-service order-service inventory-serviceproxy samemonolith? yes · local no · remote LocalProxyInvoker chenile-highwayfar interceptors inventoryservice · local near interceptors skipped no network · same exception object proxy chain near interceptors exception handler op client intcp. svc client intcp. response type HttpInvoker Mini monolith B · inventory-app inventory-serviceremote chenile-highway far interceptors headers pre-proc transform svc-ref post-proc invoke HttpEntryPointHTTP route HTTP request GenericResponse Service registry separate deployable near cache in each client serviceId: inventory-service · version 1.0 monolithName: inventory-app baseUrl: http://inventory:8080 reserve → POST /inventory/{sku}/reserve clientInterceptorNames: [retryInterceptor] lookup first call registers at startup
inventory-service lives in
inventory-service
view
Step 1
Client calls order-service

Headers

Payload and parameters

Reading the picture

What happens on the way

1 · The registry says where inventory-service lives

Every deployable publishes its services to the service registry, a separate deployable, when it starts: the service id and version, the monolithName, the baseUrl, every operation's URL, HTTP method and parameters, and the client interceptors callers should run. On its first call the proxy fetches inventory-service's entry and keeps it in a near cache.

2 · The router picks local or remote

ProxyTypeRouter compares inventory-service's monolithName with this deployable's chenile.monolith.name. The same name means local; a different one means remote. Moving inventory-service to another mini monolith changes the answer without changing order-service.

3 · Near interceptors run on the caller's side

For a remote call the proxy runs its own chain in order-service's deployable: an exception handler, the operation and service client interceptors named in inventory-service's registry entry, a response type selector and HttpInvoker. A local call skips them: there is no network call to retry, time or translate.

4 · Far interceptors always run

inventory-service's own chenile-highway runs on every call. Locally, LocalProxyInvoker calls ChenileEntryPoint in process. Remotely, inventory-service's HttpEntryPoint in the other mini monolith runs it. Either way inventory-service's policies apply.

Headers and payload

What crosses from the near side to the far side

The proxy is built with a HeaderCopier. The usual one, PopulateContextContainer, copies every x- header from order-service's ContextContainer, which order-service's own highway filled from the incoming request.

Always carried

Every x- header in order-service's context: tenant (x-chenile-tenant-id), user, trajectory, x-request-id, x-Authorization and the rest. So inventory-service runs for the same tenant, user and trajectory as order-service.

Parameters

The method's arguments are bound by inventory-service's parameter definitions: HEADER parameters become headers (and fill path variables in the URL), the BODY parameter becomes the body. Locally the body object is passed as is; remotely it is sent as JSON and typed again in inventory-service's highway.

Added for remote calls

x-chenile-entry-point-sub-type: REMOTE_PROXY, Authorization copied from x-Authorization, and JSON content headers. The URL is the registry's baseUrl plus the operation's URL.

Results and errors

order-service cannot tell near from far

Results

Locally the proxy returns the data from inventory-service's GenericResponse. Remotely the response body is read as GenericResponse<T>, using the operation's output type from the registry, and the proxy returns its payload. order-service gets the same object type either way.

Errors

Locally inventory-service's exception reaches order-service unchanged. Remotely ChenileResponseHandler reads the error body and throws an ErrorNumException with the same code, sub-error code and description. A connection failure becomes a ServerException (cannot connect or cannot invoke). Catch ErrorNumException and branch on its codes, and the same handler works for both.

Registry and proxies, the concept →   Every transport adapter →