PubsubMessage pubsubMessage = receivedMessage.getMessage(); byte[] body = pubsubMessage.decodeData();
byte[] elementBytes = pubsubMessage.decodeData(); if (elementBytes == null) { elementBytes = new byte[0];
receivedMessage.getMessage(); if (pubsubMessage != null && pubsubMessage.decodeData() != null) { System.out.println( new String(pubsubMessage.decodeData(), "UTF-8"));
@ProcessElement public void processElement(ProcessContext context) { int num = 0; Instant endTime = Instant.now().plus(maxTime); while (num < maxNum && Instant.now().isBefore(endTime)) { try { List<String> ackIds = new ArrayList<>(); List<ReceivedMessage> receivedMessages = client.pull(spec.getDatasetProperties().subscription.getValue(), maxNum - num); if (receivedMessages == null) { continue; } for (ReceivedMessage receivedMessage : receivedMessages) { context.output(new PubsubMessage(receivedMessage.getMessage().decodeData(), ImmutableMap.<String, String> of())); ackIds.add(receivedMessage.getAckId()); num++; } if (ack && !ackIds.isEmpty()) { // do not call this when getSample, else the message will be removed client.ack(spec.getDatasetProperties().subscription.getValue(), ackIds); } } catch (IOException e) { throw TalendRuntimeException.createUnexpectedException(e); } } } }