@Override public void publish(Object payload, DynamicOptions transportOptions) { String topicQueueName = destination.getValue(transportOptions); executorService.execute(new JMSPublisher(topicQueueName, jmsStaticProperties, clientConnector, payload)); }
/** * This method will be called when events need to be published via this sink * * @param payload payload of the event based on the supported event class exported by the extensions * @param dynamicOptions holds the dynamic options of this sink and Use this object to obtain dynamic options. */ @Override public void publish(Object payload, DynamicOptions dynamicOptions) { //get the dynamic parameter String headers = httpHeaderOption.getValue(dynamicOptions); List<Header> headersList = HttpSinkUtil.getHeaders(headers); if (publisherURLOption.isStatic()) { publisherURL = publisherURLOption.getValue(); } else { publisherURL = publisherURLOption.getValue(dynamicOptions); } if (authType.equals(HttpConstants.BASIC_AUTH) || authType.equals(HttpConstants.NO_AUTH)) { sendRequest(payload, dynamicOptions, headersList, HttpConstants.MAXIMUM_TRY_COUNT); } else { sendOauthRequest(payload, dynamicOptions, headersList); } }
/** * This method will be called before the processing method. * Intention to establish connection to publish event. * such that the system will take care retrying for connection */ @Override public void connect() { if (publisherURLOption.isStatic()) { log.info(streamID + " has successfully connected to " + publisherURL); } }
authType = HttpConstants.NO_AUTH; if (publisherURLOption.isStatic()) { initClientConnector(null);
@Override public void publish(Object payload, DynamicOptions transportOptions) throws ConnectionUnavailableException { String topic = topicOption.getValue(transportOptions); String partitionNo = partitionOption.getValue(transportOptions); try { if (null == partitionNo) { producer.send(new ProducerRecord<>(topic, payload.toString())); } else { producer.send(new ProducerRecord<>(topic, partitionNo, payload.toString())); } } catch (Exception e) { log.error(String.format("Failed to publish the message to [topic] %s [partition-no] %s. Error: %s", topic, partitionNo, e.getMessage()), e); } }
public void publish(Object payload, DynamicOptions dynamicOptions) throws ConnectionUnavailableException { if (optionSubject != null) { String subject = optionSubject.getValue(dynamicOptions); emailProperties.put(EmailConstants.TRANSPORT_MAIL_HEADER_SUBJECT, subject); String to = optionTo.getValue(dynamicOptions); emailProperties.put(EmailConstants.TRANSPORT_MAIL_HEADER_TO, to); String cc = optionCc.getValue(dynamicOptions); emailProperties.put(EmailConstants.TRANSPORT_MAIL_HEADER_CC, cc); String bcc = optionBcc.getValue(dynamicOptions); emailProperties.put(EmailConstants.TRANSPORT_MAIL_HEADER_BCC, bcc); String contentType = optionContentType.getValue(dynamicOptions); emailProperties.put(EmailConstants.TRANSPORT_MAIL_HEADER_CONTENT_TYPE, contentType); if ((attachmentOption != null) && (!attachmentOption.isStatic())) { attachments = Arrays.asList(attachmentOption.getValue(dynamicOptions).split(EmailConstants.COMMA_SEPERATOR));
private Map<String, Object> getTrpProperties(DynamicOptions dynamicOptions) { Event event = dynamicOptions.getEvent(); Object[] data = event.getData(); List<Attribute> attributes = outputStreamDefinition.getAttributeList(); Map<String, Object> trpProperties = new HashMap<>(); for (int i = 0; i < attributes.size(); i++) { trpProperties.put(attributes.get(i).getName(), data[i]); } if (isDownloadEnabled) { trpProperties.put(HttpConstants.DOWNLOAD_PATH, downloadPath.getValue(dynamicOptions)); } return trpProperties; }
public void publish(Object payload, DynamicOptions dynamicOptions) throws ConnectionUnavailableException { try { MqttMessage message = new MqttMessage(); byte[] byteArray; if (payload instanceof byte[]) { byteArray = (byte[]) payload; } else { byteArray = payload.toString().getBytes("UTF-8"); } message.setPayload(byteArray); int qos = Integer.parseInt(qosOption.getValue(dynamicOptions)); boolean messageRetain = Boolean.parseBoolean(messageRetainOption.getValue(dynamicOptions)); message.setQos(qos); message.setRetained(messageRetain); String topic = topicOption.getValue(dynamicOptions); client.publish(topic, message); } catch (MqttException e) { log.error("Error occurred when publishing message to the MQTT broker: " + brokerURL + " in " + streamDefinition, e); } catch (UnsupportedEncodingException e) { log.error("Event could not be encoded in UTF-8, hence it could not be published to MQTT broker: " + brokerURL + " in " + streamDefinition, e); } }
private int sendRequest(Object payload, DynamicOptions dynamicOptions, List<Header> headersList, int tryCount) { if (!publisherURLOption.isStatic()) { super.initClientConnector(dynamicOptions); String httpMethod = EMPTY_STRING.equals(httpMethodOption.getValue(dynamicOptions)) ? HttpConstants.METHOD_DEFAULT : httpMethodOption.getValue(dynamicOptions); String contentType = HttpSinkUtil.getContentType(mapType, headersList); String messageBody = getMessageBody(payload);
public void getAccessToken(DynamicOptions dynamicOptions, String encodedAuth, String tokenURL) { this.tokenURL = tokenURL; HttpsClient httpsClient = new HttpsClient(); if (!HttpConstants.EMPTY_STRING.equals(oauthUsername) && !HttpConstants.EMPTY_STRING.equals(oauthUserPassword)) { httpsClient.getPasswordGrantAccessToken(tokenURL, clientStoreFile, clientStorePass, oauthUsername, oauthUserPassword, encodedAuth); } else if (!HttpConstants.EMPTY_STRING.equals(refreshToken.getValue(dynamicOptions)) || !accessTokenCache.getRefreshtoken(encodedAuth).equals(HttpConstants.EMPTY_STRING)) { httpsClient.getRefreshGrantAccessToken(tokenURL, clientStoreFile, clientStorePass, encodedAuth, refreshToken.getValue(dynamicOptions)); } else { httpsClient.getClientGrantAccessToken(tokenURL, clientStoreFile, clientStorePass, encodedAuth); } }
private int sendRequest(Object payload, DynamicOptions dynamicOptions, List<Header> headersList) { if (publisherURLOption.isStatic()) { if (clientConnector != null) { clientConnector.close(); String httpMethod = EMPTY_STRING.equals(httpMethodOption.getValue(dynamicOptions)) ? HttpConstants.METHOD_DEFAULT : httpMethodOption.getValue(dynamicOptions); String contentType = HttpSinkUtil.getContentType(mapType, headersList); String messageBody = getMessageBody(payload);
@Override public void publish(Object payload, DynamicOptions transportOptions) throws ConnectionUnavailableException { String key = keyOption.getValue(transportOptions); Object payloadToSend = null; try {
/** * This method will be called when events need to be published via this sink * * @param payload payload of the event based on the supported event class exported by the extensions * @param dynamicOptions holds the dynamic options of this sink and Use this object to obtain dynamic options. * @throws ConnectionUnavailableException if end point is unavailable the ConnectionUnavailableException thrown * such that the system will take care retrying for connection */ @Override public void publish(Object payload, DynamicOptions dynamicOptions) throws ConnectionUnavailableException { String headers = httpHeaderOption.getValue(dynamicOptions); List<Header> headersList = HttpSinkUtil.getHeaders(headers); String messageId = messageIdOption.getValue(dynamicOptions); String contentType = HttpSinkUtil.getContentType(mapType, headersList); HTTPSourceRegistry. getRequestSource(sourceId).handleCallback(messageId, (String) payload, headersList, contentType); }
@Override public void publish(Object payload, DynamicOptions transportOptions) throws ConnectionUnavailableException { String topic = topicOption.getValue(transportOptions); String partitionNo = partitionOption.getValue(transportOptions); String key = keyOption.getValue(transportOptions); Object payloadToSend;
/** * This method will be called when events need to be published via this sink * * @param payload payload of the event based on the supported event class exported by the extensions * @param dynamicOptions holds the dynamic options of this sink and Use this object to obtain dynamic options. */ @Override public void publish(Object payload, DynamicOptions dynamicOptions) { //get the dynamic parameter String headers = httpHeaderOption.getValue(dynamicOptions); List<Header> headersList = HttpSinkUtil.getHeaders(headers); if (authType.equals(HttpConstants.BASIC_AUTH) || authType.equals(HttpConstants.NO_AUTH)) { sendRequest(payload, dynamicOptions, headersList); } else { sendOauthRequest(payload, dynamicOptions, headersList); } }
String uri = uriOption.getValue(dynamicOptions); BinaryCarbonMessage binaryCarbonMessage = new BinaryCarbonMessage(ByteBuffer.wrap(byteArray), true); properties.put(Constants.URI, uri);
SiddhiAppContext siddhiAppContext) { this.streamDefinition = streamDefinition; enclosingElement = optionHolder.getOrCreateOption(OPTION_ENCLOSING_ELEMENT, null).getValue(); if (enclosingElement != null) { endingElement = getClosingElement(enclosingElement); xmlValidationEnabled = Boolean.parseBoolean(validateXmlOption.getValue()); if (xmlValidationEnabled) { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
byteArray = payload.toString().getBytes("UTF-8"); String exchangeName = exchangeNameOption.getValue(dynamicOptions); String exchangeType = exchangeTypeOption.getValue(dynamicOptions); String headers = headerOption.getValue(dynamicOptions); String messageId = messageIdOption.getValue(dynamicOptions); int priority = Integer.parseInt(priorityOption.getValue(dynamicOptions)); String correlationId = correlationIdOption.getValue(dynamicOptions); Date timestamp; if (timestampString == null) { map = RabbitMQSinkUtil.getHeaders(headers); String routingKey = routingKeyOption.getValue(dynamicOptions); props = props.builder(). deliveryMode(deliveryMode). boolean exchangeAutoDelete = Boolean.parseBoolean(exchangeDurableAsStringOption.getValue(dynamicOptions)); boolean exchangeDurable = Boolean.parseBoolean(exchangeAutoDeleteAsStringOption.getValue(dynamicOptions)); } catch (IOException e) { log.error("Error in sending the message to the " + RabbitMQConstants.RABBITMQ_EXCHANGE_NAME + " = " + exchangeNameOption.getValue() + " in RabbitMQ broker at " + streamDefinition, e); } catch (TimeoutException e) { throw new SiddhiAppCreationException( "Timeout while publishing the events to " + exchangeNameOption.getValue() + " in " + "RabbitMQ server", e);