mirror of
https://github.com/gotson/komga.git
synced 2026-05-08 12:35:30 +02:00
refactor(komga): replace Artemis with Spring events for domain event publishing
This commit is contained in:
parent
487b43967d
commit
545a31401a
22 changed files with 56 additions and 87 deletions
|
|
@ -0,0 +1,19 @@
|
|||
package org.gotson.komga.application.events
|
||||
|
||||
import org.springframework.context.annotation.Bean
|
||||
import org.springframework.context.annotation.Configuration
|
||||
import org.springframework.context.event.ApplicationEventMulticaster
|
||||
import org.springframework.context.event.SimpleApplicationEventMulticaster
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
|
||||
|
||||
@Configuration
|
||||
class AsynchronousSpringEventsConfig(
|
||||
private val taskExecutor: ThreadPoolTaskExecutor,
|
||||
) {
|
||||
@Bean("applicationEventMulticaster")
|
||||
fun simpleApplicationEventMulticaster(): ApplicationEventMulticaster {
|
||||
val eventMulticaster = SimpleApplicationEventMulticaster()
|
||||
eventMulticaster.setTaskExecutor(taskExecutor)
|
||||
return eventMulticaster
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
package org.gotson.komga.application.events
|
||||
|
||||
import jakarta.jms.ConnectionFactory
|
||||
import org.gotson.komga.domain.model.DomainEvent
|
||||
import org.gotson.komga.infrastructure.jms.JMS_PROPERTY_TYPE
|
||||
import org.gotson.komga.infrastructure.jms.TOPIC_EVENTS
|
||||
import org.springframework.jms.core.JmsTemplate
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
class EventPublisher(
|
||||
connectionFactory: ConnectionFactory,
|
||||
) {
|
||||
private val jmsTemplate = JmsTemplate(connectionFactory).apply {
|
||||
isPubSubDomain = true
|
||||
}
|
||||
|
||||
fun publishEvent(event: DomainEvent) {
|
||||
jmsTemplate.convertAndSend(TOPIC_EVENTS, event) {
|
||||
it.apply {
|
||||
setStringProperty(JMS_PROPERTY_TYPE, event.javaClass.simpleName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,6 @@ import mu.KotlinLogging
|
|||
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry
|
||||
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream
|
||||
import org.apache.commons.io.FilenameUtils
|
||||
import org.gotson.komga.application.events.EventPublisher
|
||||
import org.gotson.komga.domain.model.Book
|
||||
import org.gotson.komga.domain.model.BookConversionException
|
||||
import org.gotson.komga.domain.model.BookWithMedia
|
||||
|
|
@ -21,6 +20,7 @@ import org.gotson.komga.domain.persistence.HistoricalEventRepository
|
|||
import org.gotson.komga.domain.persistence.LibraryRepository
|
||||
import org.gotson.komga.domain.persistence.MediaRepository
|
||||
import org.gotson.komga.language.notEquals
|
||||
import org.springframework.context.ApplicationEventPublisher
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.transaction.support.TransactionTemplate
|
||||
import java.io.FileNotFoundException
|
||||
|
|
@ -46,7 +46,7 @@ class BookConverter(
|
|||
private val mediaRepository: MediaRepository,
|
||||
private val libraryRepository: LibraryRepository,
|
||||
private val transactionTemplate: TransactionTemplate,
|
||||
private val eventPublisher: EventPublisher,
|
||||
private val eventPublisher: ApplicationEventPublisher,
|
||||
private val historicalEventRepository: HistoricalEventRepository,
|
||||
) {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package org.gotson.komga.domain.service
|
||||
|
||||
import mu.KotlinLogging
|
||||
import org.gotson.komga.application.events.EventPublisher
|
||||
import org.gotson.komga.application.tasks.TaskEmitter
|
||||
import org.gotson.komga.domain.model.Book
|
||||
import org.gotson.komga.domain.model.CodedException
|
||||
|
|
@ -22,6 +21,7 @@ import org.gotson.komga.domain.persistence.ReadListRepository
|
|||
import org.gotson.komga.domain.persistence.ReadProgressRepository
|
||||
import org.gotson.komga.domain.persistence.SidecarRepository
|
||||
import org.gotson.komga.language.toIndexedMap
|
||||
import org.springframework.context.ApplicationEventPublisher
|
||||
import org.springframework.stereotype.Service
|
||||
import java.io.FileNotFoundException
|
||||
import java.nio.file.FileAlreadyExistsException
|
||||
|
|
@ -56,7 +56,7 @@ class BookImporter(
|
|||
private val readListRepository: ReadListRepository,
|
||||
private val libraryRepository: LibraryRepository,
|
||||
private val sidecarRepository: SidecarRepository,
|
||||
private val eventPublisher: EventPublisher,
|
||||
private val eventPublisher: ApplicationEventPublisher,
|
||||
private val taskEmitter: TaskEmitter,
|
||||
private val historicalEventRepository: HistoricalEventRepository,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package org.gotson.komga.domain.service
|
||||
|
||||
import mu.KotlinLogging
|
||||
import org.gotson.komga.application.events.EventPublisher
|
||||
import org.gotson.komga.domain.model.Book
|
||||
import org.gotson.komga.domain.model.BookAction
|
||||
import org.gotson.komga.domain.model.BookPageContent
|
||||
|
|
@ -28,6 +27,7 @@ import org.gotson.komga.infrastructure.configuration.KomgaSettingsProvider
|
|||
import org.gotson.komga.infrastructure.hash.Hasher
|
||||
import org.gotson.komga.infrastructure.image.ImageConverter
|
||||
import org.gotson.komga.infrastructure.image.ImageType
|
||||
import org.springframework.context.ApplicationEventPublisher
|
||||
import org.springframework.data.domain.Sort
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.transaction.support.TransactionTemplate
|
||||
|
|
@ -53,7 +53,7 @@ class BookLifecycle(
|
|||
private val libraryRepository: LibraryRepository,
|
||||
private val bookAnalyzer: BookAnalyzer,
|
||||
private val imageConverter: ImageConverter,
|
||||
private val eventPublisher: EventPublisher,
|
||||
private val eventPublisher: ApplicationEventPublisher,
|
||||
private val transactionTemplate: TransactionTemplate,
|
||||
private val hasher: Hasher,
|
||||
private val historicalEventRepository: HistoricalEventRepository,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package org.gotson.komga.domain.service
|
||||
|
||||
import mu.KotlinLogging
|
||||
import org.gotson.komga.application.events.EventPublisher
|
||||
import org.gotson.komga.domain.model.Book
|
||||
import org.gotson.komga.domain.model.BookMetadataPatch
|
||||
import org.gotson.komga.domain.model.BookMetadataPatchCapability
|
||||
|
|
@ -14,6 +13,7 @@ import org.gotson.komga.domain.persistence.LibraryRepository
|
|||
import org.gotson.komga.domain.persistence.MediaRepository
|
||||
import org.gotson.komga.domain.persistence.ReadListRepository
|
||||
import org.gotson.komga.infrastructure.metadata.BookMetadataProvider
|
||||
import org.springframework.context.ApplicationEventPublisher
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
private val logger = KotlinLogging.logger {}
|
||||
|
|
@ -27,7 +27,7 @@ class BookMetadataLifecycle(
|
|||
private val libraryRepository: LibraryRepository,
|
||||
private val readListRepository: ReadListRepository,
|
||||
private val readListLifecycle: ReadListLifecycle,
|
||||
private val eventPublisher: EventPublisher,
|
||||
private val eventPublisher: ApplicationEventPublisher,
|
||||
) {
|
||||
|
||||
fun refreshMetadata(book: Book, capabilities: Set<BookMetadataPatchCapability>) {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import mu.KotlinLogging
|
|||
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry
|
||||
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream
|
||||
import org.apache.commons.io.FilenameUtils
|
||||
import org.gotson.komga.application.events.EventPublisher
|
||||
import org.gotson.komga.domain.model.Book
|
||||
import org.gotson.komga.domain.model.BookAction
|
||||
import org.gotson.komga.domain.model.BookConversionException
|
||||
|
|
@ -23,6 +22,7 @@ import org.gotson.komga.domain.persistence.LibraryRepository
|
|||
import org.gotson.komga.domain.persistence.MediaRepository
|
||||
import org.gotson.komga.domain.persistence.PageHashRepository
|
||||
import org.gotson.komga.language.notEquals
|
||||
import org.springframework.context.ApplicationEventPublisher
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.transaction.support.TransactionTemplate
|
||||
import java.io.File
|
||||
|
|
@ -45,7 +45,7 @@ class BookPageEditor(
|
|||
private val libraryRepository: LibraryRepository,
|
||||
private val pageHashRepository: PageHashRepository,
|
||||
private val transactionTemplate: TransactionTemplate,
|
||||
private val eventPublisher: EventPublisher,
|
||||
private val eventPublisher: ApplicationEventPublisher,
|
||||
private val historicalEventRepository: HistoricalEventRepository,
|
||||
) {
|
||||
private val convertibleTypes = listOf(MediaType.ZIP.type)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package org.gotson.komga.domain.service
|
||||
|
||||
import mu.KotlinLogging
|
||||
import org.gotson.komga.application.events.EventPublisher
|
||||
import org.gotson.komga.domain.model.DomainEvent
|
||||
import org.gotson.komga.domain.model.KomgaUser
|
||||
import org.gotson.komga.domain.model.UserEmailAlreadyExistsException
|
||||
|
|
@ -9,6 +8,7 @@ import org.gotson.komga.domain.persistence.AuthenticationActivityRepository
|
|||
import org.gotson.komga.domain.persistence.KomgaUserRepository
|
||||
import org.gotson.komga.domain.persistence.ReadProgressRepository
|
||||
import org.gotson.komga.infrastructure.security.KomgaPrincipal
|
||||
import org.springframework.context.ApplicationEventPublisher
|
||||
import org.springframework.security.core.session.SessionRegistry
|
||||
import org.springframework.security.crypto.password.PasswordEncoder
|
||||
import org.springframework.stereotype.Service
|
||||
|
|
@ -24,7 +24,7 @@ class KomgaUserLifecycle(
|
|||
private val passwordEncoder: PasswordEncoder,
|
||||
private val sessionRegistry: SessionRegistry,
|
||||
private val transactionTemplate: TransactionTemplate,
|
||||
private val eventPublisher: EventPublisher,
|
||||
private val eventPublisher: ApplicationEventPublisher,
|
||||
) {
|
||||
|
||||
fun updatePassword(user: KomgaUser, newPassword: String, expireSessions: Boolean) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package org.gotson.komga.domain.service
|
||||
|
||||
import mu.KotlinLogging
|
||||
import org.gotson.komga.application.events.EventPublisher
|
||||
import org.gotson.komga.application.tasks.TaskEmitter
|
||||
import org.gotson.komga.domain.model.Book
|
||||
import org.gotson.komga.domain.model.BookMetadataPatchCapability
|
||||
|
|
@ -29,6 +28,7 @@ import org.gotson.komga.infrastructure.configuration.KomgaSettingsProvider
|
|||
import org.gotson.komga.infrastructure.hash.Hasher
|
||||
import org.gotson.komga.language.notEquals
|
||||
import org.gotson.komga.language.toIndexedMap
|
||||
import org.springframework.context.ApplicationEventPublisher
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.transaction.support.TransactionTemplate
|
||||
import java.nio.file.Paths
|
||||
|
|
@ -59,7 +59,7 @@ class LibraryContentLifecycle(
|
|||
private val readProgressRepository: ReadProgressRepository,
|
||||
private val collectionRepository: SeriesCollectionRepository,
|
||||
private val thumbnailBookRepository: ThumbnailBookRepository,
|
||||
private val eventPublisher: EventPublisher,
|
||||
private val eventPublisher: ApplicationEventPublisher,
|
||||
) {
|
||||
|
||||
fun scanRootFolder(library: Library, scanDeep: Boolean = false) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package org.gotson.komga.domain.service
|
||||
|
||||
import mu.KotlinLogging
|
||||
import org.gotson.komga.application.events.EventPublisher
|
||||
import org.gotson.komga.application.scheduler.LibraryScanScheduler
|
||||
import org.gotson.komga.application.tasks.TaskEmitter
|
||||
import org.gotson.komga.domain.model.DirectoryNotFoundException
|
||||
|
|
@ -12,6 +11,7 @@ import org.gotson.komga.domain.model.PathContainedInPath
|
|||
import org.gotson.komga.domain.persistence.LibraryRepository
|
||||
import org.gotson.komga.domain.persistence.SeriesRepository
|
||||
import org.gotson.komga.domain.persistence.SidecarRepository
|
||||
import org.springframework.context.ApplicationEventPublisher
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.transaction.support.TransactionTemplate
|
||||
import java.io.FileNotFoundException
|
||||
|
|
@ -26,7 +26,7 @@ class LibraryLifecycle(
|
|||
private val seriesRepository: SeriesRepository,
|
||||
private val sidecarRepository: SidecarRepository,
|
||||
private val taskEmitter: TaskEmitter,
|
||||
private val eventPublisher: EventPublisher,
|
||||
private val eventPublisher: ApplicationEventPublisher,
|
||||
private val transactionTemplate: TransactionTemplate,
|
||||
private val libraryScanScheduler: LibraryScanScheduler,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package org.gotson.komga.domain.service
|
||||
|
||||
import mu.KotlinLogging
|
||||
import org.gotson.komga.application.events.EventPublisher
|
||||
import org.gotson.komga.domain.model.DomainEvent
|
||||
import org.gotson.komga.domain.model.DuplicateNameException
|
||||
import org.gotson.komga.domain.model.ReadList
|
||||
|
|
@ -11,6 +10,7 @@ import org.gotson.komga.domain.persistence.ReadListRepository
|
|||
import org.gotson.komga.domain.persistence.ThumbnailReadListRepository
|
||||
import org.gotson.komga.infrastructure.image.MosaicGenerator
|
||||
import org.gotson.komga.infrastructure.metadata.comicrack.ReadListProvider
|
||||
import org.springframework.context.ApplicationEventPublisher
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.transaction.support.TransactionTemplate
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ class ReadListLifecycle(
|
|||
private val mosaicGenerator: MosaicGenerator,
|
||||
private val readListMatcher: ReadListMatcher,
|
||||
private val readListProvider: ReadListProvider,
|
||||
private val eventPublisher: EventPublisher,
|
||||
private val eventPublisher: ApplicationEventPublisher,
|
||||
private val transactionTemplate: TransactionTemplate,
|
||||
) {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package org.gotson.komga.domain.service
|
||||
|
||||
import mu.KotlinLogging
|
||||
import org.gotson.komga.application.events.EventPublisher
|
||||
import org.gotson.komga.domain.model.DomainEvent
|
||||
import org.gotson.komga.domain.model.DuplicateNameException
|
||||
import org.gotson.komga.domain.model.SeriesCollection
|
||||
|
|
@ -9,6 +8,7 @@ import org.gotson.komga.domain.model.ThumbnailSeriesCollection
|
|||
import org.gotson.komga.domain.persistence.SeriesCollectionRepository
|
||||
import org.gotson.komga.domain.persistence.ThumbnailSeriesCollectionRepository
|
||||
import org.gotson.komga.infrastructure.image.MosaicGenerator
|
||||
import org.springframework.context.ApplicationEventPublisher
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.transaction.support.TransactionTemplate
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ class SeriesCollectionLifecycle(
|
|||
private val thumbnailSeriesCollectionRepository: ThumbnailSeriesCollectionRepository,
|
||||
private val seriesLifecycle: SeriesLifecycle,
|
||||
private val mosaicGenerator: MosaicGenerator,
|
||||
private val eventPublisher: EventPublisher,
|
||||
private val eventPublisher: ApplicationEventPublisher,
|
||||
private val transactionTemplate: TransactionTemplate,
|
||||
) {
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package org.gotson.komga.domain.service
|
|||
|
||||
import mu.KotlinLogging
|
||||
import net.greypanther.natsort.CaseInsensitiveSimpleNaturalComparator
|
||||
import org.gotson.komga.application.events.EventPublisher
|
||||
import org.gotson.komga.application.tasks.TaskEmitter
|
||||
import org.gotson.komga.domain.model.Book
|
||||
import org.gotson.komga.domain.model.BookMetadata
|
||||
|
|
@ -30,6 +29,7 @@ import org.gotson.komga.domain.persistence.SeriesMetadataRepository
|
|||
import org.gotson.komga.domain.persistence.SeriesRepository
|
||||
import org.gotson.komga.domain.persistence.ThumbnailSeriesRepository
|
||||
import org.gotson.komga.language.stripAccents
|
||||
import org.springframework.context.ApplicationEventPublisher
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.transaction.support.TransactionTemplate
|
||||
import java.io.File
|
||||
|
|
@ -58,7 +58,7 @@ class SeriesLifecycle(
|
|||
private val collectionRepository: SeriesCollectionRepository,
|
||||
private val readProgressRepository: ReadProgressRepository,
|
||||
private val taskEmitter: TaskEmitter,
|
||||
private val eventPublisher: EventPublisher,
|
||||
private val eventPublisher: ApplicationEventPublisher,
|
||||
private val transactionTemplate: TransactionTemplate,
|
||||
private val historicalEventRepository: HistoricalEventRepository,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package org.gotson.komga.domain.service
|
||||
|
||||
import mu.KotlinLogging
|
||||
import org.gotson.komga.application.events.EventPublisher
|
||||
import org.gotson.komga.domain.model.BookWithMedia
|
||||
import org.gotson.komga.domain.model.DomainEvent
|
||||
import org.gotson.komga.domain.model.MetadataPatchTarget
|
||||
|
|
@ -18,6 +17,7 @@ import org.gotson.komga.domain.persistence.SeriesMetadataRepository
|
|||
import org.gotson.komga.infrastructure.metadata.SeriesMetadataFromBookProvider
|
||||
import org.gotson.komga.infrastructure.metadata.SeriesMetadataProvider
|
||||
import org.gotson.komga.language.mostFrequent
|
||||
import org.springframework.context.ApplicationEventPublisher
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
private val logger = KotlinLogging.logger {}
|
||||
|
|
@ -36,7 +36,7 @@ class SeriesMetadataLifecycle(
|
|||
private val bookRepository: BookRepository,
|
||||
private val collectionRepository: SeriesCollectionRepository,
|
||||
private val collectionLifecycle: SeriesCollectionLifecycle,
|
||||
private val eventPublisher: EventPublisher,
|
||||
private val eventPublisher: ApplicationEventPublisher,
|
||||
) {
|
||||
|
||||
fun refreshMetadata(series: Series) {
|
||||
|
|
|
|||
|
|
@ -17,11 +17,9 @@ private val logger = KotlinLogging.logger {}
|
|||
const val QUEUE_UNIQUE_ID = "unique_id"
|
||||
|
||||
const val QUEUE_TASKS = "tasks.background"
|
||||
const val TOPIC_EVENTS = "domain.events"
|
||||
|
||||
const val JMS_PROPERTY_TYPE = "type"
|
||||
|
||||
const val TOPIC_FACTORY = "topicJmsListenerContainerFactory"
|
||||
const val QUEUE_FACTORY = "queueJmsListenerContainerFactory"
|
||||
|
||||
@Configuration
|
||||
|
|
@ -43,25 +41,9 @@ class ArtemisConfig : ArtemisConfigurationCustomizer {
|
|||
.setLastValueKey(QUEUE_UNIQUE_ID)
|
||||
.setRoutingType(RoutingType.ANYCAST),
|
||||
)
|
||||
it.addQueueConfiguration(
|
||||
QueueConfiguration(TOPIC_EVENTS)
|
||||
.setAddress(TOPIC_EVENTS)
|
||||
.setRoutingType(RoutingType.MULTICAST),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Bean(TOPIC_FACTORY)
|
||||
fun topicJmsListenerContainerFactory(
|
||||
connectionFactory: ConnectionFactory,
|
||||
configurer: DefaultJmsListenerContainerFactoryConfigurer,
|
||||
): DefaultJmsListenerContainerFactory =
|
||||
DefaultJmsListenerContainerFactory().apply {
|
||||
configurer.configure(this, connectionFactory)
|
||||
setErrorHandler { logger.warn { it.message } }
|
||||
setPubSubDomain(true)
|
||||
}
|
||||
|
||||
@Bean(QUEUE_FACTORY)
|
||||
fun queueJmsListenerContainerFactory(
|
||||
connectionFactory: ConnectionFactory,
|
||||
|
|
|
|||
|
|
@ -10,16 +10,14 @@ import org.gotson.komga.domain.model.SeriesCollection
|
|||
import org.gotson.komga.domain.model.SeriesSearchWithReadProgress
|
||||
import org.gotson.komga.domain.persistence.ReadListRepository
|
||||
import org.gotson.komga.domain.persistence.SeriesCollectionRepository
|
||||
import org.gotson.komga.infrastructure.jms.TOPIC_EVENTS
|
||||
import org.gotson.komga.infrastructure.jms.TOPIC_FACTORY
|
||||
import org.gotson.komga.interfaces.api.persistence.BookDtoRepository
|
||||
import org.gotson.komga.interfaces.api.persistence.SeriesDtoRepository
|
||||
import org.gotson.komga.interfaces.api.rest.dto.BookDto
|
||||
import org.gotson.komga.interfaces.api.rest.dto.SeriesDto
|
||||
import org.springframework.context.event.EventListener
|
||||
import org.springframework.data.domain.Page
|
||||
import org.springframework.data.domain.PageRequest
|
||||
import org.springframework.data.domain.Pageable
|
||||
import org.springframework.jms.annotation.JmsListener
|
||||
import org.springframework.stereotype.Component
|
||||
import kotlin.math.ceil
|
||||
import kotlin.time.measureTime
|
||||
|
|
@ -80,7 +78,7 @@ class SearchIndexLifecycle(
|
|||
}
|
||||
}
|
||||
|
||||
@JmsListener(destination = TOPIC_EVENTS, containerFactory = TOPIC_FACTORY)
|
||||
@EventListener
|
||||
fun consumeEvents(event: DomainEvent) {
|
||||
when (event) {
|
||||
is DomainEvent.SeriesAdded -> seriesDtoRepository.findByIdOrNull(event.series.id, "unused")?.toDocument()?.let { addEntity(it) }
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse
|
|||
import jakarta.validation.Valid
|
||||
import mu.KotlinLogging
|
||||
import org.apache.commons.io.IOUtils
|
||||
import org.gotson.komga.application.events.EventPublisher
|
||||
import org.gotson.komga.application.tasks.HIGHEST_PRIORITY
|
||||
import org.gotson.komga.application.tasks.HIGH_PRIORITY
|
||||
import org.gotson.komga.application.tasks.LOWEST_PRIORITY
|
||||
|
|
@ -69,6 +68,7 @@ import org.gotson.komga.interfaces.api.rest.dto.ThumbnailBookDto
|
|||
import org.gotson.komga.interfaces.api.rest.dto.patch
|
||||
import org.gotson.komga.interfaces.api.rest.dto.restrictUrl
|
||||
import org.gotson.komga.interfaces.api.rest.dto.toDto
|
||||
import org.springframework.context.ApplicationEventPublisher
|
||||
import org.springframework.core.io.FileSystemResource
|
||||
import org.springframework.data.domain.Page
|
||||
import org.springframework.data.domain.PageRequest
|
||||
|
|
@ -125,7 +125,7 @@ class BookController(
|
|||
private val readListRepository: ReadListRepository,
|
||||
private val contentDetector: ContentDetector,
|
||||
private val imageAnalyzer: ImageAnalyzer,
|
||||
private val eventPublisher: EventPublisher,
|
||||
private val eventPublisher: ApplicationEventPublisher,
|
||||
private val thumbnailBookRepository: ThumbnailBookRepository,
|
||||
private val imageConverter: ImageConverter,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import org.apache.commons.compress.archivers.zip.Zip64Mode
|
|||
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry
|
||||
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream
|
||||
import org.apache.commons.io.IOUtils
|
||||
import org.gotson.komga.application.events.EventPublisher
|
||||
import org.gotson.komga.domain.model.Author
|
||||
import org.gotson.komga.domain.model.BookSearchWithReadProgress
|
||||
import org.gotson.komga.domain.model.CodedException
|
||||
|
|
@ -49,6 +48,7 @@ import org.gotson.komga.interfaces.api.rest.dto.ThumbnailReadListDto
|
|||
import org.gotson.komga.interfaces.api.rest.dto.restrictUrl
|
||||
import org.gotson.komga.interfaces.api.rest.dto.toDto
|
||||
import org.gotson.komga.language.toIndexedMap
|
||||
import org.springframework.context.ApplicationEventPublisher
|
||||
import org.springframework.core.io.FileSystemResource
|
||||
import org.springframework.data.domain.Page
|
||||
import org.springframework.data.domain.PageRequest
|
||||
|
|
@ -95,7 +95,7 @@ class ReadListController(
|
|||
private val contentDetector: ContentDetector,
|
||||
private val imageAnalyzer: ImageAnalyzer,
|
||||
private val bookLifecycle: BookLifecycle,
|
||||
private val eventPublisher: EventPublisher,
|
||||
private val eventPublisher: ApplicationEventPublisher,
|
||||
) {
|
||||
|
||||
@PageableWithoutSortAsQueryParam
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import io.swagger.v3.oas.annotations.media.Schema
|
|||
import io.swagger.v3.oas.annotations.responses.ApiResponse
|
||||
import jakarta.validation.Valid
|
||||
import mu.KotlinLogging
|
||||
import org.gotson.komga.application.events.EventPublisher
|
||||
import org.gotson.komga.domain.model.Author
|
||||
import org.gotson.komga.domain.model.Dimension
|
||||
import org.gotson.komga.domain.model.DomainEvent
|
||||
|
|
@ -35,6 +34,7 @@ import org.gotson.komga.interfaces.api.rest.dto.SeriesDto
|
|||
import org.gotson.komga.interfaces.api.rest.dto.ThumbnailSeriesCollectionDto
|
||||
import org.gotson.komga.interfaces.api.rest.dto.restrictUrl
|
||||
import org.gotson.komga.interfaces.api.rest.dto.toDto
|
||||
import org.springframework.context.ApplicationEventPublisher
|
||||
import org.springframework.data.domain.Page
|
||||
import org.springframework.data.domain.PageRequest
|
||||
import org.springframework.data.domain.Pageable
|
||||
|
|
@ -71,7 +71,7 @@ class SeriesCollectionController(
|
|||
private val contentDetector: ContentDetector,
|
||||
private val imageAnalyzer: ImageAnalyzer,
|
||||
private val thumbnailSeriesCollectionRepository: ThumbnailSeriesCollectionRepository,
|
||||
private val eventPublisher: EventPublisher,
|
||||
private val eventPublisher: ApplicationEventPublisher,
|
||||
) {
|
||||
|
||||
@PageableWithoutSortAsQueryParam
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import org.apache.commons.compress.archivers.zip.Zip64Mode
|
|||
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry
|
||||
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream
|
||||
import org.apache.commons.io.IOUtils
|
||||
import org.gotson.komga.application.events.EventPublisher
|
||||
import org.gotson.komga.application.tasks.HIGHEST_PRIORITY
|
||||
import org.gotson.komga.application.tasks.HIGH_PRIORITY
|
||||
import org.gotson.komga.application.tasks.TaskEmitter
|
||||
|
|
@ -64,6 +63,7 @@ import org.gotson.komga.interfaces.api.rest.dto.TachiyomiReadProgressV2Dto
|
|||
import org.gotson.komga.interfaces.api.rest.dto.ThumbnailSeriesDto
|
||||
import org.gotson.komga.interfaces.api.rest.dto.restrictUrl
|
||||
import org.gotson.komga.interfaces.api.rest.dto.toDto
|
||||
import org.springframework.context.ApplicationEventPublisher
|
||||
import org.springframework.core.io.FileSystemResource
|
||||
import org.springframework.data.domain.Page
|
||||
import org.springframework.data.domain.PageRequest
|
||||
|
|
@ -110,7 +110,7 @@ class SeriesController(
|
|||
private val bookDtoRepository: BookDtoRepository,
|
||||
private val collectionRepository: SeriesCollectionRepository,
|
||||
private val readProgressDtoRepository: ReadProgressDtoRepository,
|
||||
private val eventPublisher: EventPublisher,
|
||||
private val eventPublisher: ApplicationEventPublisher,
|
||||
private val contentDetector: ContentDetector,
|
||||
private val imageAnalyzer: ImageAnalyzer,
|
||||
private val thumbnailsSeriesRepository: ThumbnailSeriesRepository,
|
||||
|
|
|
|||
|
|
@ -15,12 +15,9 @@ import org.gotson.komga.domain.persistence.ReadListRepository
|
|||
import org.gotson.komga.domain.persistence.SeriesCollectionRepository
|
||||
import org.gotson.komga.domain.persistence.SeriesRepository
|
||||
import org.gotson.komga.domain.persistence.SidecarRepository
|
||||
import org.gotson.komga.infrastructure.jms.TOPIC_EVENTS
|
||||
import org.gotson.komga.infrastructure.jms.TOPIC_FACTORY
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent
|
||||
import org.springframework.context.annotation.Profile
|
||||
import org.springframework.context.event.EventListener
|
||||
import org.springframework.jms.annotation.JmsListener
|
||||
import org.springframework.stereotype.Component
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
|
||||
|
|
@ -84,7 +81,7 @@ class MetricsPublisherController(
|
|||
.baseUnit("bytes")
|
||||
.register(meterRegistry)
|
||||
|
||||
@JmsListener(destination = TOPIC_EVENTS, containerFactory = TOPIC_FACTORY)
|
||||
@EventListener
|
||||
private fun pushMetricsOnEvent(event: DomainEvent) {
|
||||
when (event) {
|
||||
is DomainEvent.LibraryScanned -> entitiesMultiTag.forEach { pushMetricsCount(it) }
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@ import org.gotson.komga.domain.model.KomgaUser
|
|||
import org.gotson.komga.domain.persistence.BookRepository
|
||||
import org.gotson.komga.infrastructure.jms.JMS_PROPERTY_TYPE
|
||||
import org.gotson.komga.infrastructure.jms.QUEUE_TASKS
|
||||
import org.gotson.komga.infrastructure.jms.TOPIC_EVENTS
|
||||
import org.gotson.komga.infrastructure.jms.TOPIC_FACTORY
|
||||
import org.gotson.komga.infrastructure.security.KomgaPrincipal
|
||||
import org.gotson.komga.infrastructure.web.toFilePath
|
||||
import org.gotson.komga.interfaces.sse.dto.BookImportSseDto
|
||||
|
|
@ -28,8 +26,8 @@ import org.gotson.komga.interfaces.sse.dto.ThumbnailReadListSseDto
|
|||
import org.gotson.komga.interfaces.sse.dto.ThumbnailSeriesCollectionSseDto
|
||||
import org.gotson.komga.interfaces.sse.dto.ThumbnailSeriesSseDto
|
||||
import org.springframework.context.SmartLifecycle
|
||||
import org.springframework.context.event.EventListener
|
||||
import org.springframework.http.MediaType
|
||||
import org.springframework.jms.annotation.JmsListener
|
||||
import org.springframework.jms.core.JmsTemplate
|
||||
import org.springframework.scheduling.annotation.Scheduled
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal
|
||||
|
|
@ -75,7 +73,7 @@ class SseController(
|
|||
}
|
||||
}
|
||||
|
||||
@JmsListener(destination = TOPIC_EVENTS, containerFactory = TOPIC_FACTORY)
|
||||
@EventListener
|
||||
fun handleSseEvent(event: DomainEvent) {
|
||||
when (event) {
|
||||
is DomainEvent.LibraryAdded -> emitSse("LibraryAdded", LibrarySseDto(event.library.id))
|
||||
|
|
|
|||
Loading…
Reference in a new issue