use of org.wso2.carbon.apimgt.eventing.EventPublisherException in project carbon-apimgt by wso2.
the class APIUtil method init.
/**
* To initialize the publisherRoleCache configurations, based on configurations.
*/
public static void init() throws APIManagementException {
APIManagerConfiguration apiManagerConfiguration = ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService().getAPIManagerConfiguration();
String isPublisherRoleCacheEnabledConfiguration = apiManagerConfiguration.getFirstProperty(APIConstants.PUBLISHER_ROLE_CACHE_ENABLED);
isPublisherRoleCacheEnabled = isPublisherRoleCacheEnabledConfiguration == null || Boolean.parseBoolean(isPublisherRoleCacheEnabledConfiguration);
try {
eventPublisherFactory = ServiceReferenceHolder.getInstance().getEventPublisherFactory();
eventPublishers.putIfAbsent(EventPublisherType.ASYNC_WEBHOOKS, eventPublisherFactory.getEventPublisher(EventPublisherType.ASYNC_WEBHOOKS));
eventPublishers.putIfAbsent(EventPublisherType.CACHE_INVALIDATION, eventPublisherFactory.getEventPublisher(EventPublisherType.CACHE_INVALIDATION));
eventPublishers.putIfAbsent(EventPublisherType.GLOBAL_CACHE_INVALIDATION, eventPublisherFactory.getEventPublisher(EventPublisherType.GLOBAL_CACHE_INVALIDATION));
eventPublishers.putIfAbsent(EventPublisherType.NOTIFICATION, eventPublisherFactory.getEventPublisher(EventPublisherType.NOTIFICATION));
eventPublishers.putIfAbsent(EventPublisherType.TOKEN_REVOCATION, eventPublisherFactory.getEventPublisher(EventPublisherType.TOKEN_REVOCATION));
eventPublishers.putIfAbsent(EventPublisherType.BLOCKING_EVENT, eventPublisherFactory.getEventPublisher(EventPublisherType.BLOCKING_EVENT));
eventPublishers.putIfAbsent(EventPublisherType.KEY_TEMPLATE, eventPublisherFactory.getEventPublisher(EventPublisherType.KEY_TEMPLATE));
eventPublishers.putIfAbsent(EventPublisherType.KEYMGT_EVENT, eventPublisherFactory.getEventPublisher(EventPublisherType.KEYMGT_EVENT));
} catch (EventPublisherException e) {
log.error("Could not initialize the event publishers. Events might not be published properly.");
throw new APIManagementException(e);
}
}
use of org.wso2.carbon.apimgt.eventing.EventPublisherException in project carbon-apimgt by wso2.
the class APIManagerComponent method configureNotificationEventPublisher.
/**
* Method to configure wso2event type event adapter to be used for event notification.
*/
private void configureNotificationEventPublisher() throws APIManagementException {
Map<String, String> properties = new HashMap<>();
if (ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService() != null) {
APIManagerConfiguration configuration = ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService().getAPIManagerConfiguration();
if (configuration.getEventHubConfigurationDto().getEventHubPublisherConfiguration() != null && configuration.getEventHubConfigurationDto().isEnabled()) {
EventHubConfigurationDto eventHubConfigurationDto = configuration.getEventHubConfigurationDto();
EventHubConfigurationDto.EventHubPublisherConfiguration eventHubPublisherConfiguration = eventHubConfigurationDto.getEventHubPublisherConfiguration();
properties.put(APIConstants.RECEIVER_URL, eventHubPublisherConfiguration.getReceiverUrlGroup());
properties.put(APIConstants.AUTHENTICATOR_URL, eventHubPublisherConfiguration.getAuthUrlGroup());
properties.put(APIConstants.USERNAME, eventHubConfigurationDto.getUsername());
properties.put(APIConstants.PASSWORD, eventHubConfigurationDto.getPassword());
properties.put(APIConstants.PROTOCOL, eventHubPublisherConfiguration.getType());
properties.put(APIConstants.PUBLISHING_MODE, APIConstants.NON_BLOCKING);
properties.put(APIConstants.PUBLISHING_TIME_OUT, "0");
for (String key : eventHubPublisherConfiguration.getProperties().keySet()) {
properties.put(key, eventHubPublisherConfiguration.getProperties().get(key));
}
properties.put(APIConstants.IS_ENABLED, Boolean.toString(configuration.getEventHubConfigurationDto().isEnabled()));
try {
ServiceReferenceHolder.getInstance().getEventPublisherFactory().configure(properties);
} catch (EventPublisherException e) {
throw new APIManagementException(e);
}
} else {
log.info("Wso2Event Publisher not enabled.");
}
} else {
log.info("api-manager.xml not loaded. Wso2Event Publisher will not be enabled.");
}
}
Aggregations