maciejwalkowiak / implementing-ddd-with-spring-talk

144 stars 52 forks source link

DomainEventListener located under application or Catalog module fails modulith verification with LoanCreated and Closed from Lending module #2

Open paguerre3 opened 2 months ago

paguerre3 commented 2 months ago

@maciejwalkowiak I really enjoyed the Video but where u able to fully test it? Note I like the concepts provided and agree in most of them but checking DomainEventListener located under application or Catalog module fails modulith verification with the Loan Events from Lending module:

Note I logged modules to see further details and I saw no expose, I checked modules dependecies and saw:

Lending

Logical name: lending Base package: library.lending Direct module dependencies: none Spring beans: o ….application.RentBookUseCase o ….application.ReturnBookUseCase o ….domain.LoanRepository

Catalog

Logical name: catalog Base package: library.catalog Direct module dependencies: none Spring beans: o ….application.AddBookToCatalogUseCase o ….application.DomainEventListener o ….application.RegisterBookCopyUseCase o ….domain.BookRepository o ….domain.CopyRepository o ….infrastructure.OpenLibraryBookSearchService

So how can we see LoanCreated and Closed (from Lending Module) in the the Catalog module / application : DomainEventListener if Modulith verification fails because they aren't exposed?

paguerre3 commented 2 months ago

@maciejwalkowiak As a Quick solution I added @NamedInterface in the classes exposed into the Catalog module from Lending module, e.g.:


import org.springframework.modulith.NamedInterface;

@NamedInterface
public record LoanClosed(CopyId copyId) {
}

@maciejwalkowiak Please add me as a collaborator and I can commit the solution if u like or explain a better solution because now i see DO Events from domain of Lending exposed to the aplication Layer of Catalog

Result:

Logical name: lending Base package: library.lending Named interfaces:

  • NamedInterface: name=<>, types=[]
  • NamedInterface: name=domain, types=[ l.d.CopyId, .l.d.LoanClosed, l.d.LoanCreated ]