Updated to latest tenant-commons, adjusted listeners
This commit is contained in:
parent
987e720dad
commit
27925d6b3c
1
.gitignore
vendored
1
.gitignore
vendored
@ -40,3 +40,4 @@ gradle/
|
||||
|
||||
**/.gradle
|
||||
**/build
|
||||
.DS_Store
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
`kotlin-dsl`
|
||||
pmd
|
||||
checkstyle
|
||||
jacoco
|
||||
@ -25,10 +24,11 @@ repositories {
|
||||
val springBootVersion = "3.1.5"
|
||||
|
||||
dependencies {
|
||||
api("com.knecon.fforesight:tenant-commons:0.29.0")
|
||||
api("com.knecon.fforesight:tenant-commons:0.31.0")
|
||||
api("org.liquibase:liquibase-core:4.20.0")
|
||||
api("org.liquibase.ext:liquibase-mongodb:4.20.0")
|
||||
api("org.springframework.boot:spring-boot-starter-data-mongodb:${springBootVersion}")
|
||||
api("org.springframework.boot:spring-boot-starter-validation:${springBootVersion}")
|
||||
api("org.springframework.boot:spring-boot-configuration-processor:${springBootVersion}")
|
||||
api("org.projectlombok:lombok:1.18.28")
|
||||
runtimeOnly("org.springframework.boot:spring-boot-devtools:${springBootVersion}")
|
||||
@ -83,7 +83,7 @@ tasks.named<Test>("test") {
|
||||
|
||||
sonarqube {
|
||||
properties {
|
||||
property("sonar.login", providers.gradleProperty("sonarToken").getOrNull())
|
||||
providers.gradleProperty("sonarToken").getOrNull()?.let { property("sonar.login", it) }
|
||||
property("sonar.host.url", "https://sonarqube.knecon.com")
|
||||
}
|
||||
}
|
||||
@ -103,4 +103,4 @@ tasks.jacocoTestReport {
|
||||
|
||||
java {
|
||||
withJavadocJar()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,59 +0,0 @@
|
||||
package com.knecon.fforesight.mongo.database.commons;
|
||||
|
||||
import org.springframework.amqp.core.Binding;
|
||||
import org.springframework.amqp.core.BindingBuilder;
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.amqp.core.QueueBuilder;
|
||||
import org.springframework.amqp.core.TopicExchange;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.knecon.fforesight.mongo.database.commons.liquibase.EnableMongoLiquibaseCondition;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Configuration
|
||||
@RequiredArgsConstructor
|
||||
@Conditional(EnableMongoLiquibaseCondition.class)
|
||||
public class MongoTenantMessagingConfiguration {
|
||||
|
||||
@Value("${fforesight.mongo.multitenancy.tenant-created-queue:mongo-tenant-created}")
|
||||
private String mongoTenantCreatedEventQueue;
|
||||
|
||||
@Value("${fforesight.mongo.multitenancy.tenant-created-dlq:mongo-tenant-created-error}")
|
||||
private String mongoTenantCreatedDLQ;
|
||||
|
||||
|
||||
@Bean(name = "mongoTenantExchange")
|
||||
TopicExchange mongoTenantExchange(@Value("${fforesight.tenant-exchange.name:tenants-exchange}") String tenantExchangeName) {
|
||||
|
||||
return new TopicExchange(tenantExchangeName);
|
||||
}
|
||||
|
||||
|
||||
@Bean("persistenceServiceMongoTenantCreatedQueue")
|
||||
public Queue persistenceServiceMongoTenantCreatedQueue() {
|
||||
|
||||
return QueueBuilder.durable(mongoTenantCreatedEventQueue)
|
||||
.withArgument("x-dead-letter-exchange", "").withArgument("x-dead-letter-routing-key", mongoTenantCreatedDLQ).build();
|
||||
}
|
||||
|
||||
|
||||
@Bean("persistenceServiceMongoTenantDLQ")
|
||||
public Queue persistenceServiceMongoTenantDLQ() {
|
||||
|
||||
return QueueBuilder.durable(mongoTenantCreatedDLQ).build();
|
||||
}
|
||||
|
||||
|
||||
@Bean("mongoTenantExchangeBinding")
|
||||
public Binding mongoTenantExchangeBinding(@Qualifier("persistenceServiceMongoTenantCreatedQueue") Queue persistenceServiceTenantCreatedQueue,
|
||||
@Qualifier("mongoTenantExchange") TopicExchange tenantExchange) {
|
||||
|
||||
return BindingBuilder.bind(persistenceServiceTenantCreatedQueue).to(tenantExchange).with("tenant.created");
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,9 +2,9 @@ package com.knecon.fforesight.mongo.database.commons.config;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.bson.Document;
|
||||
import org.bson.conversions.Bson;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.mongodb.core.SimpleMongoClientDatabaseFactory;
|
||||
|
||||
|
||||
@ -2,11 +2,12 @@ package com.knecon.fforesight.mongo.database.commons.liquibase;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.context.annotation.Condition;
|
||||
import org.springframework.context.annotation.ConditionContext;
|
||||
import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
public class EnableMongoLiquibaseCondition implements Condition {
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,14 +0,0 @@
|
||||
package com.knecon.fforesight.mongo.database.commons.liquibase;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class MongoTenantCreatedEvent {
|
||||
|
||||
private String tenantId;
|
||||
|
||||
}
|
||||
@ -1,39 +1,33 @@
|
||||
package com.knecon.fforesight.mongo.database.commons.liquibase;
|
||||
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import com.knecon.fforesight.tenantcommons.listener.ITenantEventHandler;
|
||||
import com.knecon.fforesight.tenantcommons.model.TenantCreatedEvent;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Conditional(EnableMongoLiquibaseCondition.class)
|
||||
public class MongoTenantCreatedListener {
|
||||
public class MongoTenantCreatedListener implements ITenantEventHandler<TenantCreatedEvent> {
|
||||
|
||||
private final TenantMongoLiquibaseExecutor tenantMongoLiquibaseExecutor;
|
||||
|
||||
@Value("${fforesight.multitenancy.mongo.tenant-created-queue:mongo-tenant-created}")
|
||||
private String tenantCreatedQueue;
|
||||
|
||||
@Override
|
||||
public void handle(TenantCreatedEvent tenantCreatedEvent) {
|
||||
|
||||
@PostConstruct
|
||||
public void postConstruct() {
|
||||
|
||||
log.info("Listener for tenant-created started for queue: {}", tenantCreatedQueue);
|
||||
tenantMongoLiquibaseExecutor.initializeTenant(tenantCreatedEvent.getTenantId());
|
||||
}
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
@RabbitListener(queues = "${fforesight.multitenancy.mongo.tenant-created-queue:mongo-tenant-created}")
|
||||
public void createTenant(MongoTenantCreatedEvent tenantRequest) {
|
||||
@Override
|
||||
public Class<TenantCreatedEvent> getEventClass() {
|
||||
|
||||
tenantMongoLiquibaseExecutor.initializeTenant(tenantRequest.getTenantId());
|
||||
return TenantCreatedEvent.class;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@ package com.knecon.fforesight.mongo.database.commons.service;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -16,6 +15,7 @@ import com.mongodb.client.MongoClient;
|
||||
import com.mongodb.client.MongoClients;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
@ -70,4 +70,4 @@ public class MongoClientCache {
|
||||
return clients.get(tenantId);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user