GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||
GeezerVison is showing github.com — feat(streaming): support compact JSON Azure Queue migration by ReubenBond · Pull Request #10507 · dotnet/orleans Conversation
|
| File | Description |
|---|---|
| test/Extensions/Orleans.Azure.Tests/Streaming/AzureQueueJsonDataAdapterTests.cs | New tests covering JSON/binary behavior, fallback, and legacy message compatibility. |
| src/Azure/Orleans.Streaming.AzureStorage/Providers/Streams/AzureQueue/Json/AzureQueueJsonDataAdapterOptions.cs | New experimental options for adapter preference and fallback behavior. |
| src/Azure/Orleans.Streaming.AzureStorage/Providers/Streams/AzureQueue/IAzureQueueDataAdapter.cs | Adds the experimental JSON adapter implementation and DI factory method. |
| src/Azure/Orleans.Streaming.AzureStorage/Providers/Streams/AzureQueue/AzureQueueStreamBuilder.cs | Adds JSON stream configurator types/extensions for silo and client registration. |
| src/Azure/Orleans.Streaming.AzureStorage/Hosting/SiloBuilderExtensions.cs | Adds AddAzureQueueJsonStreams(...) for silo builder. |
| src/Azure/Orleans.Streaming.AzureStorage/Hosting/ClientBuilderExtensions.cs | Adds AddAzureQueueJsonStreams(...) for client builder. |
| src/api/Azure/Orleans.Streaming.AzureStorage/Orleans.Streaming.AzureStorage.cs | Updates generated API surface for newly introduced experimental APIs. |
Tip
Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
test/Extensions/Orleans.Azure.Tests/Streaming/AzureQueueJsonDataAdapterTests.cs:54
OrleansJsonSerializer with a new OrleansJsonSerializerOptions instance, which bypasses DI post-configuration (ConfigureOrleansJsonSerializerOptions) that wires up Orleans' JSON binder/converters. That can make the tests diverge from real runtime behavior. Prefer using the configured IOptions<OrleansJsonSerializerOptions> from fixture.Services. var serializer = this.fixture.Services.GetRequiredService<Serializer>();
var azureQueueDataAdapterV2 = new AzureQueueDataAdapterV2(serializer);
var jsonOrleansSerializer = new OrleansJsonSerializer(Options.Create(new OrleansJsonSerializerOptions()));
return new AzureQueueJsonDataAdapter(
jsonOrleansSerializer,
fallbackAdapter: azureQueueDataAdapterV2,
options ?? new AzureQueueJsonDataAdapterOptions(),
NullLogger<AzureQueueJsonDataAdapter>.Instance);
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
src/Azure/Orleans.Streaming.AzureStorage/Providers/Streams/AzureQueue/IAzureQueueDataAdapter.cs:145
var eventList = events.ToList();
try
{
return _options.PreferJson
src/Azure/Orleans.Streaming.AzureStorage/Providers/Streams/AzureQueue/IAzureQueueDataAdapter.cs:128
Consider changing the parameter type to IQueueDataAdapter<string, IBatchContainer> (or similar) and updating Create(...), tests, and the generated API surface accordingly.
public AzureQueueJsonDataAdapter(
OrleansJsonSerializer jsonSerializer,
AzureQueueDataAdapterV2 fallbackAdapter,
AzureQueueJsonDataAdapterOptions options,
ILogger<AzureQueueJsonDataAdapter> logger)
src/Azure/Orleans.Streaming.AzureStorage/Providers/Streams/AzureQueue/IAzureQueueDataAdapter.cs:173
public IBatchContainer FromQueueMessage(string cloudMsg, long sequenceId)
{
ArgumentException.ThrowIfNullOrEmpty(cloudMsg, nameof(cloudMsg));
test/Extensions/Orleans.Azure.Tests/Streaming/AzureQueueJsonDataAdapterTests.cs:217
var jsonAdapterNoFallback = InitializeQueueJsonDataAdapter(new AzureQueueJsonDataAdapterOptions { EnableFallback = false });
Assert.ThrowsAny<Exception>(() => jsonAdapterNoFallback.FromQueueMessage(binaryMsg, token.SequenceNumber));
}
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Register provider-keyed JSON adapters with named options, preserve binary fallback behavior, and add generated API plus Orleans 7 binary and Orleans 3 JSON compatibility coverage. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 2cd8574b-4108-4bf5-b49a-4294c21435e1
Co-authored-by: Copilot App <[email protected]> Copilot-Session: 2cd8574b-4108-4bf5-b49a-4294c21435e1
Co-authored-by: Copilot App <[email protected]>
Serialize the migration envelope without Orleans container metadata while preserving allow-listed polymorphic event and request-context graphs. Continue accepting legacy direct-container JSON and binary messages. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 2cd8574b-4108-4bf5-b49a-4294c21435e1
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
src/Azure/Orleans.Streaming.AzureStorage/Providers/Streams/AzureQueue/IAzureQueueDataAdapter.cs:186
catch (Exception ex) when (_options.EnableFallback)
{
if (_options.PreferJson)
{
_logger.LogDebug(ex, "Failed to deserialize cloud message using JSON, falling back to binary deserialization");
src/Azure/Orleans.Streaming.AzureStorage/Providers/Streams/AzureQueue/IAzureQueueDataAdapter.cs:163
This issue also appears on line 182 of the same file.
catch (Exception ex) when (_options.EnableFallback)
{
if (_options.PreferJson)
{
_logger.LogDebug(ex, "JSON serialization failed for stream {StreamId}, falling back to binary serialization", streamId);
src/Azure/Orleans.Streaming.AzureStorage/Providers/Streams/AzureQueue/IAzureQueueDataAdapter.cs:230
var serializedEvents = _jsonSerializer.Serialize(events.Cast<object>().ToList(), typeof(List<object>));
Sorry, something went wrong.
There was an error while loading. Please reload this page.
d0d3a09 to
a1ddb62
Compare
Co-authored-by: Copilot App <[email protected]> Copilot-Session: 2cd8574b-4108-4bf5-b49a-4294c21435e1
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
src/Azure/Orleans.Streaming.AzureStorage/Providers/Streams/AzureQueue/IAzureQueueDataAdapter.cs:192
FromQueueMessage falls back to binary on any exception when EnableFallback is true. This can hide meaningful JSON errors (for example, an unsupported compact-envelope version) and rethrow a FormatException from Convert.FromBase64String instead, making diagnosis harder and potentially masking forward-compatibility errors. Consider only falling back to binary when the failure indicates the payload is not valid JSON / not JSON-deserializable (JSON exceptions), and rethrow other errors. }
catch (Exception ex) when (_options.EnableFallback)
{
if (_options.PreferJson)
{
src/Azure/Orleans.Streaming.AzureStorage/Providers/Streams/AzureQueue/IAzureQueueDataAdapter.cs:310
TryDeserializeCompactJson currently requires requestContext to be present and a JSON object. However, AzureQueueBatchContainerV2 supports a null request-context (Dictionary<string, object>?) and compact envelopes coming from other producers could reasonably use null (or omit the property) when no request context is present. With the current code, such messages will throw and (with fallback enabled) may surface as a base64 error instead of being handled as an empty/null request context. {
throw new InvalidDataException("The Azure Queue JSON envelope property 'namespace' must be a String or Null.");
}
var keyElement = GetRequiredProperty(streamElement, "key", JsonValueKind.String);
src/Azure/Orleans.Streaming.AzureStorage/Providers/Streams/AzureQueue/IAzureQueueDataAdapter.cs:164
ToQueueMessage eagerly materializes events into a List<T> even when PreferJson is false and no fallback is needed. This adds an avoidable allocation/iteration on the binary-preferred path. Deferring the ToList() until the JSON path (or until a fallback is actually required) keeps the common case cheaper. /// </summary>
public string ToQueueMessage<T>(StreamId streamId, IEnumerable<T> events, StreamSequenceToken? token, Dictionary<string, object>? requestContext)
{
var eventList = events.ToList();
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
src/Azure/Orleans.Streaming.AzureStorage/Providers/Streams/AzureQueue/IAzureQueueDataAdapter.cs:193
FromQueueMessage falls back to the binary adapter for any JSON deserialization exception when PreferJson=true. If the payload is valid JSON but indicates an unsupported envelope version (or otherwise fails JSON parsing/validation), the fallback path will attempt Convert.FromBase64String and typically throw a FormatException, obscuring the real error. Consider skipping binary fallback when the message is clearly JSON so that meaningful JSON errors (like unsupported version) are preserved. catch (Exception ex) when (_options.EnableFallback)
{
if (_options.PreferJson)
{
_logger.LogDebug(ex, "Failed to deserialize cloud message using JSON, falling back to binary deserialization");
src/Azure/Orleans.Streaming.AzureStorage/Providers/Streams/AzureQueue/IAzureQueueDataAdapter.cs:133
AzureQueueJsonDataAdapter constructor takes a concrete AzureQueueDataAdapterV2 as fallbackAdapter, but the implementation stores it as IQueueDataAdapter<string, IBatchContainer>. Taking the interface in the public API makes the adapter easier to test/extend and avoids unnecessarily coupling callers to the built-in binary adapter type. public AzureQueueJsonDataAdapter(
OrleansJsonSerializer jsonSerializer,
AzureQueueDataAdapterV2 fallbackAdapter,
AzureQueueJsonDataAdapterOptions options,
ILogger<AzureQueueJsonDataAdapter> logger)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Co-authored-by: Copilot App <[email protected]> Copilot-Session: 2cd8574b-4108-4bf5-b49a-4294c21435e1
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.