diff --git a/sdk/core/Azure.Core.Amqp/src/Shared/AmqpAnnotatedMessageConverter.cs b/sdk/core/Azure.Core.Amqp/src/Shared/AmqpAnnotatedMessageConverter.cs index a7de0625ea82a..1538abbf4e550 100644 --- a/sdk/core/Azure.Core.Amqp/src/Shared/AmqpAnnotatedMessageConverter.cs +++ b/sdk/core/Azure.Core.Amqp/src/Shared/AmqpAnnotatedMessageConverter.cs @@ -511,7 +511,11 @@ public static bool TryCreateAmqpPropertyValueFromNetProperty( break; case AmqpType.Uri: - amqpPropertyValue = new DescribedType((AmqpSymbol)AmqpMessageConstants.Uri, ((Uri)propertyValue).AbsoluteUri); + amqpPropertyValue = new DescribedType((AmqpSymbol)AmqpMessageConstants.Uri, propertyValue switch + { + Uri uriValue when uriValue.IsAbsoluteUri => uriValue.AbsoluteUri, + _ => propertyValue.ToString() + }); break; case AmqpType.DateTimeOffset: @@ -819,7 +823,7 @@ private static void ThrowSerializationFailed(string propertyName, KeyValuePair[] { new byte[] { 0x11, 0x22, 0x33 }})); + annotatedMessage.ApplicationProperties.Add(key, expectedUri); + + using AmqpMessage message = ToAmqpMessage(annotatedMessage); + + Assert.IsNotNull(message, "The AMQP message should have been created."); + Assert.IsNotNull(message.ApplicationProperties, "The AMQP message should have a set of application properties."); + + var containsValue = annotatedMessage.ApplicationProperties.TryGetValue(key, out object value); + var uriProperty = value as Uri; + + Assert.IsTrue(containsValue, $"The message properties did not contain the Uri property"); + Assert.IsNotNull(uriProperty, "The property value was not a Uri."); + Assert.AreEqual(expectedUri, uriProperty, "The property value did not match."); + } + [Test] public void FromAmqpMessagePopulatesSimpleApplicationProperties() { @@ -242,6 +267,31 @@ public void FromAmqpMessagePopulatesSimpleApplicationProperties() } } + [Test] + [TestCase("http://www.server.com/path/stuff/thing.json")] + [TestCase("/path/stuff/thing.json")] + public void FromAmqpMessageHandlesRelativeAndAbsoluteUris(string uriValue) + { + var key = "UriProperty"; + var expectedUri = new Uri(uriValue, UriKind.RelativeOrAbsolute); + var dataBody = new Data { Value = new byte[] { 0x11, 0x22, 0x33 } }; + + using var message = AmqpMessage.Create(dataBody); + message.ApplicationProperties.Map.Add(key, new DescribedType((AmqpSymbol)AmqpMessageConstants.Uri, uriValue)); + + var annotatedMessage = FromAmqpMessage(message); + + Assert.NotNull(annotatedMessage, "The message should have been created."); + Assert.IsTrue(annotatedMessage.ApplicationProperties.Any(), "The message should have a set of application properties."); + + var containsValue = annotatedMessage.ApplicationProperties.TryGetValue(key, out object value); + var uriProperty = value as Uri; + + Assert.IsTrue(containsValue, $"The message properties did not contain the Uri property"); + Assert.IsNotNull(uriProperty, "The property value was not a Uri."); + Assert.AreEqual(expectedUri, uriProperty, "The property value did not match."); + } + [Test] [TestCaseSource(nameof(DescribedTypePropertyTestCases))] public void ToAmqpMessageTranslatesDescribedApplicationProperties(object typeDescriptor, object propertyValueRaw, Func propertyValueAccessor) diff --git a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/CHANGELOG.md b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/CHANGELOG.md index 5da5cc0b17f41..2dfa97779e0c9 100755 --- a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/CHANGELOG.md +++ b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/CHANGELOG.md @@ -8,8 +8,12 @@ ### Bugs Fixed +- Fixed an error that prevented relative URIs from being used with [application properties](https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-application-properties) in the `EventData.Properties` collection. + ### Other Changes +- The processor will now refresh the maximum message size each time a new AMQP link is opened; this is necessary for large message support, where the maximum message size for entities can be reconfigured and adjusted on the fly. Because the client had cached the value, it would not be aware of the change and would enforce the wrong size for batch creation. + ## 5.12.0-beta.1 (2024-05-17) ### Features Added diff --git a/sdk/eventhub/Azure.Messaging.EventHubs/CHANGELOG.md b/sdk/eventhub/Azure.Messaging.EventHubs/CHANGELOG.md index 7bbf7830a6103..ea3c5604660ec 100755 --- a/sdk/eventhub/Azure.Messaging.EventHubs/CHANGELOG.md +++ b/sdk/eventhub/Azure.Messaging.EventHubs/CHANGELOG.md @@ -8,9 +8,11 @@ ### Bugs Fixed +- Fixed an error that prevented relative URIs from being used with [application properties](https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-application-properties) in the `EventData.Properties` collection. + ### Other Changes -- The client will now refresh the maximum message size each time a new AMQP link is opened; this is necessary for large message support, where the maximum message size for entities can be reconfigureed adjusted on the fly. Because the client had cached the value, it would not be aware of the change and would enforce the wrong size for batch creation. +- The client will now refresh the maximum message size each time a new AMQP link is opened; this is necessary for large message support, where the maximum message size for entities can be reconfigured and adjusted on the fly. Because the client had cached the value, it would not be aware of the change and would enforce the wrong size for batch creation. - The `PluggableCheckpointStoreEventProcessor` will now emit a diagnostic span when a checkpoint is created/updated. While this span is not defined by the Open Telemetry specification, this change aligns diagnostic spans with those emitted by `EventProcessorClient`. diff --git a/sdk/servicebus/Azure.Messaging.ServiceBus/CHANGELOG.md b/sdk/servicebus/Azure.Messaging.ServiceBus/CHANGELOG.md index 4e5c1ad430792..3d5ef06d332e0 100644 --- a/sdk/servicebus/Azure.Messaging.ServiceBus/CHANGELOG.md +++ b/sdk/servicebus/Azure.Messaging.ServiceBus/CHANGELOG.md @@ -10,6 +10,8 @@ - Fixed an error that caused connection strings using host names without a scheme to fail parsing and be considered invalid. +- Fixed an error that prevented relative URIs from being used with [application properties](https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-application-properties) in the `ServiceBusMessage.ApplicationProperties` and `ServiceBusReceivedMessage.ApplicationProperties` collections. + ### Other Changes - The client will now refresh the maximum message size each time a new AMQP link is opened; this is necessary for large message support, where the maximum message size for entities can be reconfigureed adjusted on the fly. Because the client had cached the value, it would not be aware of the change and would enforce the wrong size for batch creation.