-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReportQueueConfiguration.kt
49 lines (43 loc) · 2.21 KB
/
ReportQueueConfiguration.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.aamdigital.aambackendservice.reporting.report.di
import com.aamdigital.aambackendservice.queue.core.QueueMessageParser
import com.aamdigital.aambackendservice.reporting.report.core.DefaultReportDocumentChangeEventConsumer
import com.aamdigital.aambackendservice.reporting.report.core.IdentifyAffectedReportsUseCase
import com.aamdigital.aambackendservice.reporting.report.core.ReportDocumentChangeEventConsumer
import com.aamdigital.aambackendservice.reporting.reportcalculation.core.CreateReportCalculationUseCase
import com.aamdigital.aambackendservice.reporting.reportcalculation.core.ReportCalculationChangeUseCase
import org.springframework.amqp.core.Binding
import org.springframework.amqp.core.BindingBuilder
import org.springframework.amqp.core.FanoutExchange
import org.springframework.amqp.core.Queue
import org.springframework.amqp.core.QueueBuilder
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
@Configuration
class ReportQueueConfiguration {
companion object {
const val DOCUMENT_CHANGES_REPORT_QUEUE = "document.changes.report"
}
@Bean("report-config-changes-queue")
fun reportConfigChangesQueue(): Queue = QueueBuilder
.durable(DOCUMENT_CHANGES_REPORT_QUEUE)
.build()
@Bean("report-document-changes-exchange")
fun reportDocumentChangesBinding(
@Qualifier("report-config-changes-queue") queue: Queue,
@Qualifier("document-changes-exchange") exchange: FanoutExchange,
): Binding = BindingBuilder.bind(queue).to(exchange)
@Bean("report-document-changes-consumer")
fun reportDocumentChangeEventConsumer(
messageParser: QueueMessageParser,
createReportCalculationUseCase: CreateReportCalculationUseCase,
reportCalculationChangeUseCase: ReportCalculationChangeUseCase,
identifyAffectedReportsUseCase: IdentifyAffectedReportsUseCase,
): ReportDocumentChangeEventConsumer =
DefaultReportDocumentChangeEventConsumer(
messageParser,
createReportCalculationUseCase,
reportCalculationChangeUseCase,
identifyAffectedReportsUseCase,
)
}