Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actor service does not function correctly #60

Closed
Dismissile opened this issue Jul 12, 2017 · 1 comment
Closed

Actor service does not function correctly #60

Dismissile opened this issue Jul 12, 2017 · 1 comment

Comments

@Dismissile
Copy link

Dismissile commented Jul 12, 2017

This is the code for the Actor service:

public async Task StartProcessingAsync(CancellationToken cancellationToken)
{
    try
    {
        // this throws an exception
        this.GetReminder(ReminderName);
            
        // therefore this never gets called
        bool added = await this.StateManager.TryAddStateAsync<long>(StateName, 0);

        if (!added)
        {
            // value already exists, which means processing has already started.
            throw new InvalidOperationException("Processing for this actor has already started.");
        }
    }
    catch (ReminderNotFoundException)
    {
        await this.RegisterReminderAsync(ReminderName, null, TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(10));
    }
}

public async Task ReceiveReminderAsync(string reminderName, byte[] context, TimeSpan dueTime, TimeSpan period)
{
    if (reminderName.Equals(ReminderName, StringComparison.OrdinalIgnoreCase))
    {
        // since TrySetState never gets called -- this will cause an exception
        long currentValue = await this.StateManager.GetStateAsync<long>(StateName);

        ActorEventSource.Current.ActorMessage(this, $"Processing. Current value: {currentValue}");

        await this.StateManager.SetStateAsync<long>(StateName, ++currentValue);
    }
}

The ActorBackendService controller will use the proxy to call this method. GetReminder will throw an exception which will go to the catch block and call RegisterReminderAsync.

Once the reminder is received it tries to use GetState but the state was never initialized because GetReminder threw an exception and skipped the rest of the code.

mikkelhegn pushed a commit that referenced this issue Dec 18, 2017
@mikkelhegn
Copy link
Contributor

Fixed...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants