Codota Logo
PubSubMessage.asJSON
Code IndexAdd Codota to your IDE (free)

How to use
asJSON
method
in
com.yahoo.bullet.pubsub.PubSubMessage

Best Java code snippets using com.yahoo.bullet.pubsub.PubSubMessage.asJSON (Showing top 9 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
DateTime d =
  • Codota Iconnew DateTime()
  • Codota IconDateTimeFormatter formatter;String text;formatter.parseDateTime(text)
  • Codota IconObject instant;new DateTime(instant)
  • Smart code suggestions by Codota
}
origin: com.yahoo.bullet/bullet-core

@Override
public String toString() {
  return asJSON();
}
origin: com.yahoo.bullet/bullet-core

  private HttpPost makeHttpPost(String url, PubSubMessage message) throws UnsupportedEncodingException {
    HttpPost httpPost = new HttpPost(url);
    httpPost.setEntity(new StringEntity(message.asJSON()));
    httpPost.setHeader(CONTENT_TYPE, APPLICATION_JSON);
    RequestConfig requestConfig =
        RequestConfig.custom().setConnectTimeout(connectTimeout).setSocketTimeout(connectTimeout).build();
    httpPost.setConfig(requestConfig);
    return httpPost;
  }
}
origin: com.yahoo.bullet/bullet-core

/**
 * 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);
  }
}
origin: bullet-db/bullet-storm

public static String makeMessage(String id, String content, int sequence) {
  return new PubSubMessage(id, content, sequence).asJSON();
}
public static Object makeMessageID(String id, int index) {
origin: com.yahoo.bullet/bullet-storm

@Override
public void send(PubSubMessage message) throws PubSubException {
  String url = urls.get();
  String id = message.getId();
  String json = message.asJSON();
  log.info("Posting to {} for id {}", url, id);
  log.debug("Posting to {} with body {}", url, json);
  client.preparePost(url).setBody(json).execute().toCompletableFuture()
     .exceptionally(this::handleException)
     .thenAcceptAsync(createResponseConsumer(id));
}
origin: bullet-db/bullet-storm

@Override
public void send(PubSubMessage message) throws PubSubException {
  String url = urls.get();
  String id = message.getId();
  String json = message.asJSON();
  log.info("Posting to {} for id {}", url, id);
  log.debug("Posting to {} with body {}", url, json);
  client.preparePost(url).setBody(json).execute().toCompletableFuture()
     .exceptionally(this::handleException)
     .thenAcceptAsync(createResponseConsumer(id));
}
origin: bullet-db/bullet-storm

@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();
}
origin: com.yahoo.bullet/bullet-storm

@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();
}
origin: bullet-db/bullet-storm

@Test(timeOut = 5000L)
public void testReadingOkResponse() throws Exception {
  PubSubMessage expected = new PubSubMessage("foo", "response");
  CompletableFuture<Response> response = getOkFuture(getOkResponse(expected.asJSON()));
  AsyncHttpClient mockClient = mockClientWith(response);
  pubscriber.setClient(mockClient);
  pubscriber.send(new PubSubMessage("foo", "bar"));
  // This is async (but practically still very fast since we mocked the response), so need a timeout.
  PubSubMessage actual = fetchAsync().get();
  Assert.assertNotNull(actual);
  Assert.assertEquals(actual.getId(), expected.getId());
  Assert.assertEquals(actual.getContent(), expected.getContent());
}
com.yahoo.bullet.pubsubPubSubMessageasJSON

Popular methods of PubSubMessage

  • <init>
    Constructor for a message having content, Metadata and a sequence number.
  • getId
  • getMetadata
  • getSequence
  • fromJSON
    Converts a json representation back to an instance.
  • getContent
  • hasMetadata
    Check if message has Metadata.
  • hasSignal
    Check if message has a given Signal.
  • setMetadata

Popular in Java

  • Start an intent from android
  • onCreateOptionsMenu (Activity)
  • orElseThrow (Optional)
  • getApplicationContext (Context)
  • MalformedURLException (java.net)
    Thrown to indicate that a malformed URL has occurred. Either no legal protocol could be found in a s
  • BitSet (java.util)
    This class implements a vector of bits that grows as needed. Each component of the bit set has a boo
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • Stack (java.util)
    The Stack class represents a last-in-first-out (LIFO) stack of objects. It extends class Vector with
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now