Specified method is not supported Exception #6907
-
Hello there, Orleans newbie here. I'm trying to implement a method to list the event history on a JournaledGrain. public class OrderGrain : JournaledGrain<OrderState, OrderEventBase>, IOrderGrain
{
public async Task<OrderState> Cancel(OrderCancelRequest request)
{
RaiseEvent(new OrderCanceledEvent(request));
await ConfirmEvents();
return State;
}
public async Task<OrderState> Create(OrderCreateRequest request)
{
RaiseEvent(new OrderCreatedEvent(request));
await ConfirmEvents();
return State;
}
public Task<OrderStatus> GetStatus()
{
return Task.FromResult(State.Status);
}
public async Task<IReadOnlyList<OrderEventBase>> GetEventHistory()
{
// ↓↓↓ The silo throws the "Specified method is not supported" exception
return await RetrieveConfirmedEvents(0, Version);
}
} Usage: private async Task OrderDemo()
{
var orderId = Guid.NewGuid();
var customerId = Guid.NewGuid();
var request = new OrderCreateRequest(Guid.Empty, "Choripanes MID", "XXXX", DateTime.Now, customerId, "dave", GetProducts());
var order = _client.GetGrain<IOrderGrain>(orderId);
await order.Create(request);
Console.WriteLine($"{DateTime.Now}-{await order.GetStatus()}");
var cancelRequest = new OrderCancelRequest(Guid.Empty, DateTime.Now, CancelationReason.CustomerCanceled, "I don't want it anymore");
await order.Cancel(cancelRequest);
Console.WriteLine($"{DateTime.Now}-{await order.GetStatus()}");
var events = await order.GetEventHistory();
Console.WriteLine($"Got {events.Count} events!");
foreach (var e in events)
{
if (e is OrderCanceledEvent canceled)
Console.WriteLine($"Canceled by {canceled.CanceledInfo.CanceledBy}");
else if (e is OrderCreatedEvent created)
Console.WriteLine($"Created in {created.LocationId}");
else
Console.WriteLine("Unknown typed event");
}
} I'm using Orleans 3.4. This code is base on one example I found in the web. |
Beta Was this translation helpful? Give feedback.
Answered by
ReubenBond
Jan 22, 2021
Replies: 1 comment 2 replies
-
@DavidIllescas if you add the LogConsistencyProvider to the OrderGrain [LogConsistencyProvider(ProviderName = "LogStorage")]
public class OrderGrain : JournaledGrain<OrderState, OrderEventBase>, IOrderGrain and then register the .AddLogStorageBasedLogConsistencyProvider("LogStorage")
.ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(HelloGrain).Assembly).WithReferences())
// .AddMemoryGrainStorage("Default")
.AddLogStorageBasedLogConsistencyProvider("LogStorage")
.AddMemoryGrainStorageAsDefault(); it looks like it works. I get 2 events. @DavidIllescas as explained here: https://dotnet.github.io/orleans/docs/grains/event_sourcing/event_sourcing_configuration.html |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
dave-zz
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@rallets explained in Gitter
@DavidIllescas if you add the LogConsistencyProvider to the OrderGrain
and then register the
LogConsistencyProvider
it looks like it works. I get 2 events.
@DavidIllescas as explained here: https://dotnet.github.io/orleans/docs/grains/event…