Package org.wso2.carbon.event.core

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


            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

    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

        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

                    .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

        if (topicValue == null) {
            handleException("Topic for the event cannot be found", synCtx);
        } else {
            org.apache.axis2.context.MessageContext mc =
                    ((Axis2MessageContext)synCtx).getAxis2MessageContext();
            EventBroker broker = (EventBroker) mc.getConfigurationContext().
                    getProperty("mediation.event.broker");
            if (broker == null) {
                handleException("EventBroker cannot be found", synCtx);
            } else {
                Message message = new Message();
                if (expression == null) {
                    message.setMessage(synCtx.getEnvelope().getBody().getFirstElement());
                } else {
                    try {
                        Object o = expression.selectSingleNode(synCtx);
                        if (o instanceof OMElement)  {
                            message.setMessage((OMElement)o);
                        } else {
                            handleException("The result of the expression:" +
                                    expression + " should be an OMElement", synCtx);
                        }
                    } catch (JaxenException e) {
                        handleException("Error evaluating the expression: " +
                                expression, synCtx);
                    }
                }

                int tenantID = SuperTenantCarbonContext.getCurrentContext(
                        mc.getConfigurationContext()).getTenantId();
                try {
                    SuperTenantCarbonContext.startTenantFlow();
                    SuperTenantCarbonContext.getCurrentContext().setTenantId(tenantID);
                    SuperTenantCarbonContext.getCurrentContext().getTenantDomain(true);
                    broker.publish(message, topicValue);
                } catch (EventBrokerException e) {
                    handleException("Error publishing the event to the broker", e, synCtx);
                } catch (Exception e) {
                    log.error("Error in setting tenant information", e);
                } finally {
View Full Code Here

    public void cleanup() throws DataServiceFault {
        if (log.isDebugEnabled()) {
            log.debug("Data Service '" + this.getName() + "' cleanup start..");
        }
        /* remove event subscriptions */
        EventBroker eventBroker =
                DataServicesDSComponent.getEventBroker();
        if (eventBroker != null) {
            this.clearDataServicesEventSubscriptions(eventBroker);
        }
        /* cleanup configs */
 
View Full Code Here

    public void publish(String topicName,
                        OMElement message,
                        BrokerConfiguration brokerConfiguration)
            throws BrokerEventProcessingException {

        EventBroker eventBroker = BrokerServiceValueHolder.getEventBroker();
        Message eventMessage = new Message();
        eventMessage.setMessage(message);
        try {
            eventBroker.publishRobust(eventMessage, topicName);
        } catch (EventBrokerException e) {
            throw new BrokerEventProcessingException("Can not publish the to local broker ", e);
        }
    }
View Full Code Here

     * @param topic     Topic
     * @throws DataServiceFault DataServiceFault
     */
    private void sendMessageToTopic(OMElement omMessage, String topic) throws DataServiceFault {
        try {
            EventBroker eventBroker = DataServicesDSComponent.getEventBroker();
            if (eventBroker == null) {
              throw new DataServiceFault("Event broker instance is not available");
            }
            Message message = new Message();
            message.setMessage(omMessage);
            eventBroker.publish(message, topic);
        } catch (Exception e) {
          throw new DataServiceFault(e, "Error in publishing event for topic: " +
                    topic + " message:-\n" + omMessage);
        }
    }
View Full Code Here

    }

    public static void registerEventBrokerServiceListener(
            EventBrokerServiceListener listener) {
        synchronized (dsComponentLock) {
            EventBroker eventBroker = getEventBroker();
            if (eventBroker == null) {
                eventBrokerServiceListeners.add(listener);
            } else {
                listener.setEventBroker(eventBroker);
            }
View Full Code Here

TOP

Related Classes of org.wso2.carbon.event.core.EventBroker

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.