use of com.vmware.xenon.common.ServiceSubscriptionState.ServiceSubscriber in project photon-model by vmware.
the class TaskUtils method subscribeToNotifications.
public static void subscribeToNotifications(StatefulService service, Consumer<Operation> notificationConsumer, String taskLink) {
ServiceSubscriber subscribeBody = new ServiceSubscriber();
subscribeBody.replayState = true;
subscribeBody.usePublicUri = true;
Operation subscribeOp = Operation.createPost(service, taskLink).setReferer(service.getUri()).setCompletion((regOp, regEx) -> {
if (regEx != null) {
sendFailureSelfPatch(service, regEx);
return;
}
});
ReliableSubscriptionService notificationTarget = ReliableSubscriptionService.create(subscribeOp, subscribeBody, notificationConsumer);
service.getHost().startSubscriptionService(subscribeOp, notificationTarget, subscribeBody);
}
Aggregations