Accessing data element of UDP datagram in Alpakka UDP

Has anybody found a workaround for accessing the data variable of a UDP Datagram in Alpakka? Datagram defines its data field as a private member, so I’m unable to access the actual data to use in my downstream flow. Seem so be an issue that data has only private access in Datagram.

For example, I’d like to create a Kafka producer record using that element:

public static ProducerRecord toProducerRecord(Datagram datagram)
{
return new ProducerRecord(“my-topic”, datagram.data);
}

Have you tried calling data() method?

public static ProducerRecord toProducerRecord(Datagram datagram)
{
  return new ProducerRecord(“my-topic”, datagram.data());
}

Note that when Alpakka 1.1.0 is released, you will be able to use getData() as well: https://github.com/akka/alpakka/pull/1803

Unfortunately I don’t see this in the Alpakka 1.1.0 release notes for UDP, but the workaround of calling the data() method directly did work.

getData and getRemote slipped from the release notes, but is available since Alpakka UDP 1.1.0.