question

Upvotes
Accepted
3 4 5 10

EMA endpoint discovery best practices

I have some questions about the discovery process for EMA connections. What we are currently using is just lifted from some sample code from about 2 years ago and looks like

class EndpointDiscoveryClient implements ServiceEndpointDiscoveryClient {
    public void onSuccess(ServiceEndpointDiscoveryResp resp, ServiceEndpointDiscoveryEvent event) {
        List<ServiceEndpointDiscoveryInfo> serviceEndpointDiscoveryInfos = resp.serviceEndpointInfoList();
        for (ServiceEndpointDiscoveryInfo info : serviceEndpointDiscoveryInfos) {
            List<String> locationList = info.locationList();
            if (locationList.size() == 2 && locationList.get(0).startsWith(location)) {
                host = info.endpoint();
                port = info.port();
                break;
            }
        }
    }
}

Why test for size == 2 instead of size >= 2 ? Will there ever be more than 2 (or just 1)?

Why only use the first one? Are there cases we would fail over to a different host, and if so how do we detect those cases?

We're currently using com.refinitiv.ema:ema:3.7.1.0

ema-api#productjava
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvote
Accepted
80.1k 257 52 75

@daniel.lipofsky

Thank you for reaching out to us.

Please refer to the Service Discovery example on GitHub.

        for(ServiceEndpointDiscoveryInfo info : serviceEndpointResp.serviceEndpointInfoList())
        {
            if(info.locationList().size() >= 2 && info.locationList().get(0).startsWith(Consumer.location)) // Get an endpoint that provides auto failover for the specified location.
            {
                endPoint = info.endpoint();
                port = info.port();
                break;
            }
            // Try to get backups and keep looking for main case. Keep only the first item met.
            else if(info.locationList().size() > 0 && info.locationList().get(0).startsWith(Consumer.location) &&
                    endPoint == null && port == null)
            {
                endPoint = info.endpoint();
                port = info.port();
            }
        }

This is just an example that shows how to use the ServiceEndpointDiscovery. You can change the way to select the endpoint according to your requirements.

The service endpoint discovery response looks like this:

"services": [
        {
            "port": 14002,
            "location": [
                "ap-northeast-1a"
            ],
            "transport": "tcp",
            "provider": "aws",
            "endpoint": "ap-northeast-1-aws-1-med.optimized-pricing-api.refinitiv.net",
            "dataFormat": [
                "rwf"
            ]
        },
        {
            "port": 14002,
            "location": [
                "ap-northeast-1a",
                "ap-northeast-1b"
            ],
            "transport": "tcp",
            "provider": "aws",
            "endpoint": "ap-northeast-1-aws-3-med.optimized-pricing-api.refinitiv.net",
            "dataFormat": [
                "rwf"
            ]
        },
        {
            "port": 14002,
            "location": [
                "ap-northeast-1b"
            ],
            "transport": "tcp",
            "provider": "aws",
            "endpoint": "ap-northeast-1-aws-2-med.optimized-pricing-api.refinitiv.net",
            "dataFormat": [
                "rwf"
            ]
        },

You can select the endpoint that closes to your location and has two more more locations for fault tolerance.

Moreover, you can use the ChannelSet configuration in the Consumer.

1691724484202.png

For example, the first channel in the ChannelSet connects to the endpoint in the ap-northeast location and the second channel in the ChannelSet connects to the endpoint in the ap-southeast location.


1691724484202.png (48.3 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thank you, that code looks more robust. ChannelSet also looks like a good thing - do you have code examples that use it?

Upvote
25.1k 57 17 14

Hello @daniel.lipofsky

Additionally, you can find more details about the Service Discovery response message from chapter 4 "Connectivity to Refinitiv Real-Time — Optimized" of the Refinitiv Real-Time - Optimized Install and Config Guide document.

service-table.png



service-table.png (153.9 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.