public override string ToString() { StringBuilder stringBuilder = new StringBuilder("properties("); int num = 0; base.AddFieldToString(this.MessageId != null, stringBuilder, Microsoft.ServiceBus.Messaging.Amqp.Framing.Properties.MessageIdName, this.MessageId, ref num); ArraySegment <byte> userId = this.UserId; base.AddFieldToString(userId.Array != null, stringBuilder, Microsoft.ServiceBus.Messaging.Amqp.Framing.Properties.UserIdName, this.UserId, ref num); base.AddFieldToString(this.To != null, stringBuilder, Microsoft.ServiceBus.Messaging.Amqp.Framing.Properties.ToName, this.To, ref num); base.AddFieldToString(this.Subject != null, stringBuilder, Microsoft.ServiceBus.Messaging.Amqp.Framing.Properties.SubjectName, this.Subject, ref num); base.AddFieldToString(this.ReplyTo != null, stringBuilder, Microsoft.ServiceBus.Messaging.Amqp.Framing.Properties.ReplyToName, this.ReplyTo, ref num); base.AddFieldToString(this.CorrelationId != null, stringBuilder, Microsoft.ServiceBus.Messaging.Amqp.Framing.Properties.CorrelationIdName, this.CorrelationId, ref num); AmqpSymbol contentType = this.ContentType; base.AddFieldToString(contentType.Value != null, stringBuilder, Microsoft.ServiceBus.Messaging.Amqp.Framing.Properties.ContentTypeName, this.ContentType, ref num); AmqpSymbol contentEncoding = this.ContentEncoding; base.AddFieldToString(contentEncoding.Value != null, stringBuilder, Microsoft.ServiceBus.Messaging.Amqp.Framing.Properties.ContentEncodingName, this.ContentEncoding, ref num); DateTime?absoluteExpiryTime = this.AbsoluteExpiryTime; base.AddFieldToString(absoluteExpiryTime.HasValue, stringBuilder, Microsoft.ServiceBus.Messaging.Amqp.Framing.Properties.AbsoluteExpiryTimeName, this.AbsoluteExpiryTime, ref num); DateTime?creationTime = this.CreationTime; base.AddFieldToString(creationTime.HasValue, stringBuilder, Microsoft.ServiceBus.Messaging.Amqp.Framing.Properties.CreationTimeName, this.CreationTime, ref num); base.AddFieldToString(this.GroupId != null, stringBuilder, Microsoft.ServiceBus.Messaging.Amqp.Framing.Properties.GroupIdName, this.GroupId, ref num); uint?groupSequence = this.GroupSequence; base.AddFieldToString(groupSequence.HasValue, stringBuilder, Microsoft.ServiceBus.Messaging.Amqp.Framing.Properties.GroupSequenceName, this.GroupSequence, ref num); base.AddFieldToString(this.ReplyToGroupId != null, stringBuilder, Microsoft.ServiceBus.Messaging.Amqp.Framing.Properties.ReplyToGroupIdName, this.ReplyToGroupId, ref num); stringBuilder.Append(')'); return(stringBuilder.ToString()); }
public IDictionary <string, object> ToDictionary() { IDictionary <string, object> strs = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase); strs.Add(this.MessageId != null, Microsoft.ServiceBus.Messaging.Amqp.Framing.Properties.MessageIdName, this.MessageId); ArraySegment <byte> userId = this.UserId; strs.Add(userId.Array != null, Microsoft.ServiceBus.Messaging.Amqp.Framing.Properties.UserIdName, this.UserId); strs.Add(this.To != null, Microsoft.ServiceBus.Messaging.Amqp.Framing.Properties.ToName, this.To); strs.Add(this.Subject != null, Microsoft.ServiceBus.Messaging.Amqp.Framing.Properties.SubjectName, this.Subject); strs.Add(this.ReplyTo != null, Microsoft.ServiceBus.Messaging.Amqp.Framing.Properties.ReplyToName, this.ReplyTo); strs.Add(this.CorrelationId != null, Microsoft.ServiceBus.Messaging.Amqp.Framing.Properties.CorrelationIdName, this.CorrelationId); AmqpSymbol contentType = this.ContentType; strs.Add(contentType.Value != null, Microsoft.ServiceBus.Messaging.Amqp.Framing.Properties.ContentTypeName, this.ContentType); AmqpSymbol contentEncoding = this.ContentEncoding; strs.Add(contentEncoding.Value != null, Microsoft.ServiceBus.Messaging.Amqp.Framing.Properties.ContentEncodingName, this.ContentEncoding); DateTime?absoluteExpiryTime = this.AbsoluteExpiryTime; strs.Add(absoluteExpiryTime.HasValue, Microsoft.ServiceBus.Messaging.Amqp.Framing.Properties.AbsoluteExpiryTimeName, this.AbsoluteExpiryTime); DateTime?creationTime = this.CreationTime; strs.Add(creationTime.HasValue, Microsoft.ServiceBus.Messaging.Amqp.Framing.Properties.CreationTimeName, this.CreationTime); strs.Add(this.GroupId != null, Microsoft.ServiceBus.Messaging.Amqp.Framing.Properties.GroupIdName, this.GroupId); uint?groupSequence = this.GroupSequence; strs.Add(groupSequence.HasValue, Microsoft.ServiceBus.Messaging.Amqp.Framing.Properties.GroupSequenceName, this.GroupSequence); strs.Add(this.ReplyToGroupId != null, Microsoft.ServiceBus.Messaging.Amqp.Framing.Properties.ReplyToGroupIdName, this.ReplyToGroupId); return(strs); }
public static void DecodeDescriptor(ByteBuffer buffer, out AmqpSymbol name, out ulong code) { name = default(AmqpSymbol); code = 0; FormatCode formatCode = AmqpEncoding.ReadFormatCode(buffer); if (formatCode == FormatCode.Described) { formatCode = AmqpEncoding.ReadFormatCode(buffer); } if (formatCode == FormatCode.Symbol8 || formatCode == FormatCode.Symbol32) { name = SymbolEncoding.Decode(buffer, formatCode); } else if (formatCode == FormatCode.ULong || formatCode == FormatCode.ULong0 || formatCode == FormatCode.SmallULong) { code = ULongEncoding.Decode(buffer, formatCode).Value; } else { throw AmqpEncoding.GetInvalidFormatCodeException(formatCode, buffer.Offset); } }
public CompositeType(Type type, string descriptorName, ulong?descriptorCode, SerialiableMember[] members) { this.type = type; this.descriptorName = descriptorName; this.descriptorCode = descriptorCode; this.members = members; }
static AmqpConstants() { AmqpConstants.BatchedMessageFormat = "com.microsoft:batched-message-format"; AmqpConstants.SimpleWebTokenPropertyName = "com.microsoft:swt"; AmqpConstants.ContainerId = "container-id"; AmqpConstants.ConnectionId = "connection-id"; AmqpConstants.LinkName = "link-name"; AmqpConstants.ClientMaxFrameSize = "client-max-frame-size"; AmqpConstants.HostName = "hostname"; AmqpConstants.NetworkHost = "network-host"; AmqpConstants.Port = "port"; AmqpConstants.Address = "address"; AmqpConstants.PublisherId = "publisher-id"; AmqpConstants.NullBinary = new ArraySegment <byte>(); AmqpConstants.EmptyBinary = new ArraySegment <byte>(new byte[0]); AmqpConstants.DefaultProtocolVersion = new AmqpVersion(1, 0, 0); DateTime dateTime = DateTime.Parse("1970-01-01T00:00:00.0000000Z", CultureInfo.InvariantCulture); AmqpConstants.StartOfEpoch = dateTime.ToUniversalTime(); DateTime maxValue = DateTime.MaxValue; AmqpConstants.MaxAbsoluteExpiryTime = maxValue.ToUniversalTime() - TimeSpan.FromDays(1); AmqpConstants.AcceptedOutcome = new Accepted(); AmqpConstants.ReleasedOutcome = new Released(); AmqpConstants.RejectedOutcome = new Rejected(); AmqpConstants.RejectedNotFoundOutcome = new Rejected() { Error = AmqpError.NotFound }; }
public static AmqpDescribed CreateAmqpDescribed(ByteBuffer buffer, Dictionary <string, Func <AmqpDescribed> > byName, Dictionary <ulong, Func <AmqpDescribed> > byCode) { FormatCode formatCode = AmqpEncoding.ReadFormatCode(buffer); if (formatCode == 64) { return(null); } EncodingBase.VerifyFormatCode(formatCode, 0, buffer.Offset); Func <AmqpDescribed> func = null; formatCode = AmqpEncoding.ReadFormatCode(buffer); if (formatCode == 163 || formatCode == 179) { AmqpSymbol amqpSymbol = SymbolEncoding.Decode(buffer, formatCode); byName.TryGetValue(amqpSymbol.Value, out func); } else if (formatCode == 68 || formatCode == 128 || formatCode == 83) { ulong?nullable = ULongEncoding.Decode(buffer, formatCode); byCode.TryGetValue(nullable.Value, out func); } if (func == null) { throw AmqpEncoding.GetEncodingException(SRAmqp.AmqpInvalidFormatCode(formatCode, buffer.Offset)); } return(func()); }
public static void DecodeDescriptor(ByteBuffer buffer, out AmqpSymbol name, out ulong code) { name = default(AmqpSymbol); code = 0; FormatCode formatCode = AmqpEncoding.ReadFormatCode(buffer); if (formatCode == FormatCode.Described) { formatCode = AmqpEncoding.ReadFormatCode(buffer); } if (formatCode == FormatCode.Symbol8 || formatCode == FormatCode.Symbol32) { name = SymbolEncoding.Decode(buffer, formatCode); } else if (formatCode == FormatCode.ULong || formatCode == FormatCode.ULong0 || formatCode == FormatCode.SmallULong) { code = ULongEncoding.Decode(buffer, formatCode).Value; } else { throw AmqpEncoding.GetEncodingException(AmqpResources.GetString(AmqpResources.AmqpInvalidFormatCode, formatCode, buffer.Offset)); } }
static TerminusExpiryPolicy() { TerminusExpiryPolicy.LinkDetach = "link-detach"; TerminusExpiryPolicy.SessionEnd = "session-end"; TerminusExpiryPolicy.ConnectionClose = "connection-close"; TerminusExpiryPolicy.Never = "never"; }
public override string ToString() { StringBuilder stringBuilder = new StringBuilder("source("); int num = 0; base.AddFieldToString(this.Address != null, stringBuilder, "address", this.Address, ref num); uint?durable = this.Durable; base.AddFieldToString(durable.HasValue, stringBuilder, "durable", this.Durable, ref num); AmqpSymbol expiryPolicy = this.ExpiryPolicy; base.AddFieldToString(expiryPolicy.Value != null, stringBuilder, "expiry-policy", this.ExpiryPolicy, ref num); uint?timeout = this.Timeout; base.AddFieldToString(timeout.HasValue, stringBuilder, "timeout", this.Timeout, ref num); bool?dynamic = this.Dynamic; base.AddFieldToString(dynamic.HasValue, stringBuilder, "dynamic", this.Dynamic, ref num); base.AddFieldToString(this.DynamicNodeProperties != null, stringBuilder, "dynamic-node-properties", this.DynamicNodeProperties, ref num); AmqpSymbol distributionMode = this.DistributionMode; base.AddFieldToString(distributionMode.Value != null, stringBuilder, "distribution-mode", this.DistributionMode, ref num); base.AddFieldToString(this.FilterSet != null, stringBuilder, "filter", this.FilterSet, ref num); base.AddFieldToString(this.DefaultOutcome != null, stringBuilder, "default-outcome", this.DefaultOutcome, ref num); base.AddFieldToString(this.Outcomes != null, stringBuilder, "outcomes", this.Outcomes, ref num); base.AddFieldToString(this.Capabilities != null, stringBuilder, "capabilities", this.Capabilities, ref num); stringBuilder.Append(')'); return(stringBuilder.ToString()); }
protected override IEnumerator <IteratorAsyncResult <AmqpChannelFactory.SharedAmqpLink.OpenLinkAsyncResult> .AsyncStep> GetAsyncSteps() { AmqpChannelFactory.SharedAmqpLink.OpenLinkAsyncResult openLinkAsyncResult = this; IteratorAsyncResult <AmqpChannelFactory.SharedAmqpLink.OpenLinkAsyncResult> .BeginCall beginCall = (AmqpChannelFactory.SharedAmqpLink.OpenLinkAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.sharedAmqpConnection.BeginGetInstance(t, c, s); yield return(openLinkAsyncResult.CallAsync(beginCall, (AmqpChannelFactory.SharedAmqpLink.OpenLinkAsyncResult thisPtr, IAsyncResult a) => thisPtr.amqpConnectionSession = thisPtr.sharedAmqpConnection.EndGetInstance(a), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer)); AmqpLinkSettings amqpLinkSetting = new AmqpLinkSettings() { LinkName = string.Concat(this.via.PathAndQuery, "/", Guid.NewGuid()) }; AmqpLinkSettings amqpLinkSetting1 = amqpLinkSetting; AmqpSymbol timeoutName = ClientConstants.TimeoutName; TimeSpan timeSpan = base.RemainingTime(); amqpLinkSetting1.AddProperty(timeoutName, (uint)timeSpan.TotalMilliseconds); amqpLinkSetting.Role = new bool?(false); amqpLinkSetting.InitialDeliveryCount = new uint?(0); AmqpLinkSettings amqpLinkSetting2 = amqpLinkSetting; Target target = new Target() { Address = this.via.PathAndQuery }; amqpLinkSetting2.Target = target; this.Link = new SendingAmqpLink(this.amqpConnectionSession.Item2, amqpLinkSetting); this.Link.Closed += new EventHandler(this.sharedAmqpLink.OnLinkClosed); AmqpChannelFactory.SharedAmqpLink.OpenLinkAsyncResult openLinkAsyncResult1 = this; IteratorAsyncResult <AmqpChannelFactory.SharedAmqpLink.OpenLinkAsyncResult> .BeginCall beginCall1 = (AmqpChannelFactory.SharedAmqpLink.OpenLinkAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.Link.BeginOpen(t, c, s); IteratorAsyncResult <AmqpChannelFactory.SharedAmqpLink.OpenLinkAsyncResult> .EndCall endCall = (AmqpChannelFactory.SharedAmqpLink.OpenLinkAsyncResult thisPtr, IAsyncResult r) => thisPtr.Link.EndOpen(r); yield return(openLinkAsyncResult1.CallAsync(beginCall1, endCall, (AmqpChannelFactory.SharedAmqpLink.OpenLinkAsyncResult thisPtr, TimeSpan t) => thisPtr.Link.Open(t), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer)); }
public static object DecodeObject(ByteBuffer buffer) { FormatCode formatCode = AmqpEncoding.ReadFormatCode(buffer); if (formatCode == 64) { return(null); } if (formatCode != 0) { return(AmqpEncoding.DecodeObject(buffer, formatCode)); } object obj = AmqpCodec.DecodeObject(buffer); Func <AmqpDescribed> func = null; if (obj is AmqpSymbol) { Dictionary <string, Func <AmqpDescribed> > strs = AmqpCodec.knownTypesByName; AmqpSymbol amqpSymbol = (AmqpSymbol)obj; strs.TryGetValue(amqpSymbol.Value, out func); } else if (obj is ulong) { AmqpCodec.knownTypesByCode.TryGetValue((ulong)obj, out func); } if (func == null) { return(new DescribedType(obj, AmqpCodec.DecodeObject(buffer))); } AmqpDescribed amqpDescribed = func(); amqpDescribed.DecodeValue(buffer); return(amqpDescribed); }
public static Exception ToMessagingContractException(this AmqpMessage responseMessage, AmqpResponseStatusCode statusCode) { AmqpSymbol errorCondition = AmqpExceptionHelper.GetResponseErrorCondition(responseMessage, statusCode); var statusDescription = responseMessage.ApplicationProperties.Map[ManagementConstants.Response.StatusDescription] as string ?? errorCondition.Value; return(AmqpExceptionHelper.ToMessagingContractException(errorCondition.Value, statusDescription)); }
public void CreateExceptionForErrorWithCondition(AmqpSymbol condition, Type exceptionType, EventHubsException.FailureReason?reason) { var description = "This is a test description."; var resourceName = "TestHub"; var error = new Error { Condition = condition, Description = description }; Exception exception = AmqpError.CreateExceptionForError(error, resourceName); Assert.That(exception, Is.Not.Null, "An exception should have been created"); Assert.That(exception, Is.TypeOf(exceptionType), "The exception should be the proper type"); Assert.That(exception.Message, Is.SupersetOf(description), "The exception message should contain the description"); if (exception is EventHubsException) { Assert.That(((EventHubsException)exception).Reason, Is.EqualTo(reason), "The proper failure reason should be specified"); Assert.That(((EventHubsException)exception).EventHubName, Is.EqualTo(resourceName), "The exception should report the proper resource"); } }
public DescribedValueType(string symbol, Func <TValue, TAs> getter, Func <TAs, TValue> setter) : base(null, typeof(TValue)) { this.symbol = symbol; this.encoder = AmqpEncoding.GetEncoding(typeof(TAs)); this.getter = getter; this.setter = setter; }
public static void AddProperty(this Attach attach, AmqpSymbol symbol, object value) { if (attach.Properties == null) { attach.Properties = new Fields(); } attach.Properties.Add(symbol, value); }
static TxnCapabilities() { TxnCapabilities.LocalTransactions = "amqp:local-transactions"; TxnCapabilities.DistributedTxn = "amqp:distributed-transactions"; TxnCapabilities.PrototableTransactions = "amqp:prototable-transactions"; TxnCapabilities.MultiTxnsPerSsn = "amqp:multi-txns-per-ssn"; TxnCapabilities.MultiSsnsPerTxn = "amqp:multi-ssns-per-txn"; }
public static void UpsertProperty(this Attach attach, AmqpSymbol symbol, object value) { if (attach.Properties == null) { attach.Properties = new Fields(); } attach.Properties[symbol] = value; }
public static void AddProperty(this Open open, AmqpSymbol symbol, object value) { if (open.Properties == null) { open.Properties = new Fields(); } open.Properties.Add(symbol, value); }
protected override async Task <IList <BrokeredMessage> > OnPeekAsync(long fromSequenceNumber, int messageCount = 1) { try { AmqpRequestMessage requestMessage = AmqpRequestMessage.CreateRequest( ManagementConstants.Operations.PeekMessageOperation, this.OperationTimeout, null); requestMessage.Map[ManagementConstants.Properties.FromSequenceNumber] = fromSequenceNumber; requestMessage.Map[ManagementConstants.Properties.MessageCount] = messageCount; if (!string.IsNullOrWhiteSpace(this.sessionId)) { requestMessage.Map[ManagementConstants.Properties.SessionId] = this.sessionId; } List <BrokeredMessage> messages = new List <BrokeredMessage>(); AmqpResponseMessage response = await this.ExecuteRequestResponseAsync(requestMessage).ConfigureAwait(false); if (response.StatusCode == AmqpResponseStatusCode.OK) { BrokeredMessage brokeredMessage = null; var messageList = response.GetListValue <AmqpMap>(ManagementConstants.Properties.Messages); foreach (AmqpMap entry in messageList) { var payload = (ArraySegment <byte>)entry[ManagementConstants.Properties.Message]; AmqpMessage amqpMessage = AmqpMessage.CreateAmqpStreamMessage(new BufferListStream(new[] { payload }), true); brokeredMessage = AmqpMessageConverter.ClientGetMessage(amqpMessage); messages.Add(brokeredMessage); } if (brokeredMessage != null) { this.LastPeekedSequenceNumber = brokeredMessage.SequenceNumber; } return(messages); } else if (response.StatusCode == AmqpResponseStatusCode.NoContent || (response.StatusCode == AmqpResponseStatusCode.NotFound && AmqpSymbol.Equals(AmqpClientConstants.MessageNotFoundError, response.GetResponseErrorCondition()))) { return(messages); } else { throw response.ToMessagingContractException(); } } catch (Exception exception) { throw AmqpExceptionHelper.GetClientException(exception); } }
// settings public static void UpsertProperty(this Begin begin, AmqpSymbol symbol, object value) { if (begin.Properties == null) { begin.Properties = new Fields(); } begin.Properties[symbol] = value; }
protected DescribedType(AmqpContractSerializer serializer, Type type, SerializableType baseType, string descriptorName, ulong?descriptorCode, SerialiableMember[] members, Dictionary <Type, SerializableType> knownTypes, MethodAccessor onDesrialized) : base(serializer, type) { this.baseType = (SerializableType.DescribedType)baseType; this.descriptorName = descriptorName; this.descriptorCode = descriptorCode; this.members = members; this.onDeserialized = onDesrialized; this.knownTypes = SerializableType.DescribedType.GetKnownTypes(knownTypes); }
public static bool IsAmqpError(Exception exception, AmqpSymbol errorCode) { AmqpException amqpException = exception as AmqpException; if (amqpException != null && amqpException.Error.Condition.Equals(errorCode)) { return(true); } return(false); }
public static Error GetError(AmqpSymbol condition) { Error internalError = null; if (!AmqpError.errors.TryGetValue(condition.Value, out internalError)) { internalError = AmqpError.InternalError; } return(internalError); }
public static void Encode(AmqpSymbol value, ByteBuffer buffer) { if (value.Value == null) { AmqpEncoding.EncodeNull(buffer); } else { SymbolEncoding.Encode(value, 0, buffer); } }
public override void ReadMembers(ByteBuffer buffer, object container, ref int count) { for (int i = 0; i < this.Members.Length && count > 0; ++i, count -= 2) { AmqpSymbol key = AmqpCodec.DecodeSymbol(buffer); object value = this.Members[i].Type.ReadObject(buffer); this.Members[i].Accessor.Set(container, value); } this.InvokeDeserialized(container); }
public static Error GetError(AmqpSymbol condition) { Error error = null; if (!errors.TryGetValue(condition.Value, out error)) { error = InternalError; } return(error); }
public override string ToString() { StringBuilder stringBuilder = new StringBuilder("error("); int num = 0; AmqpSymbol condition = this.Condition; base.AddFieldToString(condition.Value != null, stringBuilder, "condition", this.Condition, ref num); base.AddFieldToString(this.Description != null, stringBuilder, "description", this.Description, ref num); base.AddFieldToString(this.Info != null, stringBuilder, "info", this.Info, ref num); stringBuilder.Append(')'); return(stringBuilder.ToString()); }
public static void UpsertPropertyIfNotDefault <T>(this Attach attach, AmqpSymbol symbol, T value) { if (!object.Equals(value, default(T))) { if (attach.Properties == null) { attach.Properties = new Fields(); } attach.Properties[symbol] = value; } }
private bool AreEqual(ulong?code1, AmqpSymbol symbol1, ulong?code2, AmqpSymbol symbol2) { if (code1.HasValue && code2.HasValue) { return(code1.Value == code2.Value); } if (symbol1.Value == null || symbol2.Value == null) { return(false); } return(symbol1.Value == symbol2.Value); }
private void OnSaslInit(SaslInit init) { if (this.state != SaslNegotiator.SaslState.WaitingForInit) { throw new AmqpException(AmqpError.IllegalState, SRAmqp.AmqpIllegalOperationState("R:SASL-INIT", this.state)); } this.state = SaslNegotiator.SaslState.Negotiating; SaslTransportProvider saslTransportProvider = this.provider; AmqpSymbol mechanism = init.Mechanism; this.saslHandler = saslTransportProvider.GetHandler(mechanism.Value, true); this.saslHandler.Start(this, init, false); }
public static AmqpMessage BrokerGetMessage(BrokeredMessage brokeredMessage) { AmqpMessage messageId = null; bool flag = true; if (brokeredMessage.MessageFormat == BrokeredMessageFormat.PassthroughAmqp) { flag = false; messageId = AmqpMessage.CreateAmqpStreamMessage((BufferListStream)brokeredMessage.BodyStream, true); } else if (brokeredMessage.MessageFormat == BrokeredMessageFormat.Amqp) { messageId = AmqpMessage.CreateAmqpStreamMessage(brokeredMessage.RawHeaderStream, brokeredMessage.BodyStream, true); } else if (brokeredMessage.MessageFormat == BrokeredMessageFormat.AmqpEventData) { flag = false; BufferListStream bufferListStream = BufferListStream.Create(brokeredMessage.BodyStream, 512, true); messageId = AmqpMessage.CreateOutputMessage(bufferListStream, true); MessageAnnotations messageAnnotations = messageId.MessageAnnotations; messageAnnotations.Map["x-opt-sequence-number"] = brokeredMessage.SequenceNumber; Annotations map = messageAnnotations.Map; AmqpSymbol amqpSymbol = "x-opt-offset"; long offset = brokeredMessage.Offset; map[amqpSymbol] = offset.ToString(NumberFormatInfo.InvariantInfo); messageAnnotations.Map["x-opt-enqueued-time"] = brokeredMessage.EnqueuedTimeUtc; if (!string.IsNullOrEmpty(brokeredMessage.Publisher)) { messageAnnotations.Map["x-opt-publisher"] = brokeredMessage.Publisher; messageAnnotations.Map["x-opt-partition-key"] = brokeredMessage.Publisher; } } else if (brokeredMessage.MessageFormat == BrokeredMessageFormat.Sbmp) { brokeredMessage.SetPropertiesAsModifiedByBroker(); messageId = MessageConverter.CreateAmqpMessageFromSbmpMessage(brokeredMessage); messageId.Properties.MessageId = brokeredMessage.MessageId; messageId.Properties.CorrelationId = brokeredMessage.CorrelationId; messageId.Properties.ContentType = brokeredMessage.ContentType; messageId.Properties.Subject = brokeredMessage.Label; messageId.Properties.To = brokeredMessage.To; messageId.Properties.ReplyTo = brokeredMessage.ReplyTo; messageId.Properties.GroupId = brokeredMessage.SessionId; messageId.Properties.ReplyToGroupId = brokeredMessage.ReplyToSessionId; } if (flag) { MessageConverter.UpdateAmqpMessageHeadersAndProperties(messageId, brokeredMessage, true); } return(messageId); }
public static void Encode(AmqpSymbol value, ByteBuffer buffer) { if (value.Value == null) { AmqpEncoding.EncodeNull(buffer); } else { byte[] encodedData = Platform.System.Text.Encoding.ASCII.GetBytes(value.Value); int encodeWidth = AmqpEncoding.GetEncodeWidthBySize(encodedData.Length); AmqpBitConverter.WriteUByte(buffer, encodeWidth == FixedWidth.UByte ? FormatCode.Symbol8 : FormatCode.Symbol32); SymbolEncoding.Encode(encodedData, encodeWidth, buffer); } }
protected override object OnReadObject(ByteBuffer buffer) { object container = Activator.CreateInstance(this.type); FormatCode formatCode = AmqpEncoding.ReadFormatCode(buffer); // FormatCode.Described if (formatCode != FormatCode.Described) { throw new AmqpException(AmqpError.InvalidField, "format-code"); } bool validDescriptor = false; formatCode = AmqpEncoding.ReadFormatCode(buffer); if (formatCode == FormatCode.ULong || formatCode == FormatCode.SmallULong) { ulong code = AmqpBitConverter.ReadULong(buffer); validDescriptor = this.descriptorCode == null || code == this.descriptorCode.Value; } else if (formatCode == FormatCode.Symbol8 || formatCode == FormatCode.Symbol32) { AmqpSymbol symbol = SymbolEncoding.Decode(buffer, formatCode); validDescriptor = this.descriptorName.Value == null || symbol.Equals(this.descriptorName); } if (!validDescriptor) { throw new AmqpException(AmqpError.InvalidField, "descriptor"); } formatCode = AmqpEncoding.ReadFormatCode(buffer); // FormatCode.List if (formatCode == FormatCode.List0) { return(container); } int size = 0; int count = 0; AmqpEncoding.ReadSizeAndCount(buffer, formatCode, FormatCode.List8, FormatCode.List32, out size, out count); // prefetch bytes from the stream buffer.EnsureLength(size - FixedWidth.UInt); for (int i = 0; i < count; ++i) { object value = this.members[i].Type.OnReadObject(buffer); this.members[i].Accessor.SetObject(container, value); } return(container); }
static void Encode(AmqpSymbol value, int width, ByteBuffer buffer) { int stringSize = Encoding.ASCII.GetByteCount(value.Value); if (width == 0) { width = AmqpEncoding.GetEncodeWidthBySize(stringSize); } if (width == FixedWidth.UByte) { AmqpBitConverter.WriteUByte(buffer, (byte)FormatCode.Symbol8); AmqpBitConverter.WriteUByte(buffer, (byte)stringSize); } else { AmqpBitConverter.WriteUByte(buffer, (byte)FormatCode.Symbol32); AmqpBitConverter.WriteUInt(buffer, (uint)stringSize); } buffer.EnsureSize(stringSize); int written = Encoding.ASCII.GetBytes(value.Value, 0, value.Value.Length, buffer.Buffer, buffer.End); buffer.Append(written); }
protected LifeTimePolicy(AmqpSymbol name, ulong code) : base(name, code) { }
protected Performative(AmqpSymbol name, ulong code) : base(name, code) { }
public static int GetEncodeSize(AmqpSymbol value) { return value.Value == null ? FixedWidth.NullEncoded : FixedWidth.FormatCode + AmqpEncoding.GetEncodeWidthBySize(value.ValueSize) + value.ValueSize; }
public static int GetValueSize(AmqpSymbol value) { return value.Value == null ? FixedWidth.Null : Encoding.ASCII.GetByteCount(value.Value); }
protected Outcome(AmqpSymbol name, ulong code) : base(name, code) { }
public AmqpException(AmqpSymbol condition, string description) : this(new Error() { Condition = condition, Description = description }) { }
public DescribedMap(AmqpSymbol name, ulong code) : base(name, code) { this.innerMap = new AmqpMap(); }
public DescribedList(AmqpSymbol name, ulong code) : base(name, code) { }
public static Error GetError(AmqpSymbol condition) { Error error = null; if (!errors.TryGetValue(condition.Value, out error)) { error = InternalError; } return error; }
public DeliveryState(AmqpSymbol name, ulong code) : base(name, code) { }
bool AreEqual(ulong? code1, AmqpSymbol symbol1, ulong? code2, AmqpSymbol symbol2) { if (code1 != null && code2 != null) { return code1.Value == code2.Value; } if (symbol1.Value != null && symbol2.Value != null) { return symbol1.Value == symbol2.Value; } return false; }
public AmqpDescribed(AmqpSymbol name, ulong code) : base(name.Value == null ? (object)code : (object)name, null) { this.name = name; this.code = code; }
protected DescribedAnnotations(AmqpSymbol name, ulong code) : base(name, code) { }