Examples of EventBroker


Examples of org.wso2.carbon.event.core.EventBroker

//
//            ActivityEvent<MessageContext> event = null;
//            event = new ActivityThresholdEvent<MessageContext>(eventMsgCtx);
//            ((ActivityThresholdEvent<MessageContext>) event).setResourcePath(ActivityPublisherConstants.BAM_REG_PATH);
//            EventBrokerService<MessageContext> ebs = PublisherUtils.getEventBrokerService();
            EventBroker eb = PublisherUtils.getEventBroker();
            Message message = new Message();
            message.setMessage(eventBody);

            try {
                SuperTenantCarbonContext.startTenantFlow();
                int tenantId = SuperTenantCarbonContext.getCurrentContext(PublisherUtils.getConfigurationContext()).getTenantId();
                SuperTenantCarbonContext.getCurrentContext().setTenantId(tenantId);
                SuperTenantCarbonContext.getCurrentContext().getTenantDomain(true);

                eb.publish(message, ActivityPublisherConstants.BAM_REG_PATH);

            } catch (EventBrokerException e) {
                log.error("Can not publish the message ", e);
            } finally {
                SuperTenantCarbonContext.endTenantFlow();
View Full Code Here

Examples of org.wso2.carbon.event.core.EventBroker

//
//        // Create a new event and publish to the event broker service
//        ActivityThresholdEvent<MessageContext> event = new ActivityThresholdEvent<MessageContext>(eventMsgCtx);
//        event.setResourcePath(ActivityPublisherConstants.BAM_REG_PATH);

        EventBroker eb = ActivityPublisherUtils.getEventBroker();
        Message message = new Message();
        message.setMessage(eventElement);

        try {
            SuperTenantCarbonContext.startTenantFlow();
            int tenantId = SuperTenantCarbonContext.getCurrentContext(ActivityPublisherUtils.getConfigurationContextService().getServerConfigContext()).getTenantId();
            SuperTenantCarbonContext.getCurrentContext().setTenantId(tenantId);
            SuperTenantCarbonContext.getCurrentContext().getTenantDomain(true);

            eb.publish(message, ActivityPublisherConstants.BAM_REG_PATH);

        } catch (EventBrokerException e) {
            log.error("Can not publish the message ", e);
        } finally {
            SuperTenantCarbonContext.endTenantFlow();
View Full Code Here

Examples of org.wso2.carbon.event.core.EventBroker

public class EventPublisher implements ServiceStatsProcessor {

    private static Log log = LogFactory.getLog(EventPublisher.class);

    public void process(StatisticData[] statisticData) {
        EventBroker broker = StatisticsServiceComponent.getEventBroker();
        Message message = new Message();

        OMElement eventPayLoad = null;
        for (StatisticData statistic : statisticData) {
            eventPayLoad = constructEventPayLoad(statistic);
            message.setMessage(eventPayLoad);
            try {
                SuperTenantCarbonContext.startTenantFlow();
                int tenantId = SuperTenantCarbonContext.getCurrentContext(StatisticsServiceComponent.getConfigurationContext()).getTenantId();
                SuperTenantCarbonContext.getCurrentContext().setTenantId(tenantId);
                SuperTenantCarbonContext.getCurrentContext().getTenantDomain(true);

                broker.publishRobust(message, ServiceStatisticsPublisherConstants.BAM_REG_PATH);

            } catch (EventBrokerException e) {
                log.error("Can not publish the message ", e);
            } finally {
                SuperTenantCarbonContext.endTenantFlow();
View Full Code Here

Examples of org.wso2.carbon.event.core.EventBroker

        //Add static subscription only if bam url is set
        if (serverURL != null) {
            String serviceURL = serverURL + UsageAgentConstants.BAM_SERVER_STAT_SERVICE;

            EventBroker eventBrokerService = getEventBrokerService();
            Subscription subscription = new Subscription();
            // set the subscription end point to the service url
            subscription.setEventSinkURL(serviceURL);
            subscription.setTopicName(UsageAgentConstants.BAM_SERVER_STAT_FILTER);
            subscription.setOwner(CarbonConstants.REGISTRY_SYSTEM_USERNAME);
            subscription.setEventDispatcherName(EventBrokerConstants.WS_EVENT_DISPATCHER_NAME);

            try {
                eventBrokerService.subscribe(subscription);
            } catch (EventBrokerException e) {
                String msg = "Cannot subscribe to the event broker ";
                log.error(msg);
                throw e;
            }
View Full Code Here

Examples of org.wso2.carbon.event.core.EventBroker

            return;
        }

        // get the topic of the event to be published
        String topic = UsageAgentConstants.BANDWIDTH_USAGE_TOPIC;
        EventBroker eventBrokerService = Util.getEventBrokerService();
        // publish the event
        try {
            SuperTenantCarbonContext.startTenantFlow();
            SuperTenantCarbonContext.getCurrentContext().setTenantId(MultitenantConstants.SUPER_TENANT_ID);
            SuperTenantCarbonContext.getCurrentContext().getTenantDomain(true);
            eventBrokerService.publish(message, topic);
        } catch (EventBrokerException e) {
            log.error("SystemStatisticsHandler - Unable to send notification for stat threshold", e);
        } finally {
            SuperTenantCarbonContext.endTenantFlow();
        }
View Full Code Here

Examples of org.wso2.carbon.event.core.EventBroker

            if (tenantDomainName == null) {
                ServerConfiguration serverConfiguration = this.serverConfiguration;
                String mediationServerURL = serverConfiguration.getFirstProperty(BAM_SERVER_URL);

                if (mediationServerURL != null) {
                    EventBroker eventBroker = PublisherUtils.getEventBroker();

                    Subscription subscription = new Subscription();
/*
                    EventFilter eventFilter = new EventFilter(null, null); //
                    subscription.setEventFilter(eventFilter);*/

                    subscription.setEventSinkURL(mediationServerURL + MDPublisherConstants.BMA_MEDIATION_STAT_RECEIVER_SERVICE);
                    subscription.setTopicName("carbon/bam/data/publishers/mediation_stats");

/*                    EventFilterDesc eventFilterDesc = new EventFilterDesc();
                    eventFilterDesc.setFilterValue("carbon/bam/data/publishers/mediation_stats");
                    subscription.setFilterDesc(eventFilterDesc);*/
                    try {
                        eventBroker.subscribe(subscription);
                    } catch (Exception e) {
                        throw new AxisFault("Can not subscribe to the event broker ", e);
                    }
                }
            }
View Full Code Here

Examples of org.wso2.carbon.event.core.EventBroker

            Message message = new Message();
            message.setMessage(statMessage);

            int tenantId = NO_TENANT_MODE;
            EventBroker broker = PublisherUtils.getEventBroker();
            try {
                SuperTenantCarbonContext.startTenantFlow();

                // This check is for integration tests where no ConfigurationContextService would be present
                if (PublisherUtils.getConfigurationContextService() != null) {
                   tenantId = SuperTenantCarbonContext.getCurrentContext(PublisherUtils.
                        getConfigurationContextService().getServerConfigContext()).getTenantId();
                }

                SuperTenantCarbonContext.getCurrentContext().setTenantId(tenantId);
                SuperTenantCarbonContext.getCurrentContext().getTenantDomain(true);

                broker.publish(message, MDPublisherConstants.BAM_REG_PATH);

            } catch (EventBrokerException e) {
                log.error("Can not publish the message ", e);
            } finally {
                SuperTenantCarbonContext.endTenantFlow();
View Full Code Here

Examples of org.wso2.carbon.event.core.EventBroker

    private void generateEvent(OMElement statMessage) {
        if (statMessage != null) {
            Message message = new Message();
            message.setMessage(statMessage);

            EventBroker broker = PublisherUtils.getEventBroker();

            try {
                SuperTenantCarbonContext.startTenantFlow();
                int tenantId = SuperTenantCarbonContext.getCurrentContext(PublisherUtils.getConfigurationContext()).getTenantId();
                SuperTenantCarbonContext.getCurrentContext().setTenantId(tenantId);
                SuperTenantCarbonContext.getCurrentContext().getTenantDomain(true);

                broker.publish(message, ActivityPublisherConstants.BAM_REG_PATH);

            } catch (EventBrokerException e) {
                log.error("Can not publish the message ", e);
            } finally {
                SuperTenantCarbonContext.endTenantFlow();
View Full Code Here

Examples of org.wso2.carbon.event.core.EventBroker

        try {
            // set incarnate this thread to supper tenat since carbon contexes can only be
            // run is supertenants
            SuperTenantCarbonContext.startTenantFlow();
            SuperTenantCarbonContext.getCurrentContext().setTenantId(MultitenantConstants.SUPER_TENANT_ID);
            EventBroker eventBroker = EventBrokerBuilder.createEventBroker();
            this.eventServiceRegistration = context.getBundleContext().registerService(EventBroker.class.getName(),
                                                                   eventBroker, null);
            registerAxis2ConfigurationContextObserver(context);
            log.info("Successfully registered the event broker");
            EventBrokerHolder.getInstance().setEventBroker(eventBroker);
View Full Code Here

Examples of org.wso2.carbon.event.core.EventBroker

                    .getTenantDomain() == null) {
                String serverURL = serverConfiguration.getFirstProperty(
                        ServiceStatisticsPublisherConstants.BAM_SERVER_URL);

                if (serverURL != null) {
                    EventBroker broker = eventBroker;

                    Subscription subscription = new Subscription();

                    subscription.setEventSinkURL(serverURL +
                            ServiceStatisticsPublisherConstants.
                                    BAM_SERVICE_STAT_RECEIVER_SERVICE);
                    subscription.setTopicName(ServiceStatisticsPublisherConstants.BAM_REG_PATH);

                    subscription.setOwner(CarbonConstants.REGISTRY_SYSTEM_USERNAME);
                    subscription.setEventDispatcherName(EventBrokerConstants.WS_EVENT_DISPATCHER_NAME);

                    try {
                        SuperTenantCarbonContext.startTenantFlow();
                        int tenantId = SuperTenantCarbonContext.getCurrentContext(StatisticsServiceComponent.getConfigurationContext()).getTenantId();
                        SuperTenantCarbonContext.getCurrentContext().setTenantId(tenantId);
                        SuperTenantCarbonContext.getCurrentContext().getTenantDomain(true);
                        SuperTenantCarbonContext.getCurrentContext().setUsername(CarbonConstants.REGISTRY_SYSTEM_USERNAME);
                        SuperTenantCarbonContext.getCurrentContext().setUserRealm(realmService.getBootstrapRealm());

                        broker.subscribe(subscription);

                    } catch (EventBrokerException e) {
                        log.error("Can not publish the message ", e);
                    } finally {
                        SuperTenantCarbonContext.endTenantFlow();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.