public void publishEvent(ResponsePublisherDTO responsePublisherDTO) { DataBridgeResponsePublisherDTO dataBridgeResponsePublisherDTO = new DataBridgeResponsePublisherDTO(responsePublisherDTO); try { DataPublisherUtil.getApiManagerAnalyticsConfiguration().getResponseStreamName(); DataPublisherUtil.getApiManagerAnalyticsConfiguration().getResponseStreamVersion(); dataBridgeResponsePublisherDTO.createPayload(); // Publish Response Data dataPublisher.publish( DataPublisherUtil.getApiManagerAnalyticsConfiguration().getResponseStreamName(), DataPublisherUtil.getApiManagerAnalyticsConfiguration().getResponseStreamVersion(), System.currentTimeMillis(), new Object[] {"external"}, null, (Object[]) dataBridgeResponsePublisherDTO.createPayload()); } catch (AgentException e) { log.error("Error while publishing Response event", e); } }
public void init() { try { if (log.isDebugEnabled()) { log.debug("Initializing APIMgtUsageDataBridgeDataPublisher"); } this.dataPublisher = getDataPublisher(); // If Request Stream Definition does not exist. if (!dataPublisher.isStreamDefinitionAdded( DataPublisherUtil.getApiManagerAnalyticsConfiguration().getRequestStreamName(), DataPublisherUtil.getApiManagerAnalyticsConfiguration().getRequestStreamVersion())) { // Get Request Stream Definition String requestStreamDefinition = DataBridgeRequestPublisherDTO.getStreamDefinition(); // Add Request Stream Definition. dataPublisher.addStreamDefinition( requestStreamDefinition, DataPublisherUtil.getApiManagerAnalyticsConfiguration().getRequestStreamName(), DataPublisherUtil.getApiManagerAnalyticsConfiguration().getRequestStreamVersion()); } // If Response Stream Definition does not exist. if (!dataPublisher.isStreamDefinitionAdded( DataPublisherUtil.getApiManagerAnalyticsConfiguration().getResponseStreamName(), DataPublisherUtil.getApiManagerAnalyticsConfiguration().getResponseStreamVersion())) { // Get Response Stream Definition. String responseStreamDefinition = DataBridgeResponsePublisherDTO.getStreamDefinition(); // Add Response Stream Definition. dataPublisher.addStreamDefinition( responseStreamDefinition, DataPublisherUtil.getApiManagerAnalyticsConfiguration().getResponseStreamName(), DataPublisherUtil.getApiManagerAnalyticsConfiguration().getResponseStreamVersion()); } // If Fault Stream Definition does not exist. if (!dataPublisher.isStreamDefinitionAdded( DataPublisherUtil.getApiManagerAnalyticsConfiguration().getFaultStreamName(), DataPublisherUtil.getApiManagerAnalyticsConfiguration().getFaultStreamVersion())) { // Get Fault Stream Definition String faultStreamDefinition = DataBridgeFaultPublisherDTO.getStreamDefinition(); // Add Fault Stream Definition; dataPublisher.addStreamDefinition( faultStreamDefinition, DataPublisherUtil.getApiManagerAnalyticsConfiguration().getFaultStreamName(), DataPublisherUtil.getApiManagerAnalyticsConfiguration().getFaultStreamVersion()); } // If Throttle Stream Definition does not exist. if (!dataPublisher.isStreamDefinitionAdded( DataPublisherUtil.getApiManagerAnalyticsConfiguration().getThrottleStreamName(), DataPublisherUtil.getApiManagerAnalyticsConfiguration().getThrottleStreamVersion())) { // Get Throttle Stream Definition String throttleStreamDefinition = DataBridgeThrottlePublisherDTO.getStreamDefinition(); // Add Throttle Stream Definition; dataPublisher.addStreamDefinition( throttleStreamDefinition, DataPublisherUtil.getApiManagerAnalyticsConfiguration().getThrottleStreamName(), DataPublisherUtil.getApiManagerAnalyticsConfiguration().getThrottleStreamVersion()); } } catch (Exception e) { log.error("Error initializing APIMgtUsageDataBridgeDataPublisher", e); } }