Skip to content

Commit aabaf1f

Browse files
jhartmann123davidroth
authored andcommitted
improvement: Hangfire jobs triggered by the OutOfBand-Decorators now have a better job title which includes the request type name
1 parent 36eca8f commit aabaf1f

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>9.5.1-rc1</Version>
3+
<Version>9.5.2</Version>
44
<TargetFramework>net8.0</TargetFramework>
55
</PropertyGroup>
66

src/Hangfire/src/JobProcessor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
using System.Globalization;
55
using Fusonic.Extensions.Common.Security;
66
using Fusonic.Extensions.Mediator;
7+
using Hangfire;
78
using Hangfire.Server;
89
using SimpleInjector;
910

1011
namespace Fusonic.Extensions.Hangfire;
1112

1213
public class JobProcessor(Container container) : IJobProcessor
1314
{
14-
private readonly Container container = container;
15-
15+
[JobDisplayName("OutOfBand {0}")]
1616
public virtual Task ProcessAsync(MediatorHandlerContext context, PerformContext performContext)
1717
{
1818
if (context.Culture != null)

src/Hangfire/src/MediatorHandlerContext.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,25 @@
66

77
namespace Fusonic.Extensions.Hangfire;
88

9-
public class MediatorHandlerContext(object message, string handlerType)
9+
public class MediatorHandlerContext
1010
{
11-
public object Message { get; set; } = message;
12-
public string HandlerType { get; set; } = handlerType;
11+
public MediatorHandlerContext(object message, string handlerType)
12+
{
13+
Message = message;
14+
HandlerType = handlerType;
15+
16+
var type = Message.GetType();
17+
DisplayName = $"Message: {type.Name} ({type.Namespace})";
18+
}
19+
20+
public object Message { get; set; }
21+
public string HandlerType { get; set; }
1322
public CultureInfo? Culture { get; set; }
1423
public CultureInfo? UiCulture { get; set; }
1524
public HangfireUser? User { get; set; }
25+
public string DisplayName { get; set; }
26+
27+
public override string ToString() => DisplayName;
1628

1729
public class HangfireUser(List<HangfireUser.HangfireUserClaim> claims)
1830
{

0 commit comments

Comments
 (0)