Java Code Examples for com.google.cloud.pubsub.v1.AckReplyConsumer#nack()

The following examples show how to use com.google.cloud.pubsub.v1.AckReplyConsumer#nack() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExportMessageReceiver.java    From healthcare-dicom-dicomweb-adapter with Apache License 2.0 5 votes vote down vote up
@Override
public void receiveMessage(PubsubMessage message, AckReplyConsumer consumer) {
  try {
    MonitoringService.addEvent(Event.REQUEST);
    dicomSender.send(message);
    consumer.ack();
  } catch (Exception e) {
    MonitoringService.addEvent(Event.ERROR);
    e.printStackTrace();
    consumer.nack();
  }
}
 
Example 2
Source File: RiskAnalysisLDiversity.java    From java-docs-samples with Apache License 2.0 5 votes vote down vote up
private static void handleMessage(
    DlpJob job,
    SettableApiFuture<Boolean> done,
    PubsubMessage pubsubMessage,
    AckReplyConsumer ackReplyConsumer) {
  String messageAttribute = pubsubMessage.getAttributesMap().get("DlpJobName");
  if (job.getName().equals(messageAttribute)) {
    done.set(true);
    ackReplyConsumer.ack();
  } else {
    ackReplyConsumer.nack();
  }
}
 
Example 3
Source File: InspectDatastoreEntity.java    From java-docs-samples with Apache License 2.0 5 votes vote down vote up
private static void handleMessage(
    DlpJob job,
    SettableApiFuture<Boolean> done,
    PubsubMessage pubsubMessage,
    AckReplyConsumer ackReplyConsumer) {
  String messageAttribute = pubsubMessage.getAttributesMap().get("DlpJobName");
  if (job.getName().equals(messageAttribute)) {
    done.set(true);
    ackReplyConsumer.ack();
  } else {
    ackReplyConsumer.nack();
  }
}
 
Example 4
Source File: InspectGcsFile.java    From java-docs-samples with Apache License 2.0 5 votes vote down vote up
private static void handleMessage(
    DlpJob job,
    SettableApiFuture<Boolean> done,
    PubsubMessage pubsubMessage,
    AckReplyConsumer ackReplyConsumer) {
  String messageAttribute = pubsubMessage.getAttributesMap().get("DlpJobName");
  if (job.getName().equals(messageAttribute)) {
    done.set(true);
    ackReplyConsumer.ack();
  } else {
    ackReplyConsumer.nack();
  }
}
 
Example 5
Source File: RiskAnalysisCategoricalStats.java    From java-docs-samples with Apache License 2.0 5 votes vote down vote up
private static void handleMessage(
    DlpJob job,
    SettableApiFuture<Boolean> done,
    PubsubMessage pubsubMessage,
    AckReplyConsumer ackReplyConsumer) {
  String messageAttribute = pubsubMessage.getAttributesMap().get("DlpJobName");
  if (job.getName().equals(messageAttribute)) {
    done.set(true);
    ackReplyConsumer.ack();
  } else {
    ackReplyConsumer.nack();
  }
}
 
Example 6
Source File: InspectBigQueryTableWithSampling.java    From java-docs-samples with Apache License 2.0 5 votes vote down vote up
private static void handleMessage(
    DlpJob job,
    SettableApiFuture<Boolean> done,
    PubsubMessage pubsubMessage,
    AckReplyConsumer ackReplyConsumer) {
  String messageAttribute = pubsubMessage.getAttributesMap().get("DlpJobName");
  if (job.getName().equals(messageAttribute)) {
    done.set(true);
    ackReplyConsumer.ack();
  } else {
    ackReplyConsumer.nack();
  }
}
 
Example 7
Source File: InspectGcsFileWithSampling.java    From java-docs-samples with Apache License 2.0 5 votes vote down vote up
private static void handleMessage(
    DlpJob job,
    SettableApiFuture<Boolean> done,
    PubsubMessage pubsubMessage,
    AckReplyConsumer ackReplyConsumer) {
  String messageAttribute = pubsubMessage.getAttributesMap().get("DlpJobName");
  if (job.getName().equals(messageAttribute)) {
    done.set(true);
    ackReplyConsumer.ack();
  } else {
    ackReplyConsumer.nack();
  }
}
 
Example 8
Source File: RiskAnalysisKMap.java    From java-docs-samples with Apache License 2.0 5 votes vote down vote up
private static void handleMessage(
    DlpJob job,
    SettableApiFuture<Boolean> done,
    PubsubMessage pubsubMessage,
    AckReplyConsumer ackReplyConsumer) {
  String messageAttribute = pubsubMessage.getAttributesMap().get("DlpJobName");
  if (job.getName().equals(messageAttribute)) {
    done.set(true);
    ackReplyConsumer.ack();
  } else {
    ackReplyConsumer.nack();
  }
}
 
Example 9
Source File: RiskAnalysisKAnonymity.java    From java-docs-samples with Apache License 2.0 5 votes vote down vote up
private static void handleMessage(
    DlpJob job,
    SettableApiFuture<Boolean> done,
    PubsubMessage pubsubMessage,
    AckReplyConsumer ackReplyConsumer) {
  String messageAttribute = pubsubMessage.getAttributesMap().get("DlpJobName");
  if (job.getName().equals(messageAttribute)) {
    done.set(true);
    ackReplyConsumer.ack();
  } else {
    ackReplyConsumer.nack();
  }
}
 
Example 10
Source File: RiskAnalysisNumericalStats.java    From java-docs-samples with Apache License 2.0 5 votes vote down vote up
private static void handleMessage(
    DlpJob job,
    SettableApiFuture<Boolean> done,
    PubsubMessage pubsubMessage,
    AckReplyConsumer ackReplyConsumer) {
  String messageAttribute = pubsubMessage.getAttributesMap().get("DlpJobName");
  if (job.getName().equals(messageAttribute)) {
    done.set(true);
    ackReplyConsumer.ack();
  } else {
    ackReplyConsumer.nack();
  }
}
 
Example 11
Source File: InspectBigQueryTable.java    From java-docs-samples with Apache License 2.0 5 votes vote down vote up
private static void handleMessage(
    DlpJob job,
    SettableApiFuture<Boolean> done,
    PubsubMessage pubsubMessage,
    AckReplyConsumer ackReplyConsumer) {
  String messageAttribute = pubsubMessage.getAttributesMap().get("DlpJobName");
  if (job.getName().equals(messageAttribute)) {
    done.set(true);
    ackReplyConsumer.ack();
  } else {
    ackReplyConsumer.nack();
  }
}
 
Example 12
Source File: MessageReceiverImpl.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@Override
public void receiveMessage(PubsubMessage message, AckReplyConsumer consumer) {
  try {
    messages.put(new MessageReplyConsumerBundle(message, consumer));
  } catch (InterruptedException e) {
    LOG.warn(
        "Thread interrupted while trying to enqueue message with id '{}'. Sending nack. Message will be re-received",
        message.getMessageId()
    );
    consumer.nack();
    Thread.currentThread().interrupt();
  }
}