GithubHelp home page GithubHelp logo

Comments (12)

jamesmh avatar jamesmh commented on May 20, 2024

Thanks for all the details! I've run into this before so I know where it's happening but will need to figure out why....

Could you share the general shape of your PurchaseCreatedEvent? (just the method signatures)

Also:

  • is the PurchaseCreatedEvent in the same project as your web or executable project?
  • if not, what type of project is it (.NET Standard 2.0?, etc.)

from coravel.

khabubu avatar khabubu commented on May 20, 2024

Thank you for the quick replay. The shape of the PurchaseCreatedEvent is

public class PurchaseCreatedEvent : IEvent
    {
        public Organisation Organisation { get; set; }

        public Purchase Purchase { get; set; }

        public PurchaseCreatedEvent(Organisation organisation, Purchase purchase)
        {
            Organisation = organisation;
            Purchase = purchase;
        }
    }
  1. It is in the same project.

from coravel.

jamesmh avatar jamesmh commented on May 20, 2024

What do your listeners look like? Are they in the same project also?

from coravel.

khabubu avatar khabubu commented on May 20, 2024

The listener(s) are in the same project as illustrated below

public class PurchaseCreatedListener : IListener<PurchaseCreatedEvent>
    {
        private readonly ApplicationDbContext _context;

        public PurchaseCreatedListener(ApplicationDbContext context)
        {
            _context = context;
        }

        public async Task HandleAsync(PurchaseCreatedEvent broadcasted)
        {
            // Ommitted lines for brevity.
        }
    }

I am not sure if I have configured events and queues below as show below

var provider = app.ApplicationServices;
var registration = provider.ConfigureEvents();
registration.Register<PurchaseCreatedEvent>()
    .Subscribe<PurchaseCreatedListener>();
provider.ConfigureQueue().LogQueuedTaskProgress(provider.GetService<ILogger<IQueue>>())
    .OnError(e => { // Ommited for brevity });

I hope I have provide enough information.

from coravel.

jamesmh avatar jamesmh commented on May 20, 2024

Awesome. I forgot to ask (sorry!) - what version of Coravel are you using?

from coravel.

khabubu avatar khabubu commented on May 20, 2024

Version 2.3.1

from coravel.

jamesmh avatar jamesmh commented on May 20, 2024

Great. I'll try to get to this in the new couple days.

from coravel.

jamesmh avatar jamesmh commented on May 20, 2024

Quick question: Did you register your listeners with AddTransient or AddScoped?

from coravel.

khabubu avatar khabubu commented on May 20, 2024

No I didn't register with either. I think that is my issue. Let me try registering it. Ohh is this the proper way to register a listener

services.AddTransient<IListener<PurchaseCreatedEvent>, PurchaseCreatedListener>();

I had registered the listeners and events as follow

var provider = app.ApplicationServices;
var registration = provider.ConfigureEvents();
registration.Register<PurchaseCreatedEvent>()
                .Subscribe<PurchaseCreatedListener>();

from coravel.

jamesmh avatar jamesmh commented on May 20, 2024

You can just do services.AddTransient<PurchaseCreatedListener>() - does that fix your issues?

from coravel.

khabubu avatar khabubu commented on May 20, 2024

Yes it does. Thank you very much.
PS : I feel stupid now. Thanks again

from coravel.

jamesmh avatar jamesmh commented on May 20, 2024

hahaha! Don't worry about it. Glad everything is working now 👍

from coravel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.