Q:

Spring Integration convert payload to object in service activator

I am following this guide to read email notifications from a topic in Google Pub/Sub. Once the application starts, I see messages arriving on the console like this:
Message arrived! Payload: {"emailAddress":"xxxxx@gmail.com","historyId":712315}

How do I convert the payload to an object so I can retrieve the emailAddress and historyId?
The service activator looks like this:
@Bean
  @ServiceActivator(inputChannel = "pubsubInputChannel")
  public MessageHandler messageReceiver() {
    return message -> {
      LOGGER.info("Message arrived! Payload: " + message.getPayload());
      AckReplyConsumer consumer =
          (AckReplyConsumer) message.getHeaders().get(GcpPubSubHeaders.ACKNOWLEDGEMENT);
      consumer.ack();
    };
  }

And the POJO object I want the payload converted to is:
public class MessageNotification {

    private String emailAddress;

    private BigInteger historyId;

    public String getEmailAddress() {
        return emailAddress;
    }

    public BigInteger getHistoryId() {
        return historyId;
    }

    public void setHistoryId(BigInteger historyId) {
        this.historyId = historyId;
    }

    public void setEmailAddress(String emailAddress) {
        this.emailAddress = emailAddress;
    }
}

A:

Looks like that payload is a JSON, so you need to go to Spring Integration Reference Manual and use a JsonToObjectTransformer before handling it with that @ServiceActivator:
@Bean
@Transformer(inputChannel = "pubsubInputChannel", outputChannel = "handleChannel")
public JsonToObjectTransformer jsonToObjectTransformer() {
    return new JsonToObjectTransformer(MessageNotification.class);
}

@Bean
@ServiceActivator(inputChannel = "handleChannel")
public MessageHandler messageReceiver() {

  ...

