/** * <pre> * Optional attributes for this message. * </pre> * * <code>map<string, string> attributes = 2;</code> */ public Builder putAttributes( java.lang.String key, java.lang.String value) { if (key == null) { throw new java.lang.NullPointerException(); } if (value == null) { throw new java.lang.NullPointerException(); } getMutableAttributes().put(key, value); return this; } /**
/** * <pre> * Optional attributes for this message. * </pre> * * <code>map<string, string> attributes = 2;</code> */ public Builder removeAttributes( java.lang.String key) { if (key == null) { throw new java.lang.NullPointerException(); } getMutableAttributes().remove(key); return this; } /**
/** * <pre> * Optional attributes for this message. * </pre> * * <code>map<string, string> attributes = 2;</code> */ public Builder putAllAttributes( java.util.Map<java.lang.String, java.lang.String> values) { getMutableAttributes().putAll(values); return this; }
@Override public int publish(TopicPath topic, List<OutgoingMessage> outgoingMessages) throws IOException { PublishRequest.Builder request = PublishRequest.newBuilder().setTopic(topic.getPath()); for (OutgoingMessage outgoingMessage : outgoingMessages) { PubsubMessage.Builder message = PubsubMessage.newBuilder().setData(ByteString.copyFrom(outgoingMessage.elementBytes)); if (outgoingMessage.attributes != null) { message.putAllAttributes(outgoingMessage.attributes); } if (timestampAttribute != null) { message .getMutableAttributes() .put(timestampAttribute, String.valueOf(outgoingMessage.timestampMsSinceEpoch)); } if (idAttribute != null && !Strings.isNullOrEmpty(outgoingMessage.recordId)) { message.getMutableAttributes().put(idAttribute, outgoingMessage.recordId); } request.addMessages(message); } PublishResponse response = publisherStub().publish(request.build()); return response.getMessageIdsCount(); }
public Builder clearAttributes() { getMutableAttributes().clear(); return this; } /**
/** * <code>map<string, string> attributes = 2;</code> * * <pre> * Optional attributes for this message. * </pre> */ public Builder putAllAttributes( java.util.Map<java.lang.String, java.lang.String> values) { getMutableAttributes().putAll(values); return this; }