Search in sources :

Example 1 with ServiceSubscriber

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);
}
Also used : ReliableSubscriptionService(com.vmware.xenon.services.common.ReliableSubscriptionService) ServiceSubscriber(com.vmware.xenon.common.ServiceSubscriptionState.ServiceSubscriber) Operation(com.vmware.xenon.common.Operation)

Aggregations

Operation (com.vmware.xenon.common.Operation)1 ServiceSubscriber (com.vmware.xenon.common.ServiceSubscriptionState.ServiceSubscriber)1 ReliableSubscriptionService (com.vmware.xenon.services.common.ReliableSubscriptionService)1