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

Rebus: Trigger event handlers twice #11431

Closed
realLiangshiwei opened this issue Jan 24, 2022 · 1 comment
Closed

Rebus: Trigger event handlers twice #11431

realLiangshiwei opened this issue Jan 24, 2022 · 1 comment
Assignees
Labels
Milestone

Comments

@realLiangshiwei
Copy link
Member

realLiangshiwei commented Jan 24, 2022

Related to: rebus-org/Rebus.ServiceProvider#50

@brunobertechini
Copy link
Contributor

Hello there, I just created a new solution (5.2.2) and added the configuration for Rebus.RabbitMq to test the integration.

I am facing the same issue of my handler being called twice when using Rebus+RabbitMq.

I have no special configuration. A simple event and a simple handler:

PreConfigure<AbpRebusEventBusOptions>(options =>
        {
            var queueName = "eventbus";
            options.InputQueueName = queueName;
            options.Configurer = rebusConfigurer =>
            {
                rebusConfigurer.Transport(t => t.UseRabbitMq("amqp://localhost", queueName));
                // rebusConfigurer.Subscriptions(s => s.UseJsonFile(@"subscriptions.json"));
            };
        });
public class SampleEvent1 : IEvent
{
    [Required]
    public string MyStringProp { get; set; }
    
    [Required]
    public int? MyIntProp { get; set; }
    
    [Required]
    public bool? MyBoolProp { get; set; }
    
    [Required]
    public DateTime? MyDateTimeProp { get; set; }
}
public class SampleEvent1Handler : IDistributedEventHandler<SampleEvent1>, ITransientDependency
{
    private readonly ILogger<SampleEvent1Handler> _logger;
    private readonly IDistributedEventBus _bus;

    public SampleEvent1Handler(ILogger<SampleEvent1Handler> logger, IDistributedEventBus bus)
    {
        _logger = logger;
        _bus = bus;
    }    
    
    public Task HandleEventAsync(SampleEvent1 eventData)
    {
        _logger.LogInformation($"Received Event {eventData.GetType().FullName}");

        var a = _bus;
        
        Thread.Sleep(10000);
        
        _logger.LogInformation($"Finished processing Event {eventData.GetType().FullName}");
        
        return Task.CompletedTask;
    }
}

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

No branches or pull requests

2 participants