com.thomsonreuters.ema.access.ServiceEndpointDiscovery Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ema Show documentation
Show all versions of ema Show documentation
Enterprise Message API (EMA) Java Edition
///*|-----------------------------------------------------------------------------
// *| This source code is provided under the Apache 2.0 license --
// *| and is provided AS IS with no warranty or guarantee of fit for purpose. --
// *| See the project's LICENSE.md for details. --
// *| Copyright (C) 2019 Refinitiv. All rights reserved. --
///*|-----------------------------------------------------------------------------
package com.thomsonreuters.ema.access;
/**
* ServiceEndpointDiscovery class provides the functionality to query endpoints from EDP-RT service discovery.
*
* Application interacts with the service discovery through the ServiceEndpointDiscovery interface methods.
* The results of these interactions are communicated back to application through ServiceEndpointDiscoveryClient.
*
* An ServiceEndpointDiscovery is created from EmaFactory
* (see {@link com.thomsonreuters.ema.access.EmaFactory#createServiceEndpointDiscovery()}
* or {@link com.thomsonreuters.ema.access.EmaFactory#createServiceEndpointDiscovery(String, String)}).
*
* The following code snippet shows basic usage of ServiceEndpointDiscovery class in a simple consumer type app.
*
*
* // create an implementation for ServiceEndpointDiscoveryClient to process service discovery responses
* class AppClient implements ServiceEndpointDiscoveryClient
* {
* void onSuccess(ServiceEndpointDiscoveryResp serviceEndpointDiscoveryResp, ServiceEndpointDiscoveryEvent event);
* void onError(String errorText, ServiceEndpointDiscoveryEvent event);
* }
*
* public class Consumer
* {
* public static void main(String[] args)
* {
* ServiceEndpointDiscovery serviceEndpointDiscovery = null;
* try
* {
* AppClient appClient = new AppClient();
*
* // instantiate ServiceEndpointDiscovery object
* serviceEndpointDiscovery = EmaFactory.createServiceEndpointDiscovery();
*
* // Query endpoints from EDP-RT service discovery
* serviceEndpointDiscovery.registerClient(EmaFactory.createServiceEndpointDiscoveryOpion().username(userName)
* .password(password).transport(ServiceEndpointDiscoveryOption::TCP).clientId(clientId), appClient);
* }
* catch (OmmException excp)
* {
* System.out.println(excp.getMessage());
* }
* finally
* {
* if (serviceEndpointDiscovery != null) serviceEndpointDiscovery.uninitialize();
* }
* }
* }
*
*
* @see ServiceEndpointDiscoveryOption
* @see ServiceEndpointDiscoveryClient
* @see OmmException
*/
public interface ServiceEndpointDiscovery
{
/**
* Queries the EDP-RT service discovery synchronously to get endpoints according to the specified parameters
*
* This method is ObjectLevelSafe.
*
* @throws OmmInvalidUsageException if application passes invalid ServiceEndpointDiscoveryOption
*
* @param params specifies query options to get endpoints
* @param client specifies ServiceEndpointDiscoveryClient instance receiving notifications about this query
*/
public void registerClient(ServiceEndpointDiscoveryOption params, ServiceEndpointDiscoveryClient client);
/**
* Queries the EDP-RT service discovery synchronously to get endpoints according to the specified parameters
*
* This method is ObjectLevelSafe.
*
* @throws OmmInvalidUsageException if application passes invalid ServiceEndpointDiscoveryOption
*
* @param params specifies query options to get endpoints
* @param client specifies ServiceEndpointDiscoveryClient instance receiving notifications about this query
* @param closure specifies application defined query identification
*/
public void registerClient(ServiceEndpointDiscoveryOption params, ServiceEndpointDiscoveryClient client, Object closure);
/**
* Uninitializes the ServiceEndpointDiscovery object.
*
* This method is ObjectLevelSafe.
*/
public void uninitialize();
}