Service Bus Create and Delete Support for Subscriptions
All Submissions:
- [YES] I have added an explanation of what changes in this merge do and why we should include it?
- [NO] Does the MR contain pipeline/ helm chart related changes?
- [NO] I have updated the documentation accordingly.
- [NO] I have added tests to cover my changes.
- [NA] All new and existing tests passed.
- [YES] My code follows the code style of this project.
- [NA] I ran lint checks locally prior to submission.
What is the issue or story related to the change?
The MR contains implementation for creation and deletion Support for SB subscriptions corresponding to Cosmos DB.
High level design:
Issue: notification#25 (closed)
Test coverage:
Does this introduce a breaking change?
- [NO]
Pending items
1-Update UT's and ITs
2-Update comments for pull subscriptions
Reviewer request
- Please provide an ETA when you plan to review this MR. Write a comment to decline or provide an ETA.
- Block the MR if you feel there is less testing or no details in the MR
- Please cover the following aspects in the MR -- Coding design: <Harshit/Komal/Vishnu> -- Backward Compatibility: <Harshit/Komal/Vishnu> -- Feature Logic: <Harshit/Komal/Vishnu>
Other information
Merge request reports
Activity
requested review from @komakkar and @harshit283
assigned to @NikhilSingh
7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package org.opengroup.osdu.register.provider.azure.subscriber; 16 17 import com.microsoft.azure.servicebus.management.ManagementClient; 18 import org.opengroup.osdu.core.common.cache.VmCache; 19 import org.springframework.context.annotation.Lazy; 20 import org.springframework.stereotype.Component; 21 22 @Lazy changed this line in version 2 of the diff
192 198 try { 193 199 pushSubscription.deletePushSubscription(subscription.get().getNotificationId(), subscription.get().getTopic()); 194 200 logger.debug("Push Subscription deleted with Event Grid ID:" + subscription.get().getNotificationId()); 201 202 pullSubscription.deletePullSubscription(subscription.get().getNotificationId(), subscription.get().getTopic()); changed this line in version 2 of the diff
19 @Autowired 20 private DpsHeaders dpsHeaders; 21 @Autowired 22 private JaxRsDpsLog logger; 23 @Autowired 24 private PartitionServiceClient partitionService; 25 @Autowired 26 private PartitionHelper partitionHelper; 27 28 public void createPullSubscription(String subscriptionId, String topicName) { 29 try { 30 TopicsRepositoryImpl topicsRepositoryImpl = new TopicsRepositoryImpl(logger, dpsHeaders, partitionHelper); 31 String topicAliasName = topicsRepositoryImpl.getTopicAliasFromFullyQualifiedTopicName(topicName); 32 factory.getManager().createSubscription(topicAliasName, subscriptionId); 33 } catch (Exception e) { 34 if (e.getMessage().equals(RESOURCE_PROVISIONING_ERROR_MESSAGE)) { changed this line in version 2 of the diff
129 132 try { 130 133 pushSubscription.createPushSubscription(doc.getNotificationId(), doc.getTopic()); 131 134 logger.debug("Push Subscription created with Event Grid ID:" + doc.getNotificationId()); 135 136 pullSubscription.createPullSubscription(doc.getNotificationId(), doc.getTopic()); changed this line in version 2 of the diff
251 260 // We will check if Push Subscription does not exist then we should try creating it again since 252 261 // the corresponding record in the Cosmos Db is already present 253 262 pushSubscription.checkIfPushSubscriptionExists(input.getNotificationId(), input.getTopic()); 263 pullSubscription.checkIfPullSubscriptionExists(input.getNotificationId(), input.getTopic()); changed this line in version 2 of the diff
192 198 try { 193 199 pushSubscription.deletePushSubscription(subscription.get().getNotificationId(), subscription.get().getTopic()); changed this line in version 2 of the diff
116 119 // This will result in an 500 Exception so the user should be able to create the subscription with 117 120 // the same topic and pushEndpoint combination again 118 121 logger.info(String.format("Record already exists for Subscription with id %s", input.getId())); 119 SubscriptionDoc output = createPushSubscriptionIfDoesNotExist(doc); 122 SubscriptionDoc output = createPushAndPullSubscriptionIfDoesNotExist(doc); changed this line in version 2 of the diff
- Resolved by Alok Joshi
15 // TODO: UPDATE ERROR_MESSAGE FOR SERVICE BUS 16 private static final String RESOURCE_PROVISIONING_ERROR_MESSAGE = "Resource cannot be updated during provisioning"; 17 @Autowired 18 private IManagementClientFactory factory; 19 @Autowired 20 private DpsHeaders dpsHeaders; 21 @Autowired 22 private JaxRsDpsLog logger; 23 @Autowired 24 private PartitionServiceClient partitionService; 25 @Autowired 26 private PartitionHelper partitionHelper; 27 28 public void createPullSubscription(String subscriptionId, String topicName) { 29 try { 30 TopicsRepositoryImpl topicsRepositoryImpl = new TopicsRepositoryImpl(logger, dpsHeaders, partitionHelper); changed this line in version 2 of the diff
- Resolved by Alok Joshi
I have a general question, are we going to keep both push and pull based subscriptions for Azure implementation? I am not clear if the pull based subs is going to replace the push based subs in future.
added 2 commits