diff --git a/application/src/test/java/org/thingsboard/server/controller/TenantControllerTest.java b/application/src/test/java/org/thingsboard/server/controller/TenantControllerTest.java index 3160d542f1..14e597378c 100644 --- a/application/src/test/java/org/thingsboard/server/controller/TenantControllerTest.java +++ b/application/src/test/java/org/thingsboard/server/controller/TenantControllerTest.java @@ -616,6 +616,14 @@ public class TenantControllerTest extends AbstractControllerTest { assertThat(usedTpi.getTopic()).isEqualTo(DataConstants.HP_QUEUE_TOPIC); assertThat(usedTpi.getTenantId()).get().isEqualTo(TenantId.SYS_TENANT_ID); }); + assertThat(partitionService.resolve(ServiceType.TB_RULE_ENGINE, null, tenantId, tenantId)).satisfies(tpi -> { + assertThat(tpi.getTopic()).isEqualTo(MAIN_QUEUE_TOPIC); + assertThat(tpi.getTenantId()).get().isEqualTo(tenantId); + }); + assertThat(partitionService.resolve(ServiceType.TB_RULE_ENGINE, "", tenantId, tenantId)).satisfies(tpi -> { + assertThat(tpi.getTopic()).isEqualTo(MAIN_QUEUE_TOPIC); + assertThat(tpi.getTenantId()).get().isEqualTo(tenantId); + }); loginSysAdmin(); tenantProfile.setIsolatedTbRuleEngine(true); @@ -850,4 +858,5 @@ public class TenantControllerTest extends AbstractControllerTest { testBroadcastEntityStateChangeEventNever(createEntityId_NULL_UUID(new Tenant())); Mockito.reset(tbClusterService); } + } diff --git a/common/queue/src/main/java/org/thingsboard/server/queue/discovery/HashPartitionService.java b/common/queue/src/main/java/org/thingsboard/server/queue/discovery/HashPartitionService.java index 04d55f91c0..53a2152782 100644 --- a/common/queue/src/main/java/org/thingsboard/server/queue/discovery/HashPartitionService.java +++ b/common/queue/src/main/java/org/thingsboard/server/queue/discovery/HashPartitionService.java @@ -17,6 +17,7 @@ package org.thingsboard.server.queue.discovery; import com.google.common.hash.HashFunction; import com.google.common.hash.Hashing; +import jakarta.annotation.PostConstruct; import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; @@ -36,7 +37,6 @@ import org.thingsboard.server.queue.discovery.event.PartitionChangeEvent; import org.thingsboard.server.queue.discovery.event.ServiceListChangedEvent; import org.thingsboard.server.queue.util.AfterStartUp; -import jakarta.annotation.PostConstruct; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -319,7 +319,7 @@ public class HashPartitionService implements PartitionService { private QueueKey getQueueKey(ServiceType serviceType, String queueName, TenantId tenantId) { TenantId isolatedOrSystemTenantId = getIsolatedOrSystemTenantId(serviceType, tenantId); - if (queueName == null) { + if (queueName == null || queueName.isEmpty()) { queueName = MAIN_QUEUE_NAME; } QueueKey queueKey = new QueueKey(serviceType, queueName, isolatedOrSystemTenantId); @@ -672,6 +672,7 @@ public class HashPartitionService implements PartitionService { public QueueConfig(QueueRoutingInfo queueRoutingInfo) { this.duplicateMsgToAllPartitions = queueRoutingInfo.isDuplicateMsgToAllPartitions(); } + } }