T
- the class of payload objects that this function expects.@FunctionalInterface public interface BackgroundFunction<T>
Here is an example of an implementation that accesses the messageId
property from
a payload that matches a user-defined PubSubMessage
class:
public class Example implementsBackgroundFunction<PubSubMessage>
{ private static final Logger logger = Logger.getLogger(Example.class.getName());@Override
public void accept(PubSubMessage pubSubMessage, Context context) { logger.info("Got messageId " + pubSubMessage.messageId); } } // Where PubSubMessage is a user-defined class like this: public class PubSubMessage { String data;Map<String, String>
attributes; String messageId; String publishTime; }
Modifier and Type | Method and Description |
---|---|
void |
accept(T payload,
Context context)
Called to service an incoming event.
|
void accept(T payload, Context context)
Error
) then the HTTP response will have a 500 status code.payload
- the payload of the event, deserialized from the original JSON string.context
- the context of the event. This is a set of values that every event has,
separately from the payload, such as timestamp and event type.Copyright © 2019. All rights reserved.