MapDaprScheduledJobHandler not working with AppCallback MapGrpcService registration
- Dominant language
- C#
- Stars
- 1.2k
- Forks
- 378
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 6
Description
## Expected Behavior
When a scheduled job triggers, even using AppCallback.AppCallbackBase to receive pubsub events, the delegate passed to `MapDaprScheduledJobHandler` should execute and receive the job payload.
I'm using `MapDaprScheduledJobHandler` because is the recommended way to do it using the `Dapr.Jobs` .NET package, while i'm using `AppCallback.AppCallbackBase` to receive and handle dynamic events implementations (subscribed using the YAML subscribe)
```csharp
foreach (ISubscriberService subscriberService in _serviceProvider.GetKeyedServices(KeyedService.AnyKey))
{
if (!subscriberService.IsTopicMatched(request.Path))
{
continue;
}
string cloudEventJson = request.Data.ToStringUtf8();
return await subscriberService.OnTopicEventAsync(request.Path, cloudEventJson, cancellationToken);
}
```
## Actual Behavior
I have a registered service with MapGrpcService that implements AppCallback.AppCallbackBase and in `Program.cs` I'm also using `MapDaprScheduledJobHandler` for catching the job schedule.
When the job triggers the schedule never invoked the action inside the `MapDaprScheduledJobHandler `, instead the app logs show:
```sh
info: Grpc.AspNetCore.Server.Internal.ServerCallHandlerFactory[2]
Method 'OnJobEvent' is unimplemented.
info: Grpc.AspNetCore.Server.Internal.ServerCallHandlerFactory[1]
Service 'dapr.proto.runtime.v1.AppCallbackAlpha' is unimplemented.
```
I also noticed that in the [dapr runtime proto](https://github.com/dapr/dapr/blob/master/pkg/proto/runtime/v1/appcallback_grpc.pb.go#L42) there's the `OnJobEvent` method added to the stable proto file, together with the Alpha one in it's file.
## Steps to Reproduce the Problem
Using the latest version of the Dapr SDK for .NET and runtime
```csharp
builder.Services.AddDaprJobsClient(lifetime: ServiceLifetime.Scoped);
// ...
var app = builder.Build();
app.MapDaprScheduledJobHandler(async (string jobName, ReadOnlyMemory payload, ILogger logger, CancellationToken cancellationToken = default) =>
{
logger.LogInformation("Received trigger invocation for job '{jobName}'", jobName);
string cloudEvent = Encoding.UTF8.GetString(payload.Span);
return Task.CompletedTask;
});
// Implements AppCallback.AppCallbackBase for receiving pub sub events
app.MapGrpcService();
await app.RunAsync();
```
## Release Note
Could it be fixed in the 1.18 version, please?
Contributor guide
Research direction
Start in Program.cs with the interaction between MapDaprScheduledJobHandler and MapGrpcService. Reproduce the scheduled job and inspect the gRPC logs for the unimplemented OnJobEvent and AppCallbackAlpha methods. Done means the scheduled handler delegate receives the job name and payload while AppCallback continues handling pub/sub events.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, grpc
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100