本文整理汇总了C#中IClientMessage.GetCorrelationId方法的典型用法代码示例。如果您正苦于以下问题:C# IClientMessage.GetCorrelationId方法的具体用法?C# IClientMessage.GetCorrelationId怎么用?C# IClientMessage.GetCorrelationId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IClientMessage
的用法示例。
在下文中一共展示了IClientMessage.GetCorrelationId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartListening
public string StartListening(IClientMessage request, DistributedEventHandler handler,
DecodeStartListenerResponse responseDecoder, object key = null)
{
try
{
IFuture<IClientMessage> task;
if (key == null)
{
task = _client.GetInvocationService()
.InvokeListenerOnRandomTarget(request, handler, responseDecoder);
}
else
{
task = _client.GetInvocationService()
.InvokeListenerOnKeyOwner(request, key, handler, responseDecoder);
}
var clientMessage = ThreadUtil.GetResult(task);
var registrationId = responseDecoder(clientMessage);
RegisterListener(registrationId, request.GetCorrelationId());
return registrationId;
}
catch (Exception e)
{
throw ExceptionUtil.Rethrow(e);
}
}
示例2: HandleResponseMessage
private void HandleResponseMessage(IClientMessage response)
{
var correlationId = response.GetCorrelationId();
ClientInvocation invocation;
if (_invocations.TryRemove(correlationId, out invocation))
{
if (response.GetMessageType() == Error.Type)
{
var error = Error.Decode(response);
var exception = ExceptionUtil.ToException(error);
// retry only specific exceptions
HandleException(invocation, exception);
}
// if this was a re-registration operation, then we will throw away the response and just store the alias
else if (invocation is ClientListenerInvocation && invocation.Future.IsComplete &&
invocation.Future.Result != null)
{
var listenerInvocation = (ClientListenerInvocation) invocation;
var originalRegistrationId = GetRegistrationIdFromResponse(listenerInvocation);
var newRegistrationId = listenerInvocation.ResponseDecoder(response);
_client.GetListenerService()
.ReregisterListener(originalRegistrationId, newRegistrationId,
invocation.Message.GetCorrelationId());
if (Logger.IsFinestEnabled())
{
Logger.Finest(string.Format("Re-registered listener for {0} of type {1:X}",
originalRegistrationId,
listenerInvocation.Message.GetMessageType()));
}
}
else
{
invocation.Future.Result = response;
}
}
else
{
Logger.Warning("No call for correlationId: " + correlationId + ", response: " + response);
}
}
示例3: HandleEventMessage
private void HandleEventMessage(IClientMessage eventMessage)
{
var correlationId = eventMessage.GetCorrelationId();
ClientListenerInvocation invocationWithHandler;
if (!_listenerInvocations.TryGetValue(correlationId, out invocationWithHandler))
{
// no event handler found, could be that the event is already unregistered
Logger.Warning("No eventHandler for correlationId: " + correlationId + ", event: " + eventMessage);
return;
}
invocationWithHandler.Handler(eventMessage);
}