Package org.apache.stratos.messaging.event.tenant

Examples of org.apache.stratos.messaging.event.tenant.TenantUnSubscribedEvent


            if(!TenantManager.getInstance().isInitialized()) {
                return false;
            }

            // Parse complete message and build event
            TenantUnSubscribedEvent event = (TenantUnSubscribedEvent) Util.jsonToObject(message, TenantUnSubscribedEvent.class);

            try {
                TenantManager.acquireWriteLock();
                Tenant tenant = TenantManager.getInstance().getTenant(event.getTenantId());
                if(tenant == null) {
                    if(log.isWarnEnabled()) {
                        log.warn(String.format("Tenant not found: [tenant-id] %d", event.getTenantId()));
                    }
                    return false;
                }
                tenant.removeServiceSubscription(event.getServiceName());
                if(log.isInfoEnabled()) {
                    log.info(String.format("Tenant un-subscribed from service: [tenant-id] %d [tenant-domain] %s [service] %s",
                            tenant.getTenantId(), tenant.getTenantDomain(), event.getServiceName()));
                }

                // Notify event listeners
                notifyEventListeners(event);
                return true;
View Full Code Here


    public static void publishTenantUnSubscribedEvent(int tenantId, String serviceName) {
        try {
            if(log.isInfoEnabled()) {
                log.info(String.format("Publishing tenant un-subscribed event: [tenant-id] %d [service] %s", tenantId, serviceName));
            }
            TenantUnSubscribedEvent event = new TenantUnSubscribedEvent(tenantId, serviceName);
            EventPublisher eventPublisher = EventPublisherPool.getPublisher(Constants.TENANT_TOPIC);
            eventPublisher.publish(event);
        } catch (Exception e) {
            if (log.isErrorEnabled()) {
                log.error(String.format("Could not publish tenant un-subscribed event: [tenant-id] %d [service] %s", tenantId, serviceName), e);
View Full Code Here

            }
        });
        tenantEventReceiver.addEventListener(new TenantUnSubscribedEventListener() {
            @Override
            protected void onEvent(Event event) {
                TenantUnSubscribedEvent tenantUnSubscribedEvent = (TenantUnSubscribedEvent) event;
                if(log.isDebugEnabled()) {
                    log.debug(String.format("Tenant un-subscribed event received: [tenant-id] %d [service] %s",
                            tenantUnSubscribedEvent.getTenantId(), tenantUnSubscribedEvent.getServiceName()));
                }
                if(isMultiTenantService(tenantUnSubscribedEvent.getServiceName())) {
                    removeTenantSubscriptionFromLbContext(tenantUnSubscribedEvent.getServiceName(), tenantUnSubscribedEvent.getTenantId());
                }
            }
        });
    }
View Full Code Here

TOP

Related Classes of org.apache.stratos.messaging.event.tenant.TenantUnSubscribedEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.