-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11908 from thingsboard/queue-types-deprecation
Deprecate all queue types except Kafka and in-memory
- Loading branch information
Showing
10 changed files
with
131 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
application/src/main/java/org/thingsboard/server/service/update/DeprecationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
))); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...in/java/org/thingsboard/server/common/data/notification/info/GeneralNotificationInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters