/** * Send the {@link PubSubMessage} to the given url. * * @param url The url to which to send the message. * @param message The message to send. */ protected void sendToURL(String url, PubSubMessage message) { log.debug("Sending message: {} to url: {}", message, url); try (CloseableHttpResponse response = client.execute(makeHttpPost(url, message))) { if (response == null || response.getStatusLine().getStatusCode() != RESTPubSub.OK_200) { log.error("Couldn't POST to REST pubsub server. Got response: {}", response); } } catch (Exception e) { log.error("Error when trying to POST. Message was: {}. Error was: ", message.asJSON(), e); } }