本文整理汇总了C#中IBasicProperties.IsCorrelationIdPresent方法的典型用法代码示例。如果您正苦于以下问题:C# IBasicProperties.IsCorrelationIdPresent方法的具体用法?C# IBasicProperties.IsCorrelationIdPresent怎么用?C# IBasicProperties.IsCorrelationIdPresent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IBasicProperties
的用法示例。
在下文中一共展示了IBasicProperties.IsCorrelationIdPresent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyFrom
public void CopyFrom(IBasicProperties basicProperties)
{
Preconditions.CheckNotNull(basicProperties, "basicProperties");
if (basicProperties.IsContentTypePresent()) ContentType = basicProperties.ContentType;
if (basicProperties.IsContentEncodingPresent()) ContentEncoding = basicProperties.ContentEncoding;
if (basicProperties.IsDeliveryModePresent()) DeliveryMode = basicProperties.DeliveryMode;
if (basicProperties.IsPriorityPresent()) Priority = basicProperties.Priority;
if (basicProperties.IsCorrelationIdPresent()) CorrelationId = basicProperties.CorrelationId;
if (basicProperties.IsReplyToPresent()) ReplyTo = basicProperties.ReplyTo;
if (basicProperties.IsExpirationPresent()) Expiration = basicProperties.Expiration;
if (basicProperties.IsMessageIdPresent()) MessageId = basicProperties.MessageId;
if (basicProperties.IsTimestampPresent()) Timestamp = basicProperties.Timestamp.UnixTime;
if (basicProperties.IsTypePresent()) Type = basicProperties.Type;
if (basicProperties.IsUserIdPresent()) UserId = basicProperties.UserId;
if (basicProperties.IsAppIdPresent()) AppId = basicProperties.AppId;
if (basicProperties.IsClusterIdPresent()) ClusterId = basicProperties.ClusterId;
if (basicProperties.IsHeadersPresent())
{
foreach (var header in basicProperties.Headers)
{
Headers.Add(header.Key, header.Value);
}
}
}
示例2: MessageBasicProperties
public MessageBasicProperties(IBasicProperties basicProperties)
: this()
{
ContentTypePresent = basicProperties.IsContentTypePresent();
ContentEncodingPresent = basicProperties.IsContentEncodingPresent();
HeadersPresent = basicProperties.IsHeadersPresent();
DeliveryModePresent = basicProperties.IsDeliveryModePresent();
PriorityPresent = basicProperties.IsPriorityPresent();
CorrelationIdPresent = basicProperties.IsCorrelationIdPresent();
ReplyToPresent = basicProperties.IsReplyToPresent();
ExpirationPresent = basicProperties.IsExpirationPresent();
MessageIdPresent = basicProperties.IsMessageIdPresent();
TimestampPresent = basicProperties.IsTimestampPresent();
TypePresent = basicProperties.IsTypePresent();
UserIdPresent = basicProperties.IsUserIdPresent();
AppIdPresent = basicProperties.IsAppIdPresent();
ClusterIdPresent = basicProperties.IsClusterIdPresent();
ContentType = basicProperties.ContentType;
ContentEncoding = basicProperties.ContentEncoding;
DeliveryMode = basicProperties.DeliveryMode;
Priority = basicProperties.Priority;
CorrelationId = basicProperties.CorrelationId;
ReplyTo = basicProperties.ReplyTo;
Expiration = basicProperties.Expiration;
MessageId = basicProperties.MessageId;
Timestamp = basicProperties.Timestamp.UnixTime;
Type = basicProperties.Type;
UserId = basicProperties.UserId;
AppId = basicProperties.AppId;
ClusterId = basicProperties.ClusterId;
if(basicProperties.IsHeadersPresent())
{
foreach (DictionaryEntry header in basicProperties.Headers)
{
Headers.Add(header.Key, header.Value);
}
}
}
示例3: ConsumeMessage
protected virtual async Task<bool> ConsumeMessage(bool redelivered, ulong deliveryTag, IBasicProperties properties, byte[] body)
{
DataContractKey dataContractKey = properties.GetDataContractKey();
var subscription =
_subscriptions.Where(p => p.Value.FilterInfo.ContractKey.Equals(dataContractKey)).Select(
pair =>
new
{
DataType = pair.Key,
pair.Value.Handler
}).FirstOrDefault();
if (subscription == null)
{
RawBusMessage rawBusMessage = _messageHelper.ConstructMessage(dataContractKey, properties, (object)body);
_errorSubscriber.UnregisteredMessageArrived(rawBusMessage);
return false;
}
object data;
if (!_serializers.ContainsKey(properties.ContentType))
{
RawBusMessage rawBusMessage = _messageHelper.ConstructMessage(dataContractKey, properties, (object)body);
_errorSubscriber.MessageDeserializeException(rawBusMessage, new Exception("Unsupported content type"));
return false;
}
ISerializer serializer;
try
{
serializer = _serializers[properties.ContentType];
data = serializer.Deserialize(dataContractKey, subscription.DataType, body);
}
catch (Exception ex)
{
RawBusMessage rawBusMessage = _messageHelper.ConstructMessage(dataContractKey, properties, (object)body);
_errorSubscriber.MessageDeserializeException(rawBusMessage, ex);
return false;
}
RawBusMessage message = _messageHelper.ConstructMessage(dataContractKey, properties, data);
if (!_receiveSelfPublish && _busId.Equals(message.BusId))
{
_errorSubscriber.MessageFilteredOut(message);
return false;
}
_trace.MessageArrived(_busId, message, ConsumerTag);
RawBusMessage reply;
try
{
reply = await HandleMessage(subscription.Handler, message, redelivered, deliveryTag);
}
catch (RejectMessageException ex)
{
reply = new RawBusMessage
{
Data = ex.ReplyData
};
reply.Headers.Add(new RejectedHeader());
}
catch (Exception ex)
{
_errorSubscriber.MessageDispatchException(message, ex);
reply = new RawBusMessage();
reply.Headers.Add(new ExceptionHeader
{
Message = ex.Message
});
}
if (!_neverReply && reply != null && properties.IsReplyToPresent())
{
_sendHelper.Send(new SendParams
{
BusId = _busId,
BusMessage = reply,
Model = Model,
CorrelationId = properties.IsCorrelationIdPresent() ? properties.CorrelationId : "",
Exchange = _replyExchange,
RoutingKey = properties.ReplyTo,
Serializer = serializer,
MandatoryDelivery = false,
//.........这里部分代码省略.........
示例4: HandleBasicDeliver
public override void HandleBasicDeliver(string consumerTag, ulong deliveryTag, bool redelivered, string exchange, string routingKey, IBasicProperties properties, byte[] body)
{
if (!properties.IsCorrelationIdPresent())
{
return;
}
CallbackInfo info;
if (_callbacksDictionary.TryRemove(properties.CorrelationId, out info))
{
var rejectHeader =
properties.Headers.Where(pair => pair.Key == RejectedHeader.WellknownName)
.Select(pair => pair.Value)
.FirstOrDefault();
var exceptionHeader =
properties.Headers.Where(pair => pair.Key == ExceptionHeader.WellknownName)
.Select(pair => pair.Value)
.FirstOrDefault();
if (exceptionHeader != null)
{
info.SetResponse(null, new RpcCallException(RpcFailureReason.HandlerError, exceptionHeader.ToString()));
return;
}
DataContractKey dataContractKey;
object data;
if (body.Length == 0 || info.ReplyType == null)
{
// Reject without data
if (rejectHeader != null)
{
info.SetResponse(null, new RpcCallException(RpcFailureReason.Reject));
return;
}
// Void reply or sender not interested in reply data, but only interested to be notified that work is done
dataContractKey = DataContractKey.Void;
data = null;
}
else
{
dataContractKey = properties.GetDataContractKey();
if (!_serializers.ContainsKey(properties.ContentType))
{
info.SetResponse(null,
new RpcCallException(RpcFailureReason.SerializationError,
string.Format("Unsupported content type {0}", properties.ContentType)));
return;
}
try
{
ISerializer serializer = _serializers[properties.ContentType];
data = serializer.Deserialize(dataContractKey, info.ReplyType, body);
}
catch (Exception ex)
{
info.SetResponse(null, new RpcCallException(RpcFailureReason.SerializationError, ex));
return;
}
}
// Reject with data
if (rejectHeader != null)
{
info.SetResponse(null, new RpcCallException(RpcFailureReason.Reject, data));
return;
}
RawBusMessage message = _messageHelper.ConstructMessage(dataContractKey, properties, data);
_trace.MessageArrived(_busId, message, ConsumerTag);
info.SetResponse(message, null);
info.RegisteredHandle.Unregister(info.WaitHandle);
}
}
示例5: CopyFrom
internal void CopyFrom(IBasicProperties from)
{
if (from == null)
throw new ArgumentNullException(nameof(from));
if (from.IsAppIdPresent()) AppId = from.AppId;
if (from.IsClusterIdPresent()) ClusterId = from.ClusterId;
if (from.IsContentEncodingPresent()) ContentEncoding = from.ContentEncoding;
if (from.IsContentTypePresent()) ContentType = from.ContentType;
if (from.IsCorrelationIdPresent()) CorrelationId = from.CorrelationId;
if (from.IsDeliveryModePresent()) DeliveryMode = (LinkMessageDeliveryMode) from.DeliveryMode;
if (from.IsReplyToPresent()) ReplyTo = from.ReplyTo;
if (from.IsExpirationPresent()) Expiration = TimeSpan.FromMilliseconds(int.Parse(from.Expiration));
if (from.IsMessageIdPresent()) MessageId = from.MessageId;
if (from.IsTimestampPresent()) TimeStamp = from.Timestamp.UnixTime;
if (from.IsTypePresent()) Type = from.Type;
if (from.IsUserIdPresent()) UserId = from.UserId;
if (from.IsPriorityPresent()) Priority = from.Priority;
if (from.IsHeadersPresent())
{
foreach (var header in from.Headers)
{
Headers[header.Key] = header.Value;
}
}
}