//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;
}