Merge pull request #11908 from thingsboard/queue-types-deprecation
Deprecate all queue types except Kafka and in-memory
This commit is contained in:
commit
c3d922e002
@ -40,6 +40,7 @@ import org.thingsboard.server.common.data.notification.NotificationRequestConfig
|
||||
import org.thingsboard.server.common.data.notification.NotificationRequestStats;
|
||||
import org.thingsboard.server.common.data.notification.NotificationRequestStatus;
|
||||
import org.thingsboard.server.common.data.notification.NotificationStatus;
|
||||
import org.thingsboard.server.common.data.notification.info.GeneralNotificationInfo;
|
||||
import org.thingsboard.server.common.data.notification.info.RuleOriginatedNotificationInfo;
|
||||
import org.thingsboard.server.common.data.notification.settings.NotificationSettings;
|
||||
import org.thingsboard.server.common.data.notification.settings.UserNotificationSettings;
|
||||
@ -187,7 +188,7 @@ public class DefaultNotificationCenter extends AbstractSubscriptionService imple
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendGeneralWebNotification(TenantId tenantId, UsersFilter recipients, NotificationTemplate template) {
|
||||
public void sendGeneralWebNotification(TenantId tenantId, UsersFilter recipients, NotificationTemplate template, GeneralNotificationInfo info) {
|
||||
NotificationTarget target = new NotificationTarget();
|
||||
target.setTenantId(tenantId);
|
||||
PlatformUsersNotificationTargetConfig targetConfig = new PlatformUsersNotificationTargetConfig();
|
||||
@ -198,6 +199,7 @@ public class DefaultNotificationCenter extends AbstractSubscriptionService imple
|
||||
.tenantId(tenantId)
|
||||
.template(template)
|
||||
.targets(List.of(EntityId.NULL_UUID)) // this is temporary and will be removed when 'create from scratch' functionality is implemented for recipients
|
||||
.info(info)
|
||||
.status(NotificationRequestStatus.PROCESSING)
|
||||
.build();
|
||||
try {
|
||||
|
||||
@ -0,0 +1,65 @@
|
||||
/**
|
||||
* Copyright © 2016-2024 The Thingsboard Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.thingsboard.server.service.update;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.thingsboard.rule.engine.api.NotificationCenter;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.common.data.notification.info.GeneralNotificationInfo;
|
||||
import org.thingsboard.server.common.data.notification.targets.platform.SystemAdministratorsFilter;
|
||||
import org.thingsboard.server.dao.notification.DefaultNotifications;
|
||||
import org.thingsboard.server.queue.util.AfterStartUp;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class DeprecationService {
|
||||
|
||||
private final NotificationCenter notificationCenter;
|
||||
|
||||
@Value("${queue.type}")
|
||||
private String queueType;
|
||||
|
||||
@AfterStartUp(order = Integer.MAX_VALUE)
|
||||
public void checkDeprecation() {
|
||||
checkQueueTypeDeprecation();
|
||||
}
|
||||
|
||||
private void checkQueueTypeDeprecation() {
|
||||
String queueTypeName;
|
||||
switch (queueType) {
|
||||
case "aws-sqs" -> queueTypeName = "AWS SQS";
|
||||
case "pubsub" -> queueTypeName = "PubSub";
|
||||
case "service-bus" -> queueTypeName = "Azure Service Bus";
|
||||
case "rabbitmq" -> queueTypeName = "RabbitMQ";
|
||||
default -> {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
log.warn("WARNING: {} queue type is deprecated and will be removed in ThingsBoard 4.0. Please migrate to Apache Kafka", queueTypeName);
|
||||
notificationCenter.sendGeneralWebNotification(TenantId.SYS_TENANT_ID, new SystemAdministratorsFilter(),
|
||||
DefaultNotifications.queueTypeDeprecation.toTemplate(), new GeneralNotificationInfo(Map.of(
|
||||
"queueType", queueTypeName
|
||||
)));
|
||||
}
|
||||
|
||||
}
|
||||
@ -56,6 +56,7 @@ import org.thingsboard.server.common.data.notification.NotificationRequestStatus
|
||||
import org.thingsboard.server.common.data.notification.NotificationType;
|
||||
import org.thingsboard.server.common.data.notification.info.AlarmCommentNotificationInfo;
|
||||
import org.thingsboard.server.common.data.notification.info.EntityActionNotificationInfo;
|
||||
import org.thingsboard.server.common.data.notification.info.GeneralNotificationInfo;
|
||||
import org.thingsboard.server.common.data.notification.rule.trigger.config.AlarmCommentNotificationRuleTriggerConfig;
|
||||
import org.thingsboard.server.common.data.notification.settings.MobileAppNotificationDeliveryMethodConfig;
|
||||
import org.thingsboard.server.common.data.notification.settings.NotificationSettings;
|
||||
@ -84,6 +85,7 @@ import org.thingsboard.server.common.data.notification.template.WebDeliveryMetho
|
||||
import org.thingsboard.server.common.data.page.PageLink;
|
||||
import org.thingsboard.server.common.data.security.Authority;
|
||||
import org.thingsboard.server.dao.notification.DefaultNotifications;
|
||||
import org.thingsboard.server.dao.notification.DefaultNotifications.DefaultNotification;
|
||||
import org.thingsboard.server.dao.service.DaoSqlTest;
|
||||
import org.thingsboard.server.service.notification.channels.MicrosoftTeamsNotificationChannel;
|
||||
import org.thingsboard.server.service.notification.channels.TeamsAdaptiveCard;
|
||||
@ -746,14 +748,21 @@ public class NotificationApiTest extends AbstractNotificationApiTest {
|
||||
|
||||
getAnotherWsClient().registerWaitForUpdate();
|
||||
|
||||
DefaultNotifications.DefaultNotification expectedNotification = DefaultNotifications.maintenanceWork;
|
||||
NotificationTemplate template = DefaultNotification.builder()
|
||||
.name("Test")
|
||||
.subject("Testing ${subjectVariable}")
|
||||
.text("Testing ${bodyVariable}")
|
||||
.build().toTemplate();
|
||||
notificationCenter.sendGeneralWebNotification(TenantId.SYS_TENANT_ID, new SystemAdministratorsFilter(),
|
||||
expectedNotification.toTemplate());
|
||||
template, new GeneralNotificationInfo(Map.of(
|
||||
"subjectVariable", "subject",
|
||||
"bodyVariable", "body"
|
||||
)));
|
||||
|
||||
getAnotherWsClient().waitForUpdate(true);
|
||||
Notification notification = getAnotherWsClient().getLastDataUpdate().getUpdate();
|
||||
assertThat(notification.getSubject()).isEqualTo(expectedNotification.getSubject());
|
||||
assertThat(notification.getText()).isEqualTo(expectedNotification.getText());
|
||||
assertThat(notification.getSubject()).isEqualTo("Testing subject");
|
||||
assertThat(notification.getText()).isEqualTo("Testing body");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Copyright © 2016-2024 The Thingsboard Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.thingsboard.server.common.data.notification.info;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class GeneralNotificationInfo implements RuleOriginatedNotificationInfo {
|
||||
|
||||
private Map<String, String> data;
|
||||
|
||||
@Override
|
||||
public Map<String, String> getTemplateData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
@ -31,6 +31,7 @@ import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Slf4j
|
||||
@Deprecated(forRemoval = true, since = "3.9") // for removal in 4.0
|
||||
public class TbServiceBusAdmin implements TbQueueAdmin {
|
||||
private final String MAX_SIZE = "maxSizeInMb";
|
||||
private final String MESSAGE_TIME_TO_LIVE = "messageTimeToLiveInSec";
|
||||
|
||||
@ -37,6 +37,7 @@ import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Slf4j
|
||||
@Deprecated(forRemoval = true, since = "3.9") // for removal in 4.0
|
||||
public class TbPubSubAdmin implements TbQueueAdmin {
|
||||
private static final String ACK_DEADLINE = "ackDeadlineInSec";
|
||||
private static final String MESSAGE_RETENTION = "messageRetentionInSec";
|
||||
|
||||
@ -27,6 +27,7 @@ import java.util.Map;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
@Slf4j
|
||||
@Deprecated(forRemoval = true, since = "3.9") // for removal in 4.0
|
||||
public class TbRabbitMqAdmin implements TbQueueAdmin {
|
||||
|
||||
private final Channel channel;
|
||||
|
||||
@ -36,6 +36,7 @@ import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Deprecated(forRemoval = true, since = "3.9") // for removal in 4.0
|
||||
public class TbAwsSqsAdmin implements TbQueueAdmin {
|
||||
|
||||
private final Map<String, String> attributes;
|
||||
|
||||
@ -372,6 +372,14 @@ public class DefaultNotifications {
|
||||
.build())
|
||||
.build();
|
||||
|
||||
public static final DefaultNotification queueTypeDeprecation = DefaultNotification.builder()
|
||||
.name("Queue type deprecation")
|
||||
.type(NotificationType.GENERAL)
|
||||
.subject("WARNING: ${queueType} deprecation")
|
||||
.text("${queueType} queue type is deprecated and will be removed in ThingsBoard 4.0. Please migrate to Apache Kafka")
|
||||
.icon("warning").color(RED_COLOR)
|
||||
.build();
|
||||
|
||||
private final NotificationTemplateService templateService;
|
||||
private final NotificationRuleService ruleService;
|
||||
|
||||
|
||||
@ -23,6 +23,7 @@ import org.thingsboard.server.common.data.id.UserId;
|
||||
import org.thingsboard.server.common.data.notification.NotificationDeliveryMethod;
|
||||
import org.thingsboard.server.common.data.notification.NotificationRequest;
|
||||
import org.thingsboard.server.common.data.notification.NotificationRequestStats;
|
||||
import org.thingsboard.server.common.data.notification.info.GeneralNotificationInfo;
|
||||
import org.thingsboard.server.common.data.notification.targets.platform.UsersFilter;
|
||||
import org.thingsboard.server.common.data.notification.template.NotificationTemplate;
|
||||
|
||||
@ -32,7 +33,7 @@ public interface NotificationCenter {
|
||||
|
||||
NotificationRequest processNotificationRequest(TenantId tenantId, NotificationRequest notificationRequest, FutureCallback<NotificationRequestStats> callback);
|
||||
|
||||
void sendGeneralWebNotification(TenantId tenantId, UsersFilter recipients, NotificationTemplate template);
|
||||
void sendGeneralWebNotification(TenantId tenantId, UsersFilter recipients, NotificationTemplate template, GeneralNotificationInfo info);
|
||||
|
||||
void deleteNotificationRequest(TenantId tenantId, NotificationRequestId notificationRequestId);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user