@Override public void send(PubSubMessage message) { String url = (String) message.getMetadata().getContent(); log.debug("Extracted url to which to send results: {}", url); sendToURL(url, message); } }
private Metadata withSignal(Metadata metadata, Metadata.Signal signal) { // Don't change the non-readonly bits of metadata in place since that might affect tuples emitted but pending. Metadata copy = new Metadata(signal, null); if (metadata != null) { copy.setContent(metadata.getContent()); } return copy; }
private Metadata withSignal(Metadata metadata, Metadata.Signal signal) { // Don't change the non-readonly bits of metadata in place since that might affect tuples emitted but pending. Metadata copy = new Metadata(signal, null); if (metadata != null) { copy.setContent(metadata.getContent()); } return copy; }
private static boolean isSameMetadata(Object actual, Object expected) { Metadata actualMetadata = (Metadata) actual; Metadata expectedMetadata = (Metadata) expected; if (actualMetadata.getSignal() != expectedMetadata.getSignal()) { return false; } Serializable actualContent = actualMetadata.getContent(); Serializable expectedContent = expectedMetadata.getContent(); return actualContent == expectedContent || actualContent.equals(expectedContent); }
@Override public void send(PubSubMessage message) throws PubSubException { Metadata metadata = message.getMetadata(); // Remove the content String content = metadata.getContent().toString(); log.debug("Removing metadata {} for result {}@{}: {}", content, message.getId(), message.getSequence(), message.getContent()); metadata.setContent(null); String serializedMessage = message.asJSON(); Tuple tuple = new DRPCTuple(new Values(serializedMessage, content)); // This sends the message through DRPC and not to the collector but it acks or fails accordingly. bolt.execute(tuple); if (!collector.isAcked()) { throw new PubSubException("Message not acked. Unable to send message through DRPC:\n " + serializedMessage); } // Otherwise, we're good to proceed collector.reset(); }
@Override public void send(PubSubMessage message) throws PubSubException { Metadata metadata = message.getMetadata(); // Remove the content String content = metadata.getContent().toString(); log.debug("Removing metadata {} for result {}@{}: {}", content, message.getId(), message.getSequence(), message.getContent()); metadata.setContent(null); String serializedMessage = message.asJSON(); Tuple tuple = new DRPCTuple(new Values(serializedMessage, content)); // This sends the message through DRPC and not to the collector but it acks or fails accordingly. bolt.execute(tuple); if (!collector.isAcked()) { throw new PubSubException("Message not acked. Unable to send message through DRPC:\n " + serializedMessage); } // Otherwise, we're good to proceed collector.reset(); }
Assert.assertTrue(actual.hasMetadata()); Metadata metadata = actual.getMetadata(); Assert.assertEquals(metadata.getContent(), makeReturnInfo("fakefoo", "testHost", 0)); Assert.assertTrue(actual.hasMetadata()); metadata = actual.getMetadata(); Assert.assertEquals(metadata.getContent(), makeReturnInfo("fakefoo", "testHost", 1)); Assert.assertTrue(actual.hasMetadata()); metadata = actual.getMetadata(); Assert.assertEquals(metadata.getContent(), makeReturnInfo("fakebar", "testHost", 2));