-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SWATCH-2356: Send request to enabled-orgs-for-tasks for prune and sync
- The method "pruneUnlistedSubscriptions" from SWATCH-2277 should produce a single message to "platform.rhsm-subscriptions.enabled-orgs-for-tasks" with a message containing the topic name "platform.rhsm-subscriptions.subscription-prune-task". - The method "syncAllSubscriptions" from SWATCH-2277 should produce a single message to "platform.rhsm-subscriptions.enabled-orgs-for-tasks" with a message containing the topic name "platform.rhsm-subscriptions.subscription-sync-task". - Create the consumer of "platform.rhsm-subscriptions.subscription-prune-task" that receives a message that includes the orgId. Leave the implementation empty. - Create the consumer of "platform.rhsm-subscriptions.subscription-sync-task" that receives a message that includes the orgId. Leave the implementation empty.
- Loading branch information
Showing
14 changed files
with
606 additions
and
11 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
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
32 changes: 32 additions & 0 deletions
32
...h-contracts/src/main/java/com/redhat/swatch/contract/config/ApplicationConfiguration.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,32 @@ | ||
/* | ||
* Copyright Red Hat, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
* Red Hat trademarks are not licensed under GPLv3. No permission is | ||
* granted to use or replicate Red Hat trademarks that are incorporated | ||
* in this software or its documentation. | ||
*/ | ||
package com.redhat.swatch.contract.config; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import lombok.Getter; | ||
import org.eclipse.microprofile.config.inject.ConfigProperty; | ||
|
||
@ApplicationScoped | ||
@Getter | ||
public class ApplicationConfiguration { | ||
@ConfigProperty(name = "rhsm-subscriptions.subscription-sync-enabled") | ||
boolean subscriptionSyncEnabled; | ||
} |
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
61 changes: 61 additions & 0 deletions
61
swatch-contracts/src/main/java/com/redhat/swatch/contract/service/EnabledOrgsProducer.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,61 @@ | ||
/* | ||
* Copyright Red Hat, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
* Red Hat trademarks are not licensed under GPLv3. No permission is | ||
* granted to use or replicate Red Hat trademarks that are incorporated | ||
* in this software or its documentation. | ||
*/ | ||
package com.redhat.swatch.contract.service; | ||
|
||
import com.redhat.swatch.contract.model.EnabledOrgsRequest; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
import org.eclipse.microprofile.config.inject.ConfigProperty; | ||
import org.eclipse.microprofile.reactive.messaging.Channel; | ||
import org.eclipse.microprofile.reactive.messaging.Emitter; | ||
|
||
@ApplicationScoped | ||
public class EnabledOrgsProducer { | ||
|
||
public static final String SUBSCRIPTION_SYNC_TASK_TOPIC = | ||
"mp.messaging.incoming.subscription-sync-task.topic"; | ||
public static final String SUBSCRIPTION_PRUNE_TASK_TOPIC = | ||
"mp.messaging.incoming.subscription-prune-task.topic"; | ||
|
||
private final Emitter<EnabledOrgsRequest> emitter; | ||
private final String subscriptionSyncTaskTopic; | ||
private final String subscriptionPruneTaskTopic; | ||
|
||
public EnabledOrgsProducer( | ||
@Channel("enabled-orgs") Emitter<EnabledOrgsRequest> emitter, | ||
@ConfigProperty(name = SUBSCRIPTION_SYNC_TASK_TOPIC) String subscriptionSyncTaskTopic, | ||
@ConfigProperty(name = SUBSCRIPTION_PRUNE_TASK_TOPIC) String subscriptionPruneTaskTopic) { | ||
this.emitter = emitter; | ||
this.subscriptionSyncTaskTopic = subscriptionSyncTaskTopic; | ||
this.subscriptionPruneTaskTopic = subscriptionPruneTaskTopic; | ||
} | ||
|
||
public void sendTaskForSubscriptionsPrune() { | ||
sendTask(subscriptionPruneTaskTopic); | ||
} | ||
|
||
public void sendTaskForSubscriptionsSync() { | ||
sendTask(subscriptionSyncTaskTopic); | ||
} | ||
|
||
private void sendTask(String topic) { | ||
emitter.send(new EnabledOrgsRequest().withTargetTopic(topic)); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...racts/src/main/java/com/redhat/swatch/contract/service/SubscriptionPruneTaskConsumer.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 Red Hat, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
* Red Hat trademarks are not licensed under GPLv3. No permission is | ||
* granted to use or replicate Red Hat trademarks that are incorporated | ||
* in this software or its documentation. | ||
*/ | ||
package com.redhat.swatch.contract.service; | ||
|
||
import com.redhat.swatch.contract.model.EnabledOrgsResponse; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.eclipse.microprofile.reactive.messaging.Incoming; | ||
|
||
@Slf4j | ||
@ApplicationScoped | ||
public class SubscriptionPruneTaskConsumer { | ||
@Incoming("subscription-prune-task") | ||
public void consume(EnabledOrgsResponse message) { | ||
log.info("Received task for subscription prune with org ID: {}", message.getOrgId()); | ||
// Implementation will be done as part of SWATCH-2281 | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...tracts/src/main/java/com/redhat/swatch/contract/service/SubscriptionSyncTaskConsumer.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 Red Hat, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
* Red Hat trademarks are not licensed under GPLv3. No permission is | ||
* granted to use or replicate Red Hat trademarks that are incorporated | ||
* in this software or its documentation. | ||
*/ | ||
package com.redhat.swatch.contract.service; | ||
|
||
import com.redhat.swatch.contract.model.EnabledOrgsResponse; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.eclipse.microprofile.reactive.messaging.Incoming; | ||
|
||
@Slf4j | ||
@ApplicationScoped | ||
public class SubscriptionSyncTaskConsumer { | ||
@Incoming("subscription-sync-task") | ||
public void consume(EnabledOrgsResponse message) { | ||
log.info("Received task for subscription sync with org ID: {}", message.getOrgId()); | ||
// Implementation will be done as part of SWATCH-2281 | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...rc/main/java/com/redhat/swatch/contract/service/json/EnabledOrgsResponseDeserializer.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,31 @@ | ||
/* | ||
* Copyright Red Hat, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
* Red Hat trademarks are not licensed under GPLv3. No permission is | ||
* granted to use or replicate Red Hat trademarks that are incorporated | ||
* in this software or its documentation. | ||
*/ | ||
package com.redhat.swatch.contract.service.json; | ||
|
||
import com.redhat.swatch.contract.model.EnabledOrgsResponse; | ||
import io.quarkus.kafka.client.serialization.ObjectMapperDeserializer; | ||
|
||
/** Provides quarkus a hint that we want to use Jackson to serialize EnabledOrgsResponse objects. */ | ||
public class EnabledOrgsResponseDeserializer extends ObjectMapperDeserializer<EnabledOrgsResponse> { | ||
public EnabledOrgsResponseDeserializer() { | ||
super(EnabledOrgsResponse.class); | ||
} | ||
} |
Oops, something went wrong.