Search Results for

Show / Hide Table of Contents

# Interface IServiceCallContext

Represents service call context.

This context is implicitly passed to the service and can be retrieved inside the service using CurrentCallContext. It is accessible only from the local thread during the execution of a service method.

Use ServiceCallContextBuilder to instantiate the context.

Note: passing the context to the service may lead to performance overhead, so it should only be used for "middleware" tasks.

Usage example:

    // Service implementation.
    public class HelloServiceImpl : HelloService
    {
        private IServiceContext ctx;

        public void Init(IServiceContext ctx)
        {
            this.ctx = ctx;
        }

        public string Call(string msg)
        {
            return msg + ctx.CurrentCallContext.Attribute("user");
        }
        ...
    }
    ...

    // Call this service with context.
    IServiceCallContext callCtx = new ServiceCallContextBuilder().Set("user", "John").build();
    HelloService helloSvc = ignite.GetServices().GetServiceProxy<HelloService>("hello-service", false, callCtx);
    // Print "Hello John".
    Console.WriteLine( helloSvc.call("Hello ") );

###### Namespace: Apache.Ignite.Core.Services

###### Assembly: Apache.Ignite.Core.dll

##### Syntax

    public interface IServiceCallContext

### Methods

#### GetAttribute(String)

Gets the string attribute.

##### Declaration

    string GetAttribute(string name)

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | name | Attribute name.

##### Returns

Type | Description
--- | ---
System.String | String attribute value.

#### GetBinaryAttribute(String)

Gets the binary attribute.

##### Declaration

    byte[] GetBinaryAttribute(string name)

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | name | Attribute name.

##### Returns

Type | Description
--- | ---
System.Byte[] | Binary attribute value.