diff --git a/README.md b/README.md index ad2ae922..628655c6 100644 --- a/README.md +++ b/README.md @@ -112,26 +112,26 @@ contents: ```java package com.example; -import com.example.PubSubBackground.PubSubMessage; import com.google.cloud.functions.BackgroundFunction; import com.google.cloud.functions.Context; import java.util.Map; import java.util.logging.Logger; +// This is the Pub/Sub message format from the Pub/Sub emulator. +class PubSubMessage { + String data; + Map attributes; + String messageId; + String publishTime; +} + public class PubSubBackground implements BackgroundFunction { private static final Logger logger = Logger.getLogger(PubSubBackground.class.getName()); @Override public void accept(PubSubMessage pubSubMessage, Context context) { - logger.info("Received message with id " + pubSubMessage.messageId); - } - - public static class PubSubMessage { - public String data; - public Map attributes; - public String messageId; - public String publishTime; + logger.info("Received message with id " + context.eventId()); } } ```