Search in sources :

Example 1 with MessageImpl

use of io.eventuate.tram.messaging.common.MessageImpl in project eventuate-tram-core by eventuate-tram.

the class WriteRowsEventDataParser method parseEventData.

@Override
public MessageWithDestination parseEventData(WriteRowsEventData eventData, String binlogFilename, long position) throws IOException {
    if (columnOrders.isEmpty()) {
        try {
            getColumnOrders();
        } catch (SQLException e) {
            logger.error("Error getting metadata", e);
            throw new RuntimeException(e);
        }
    }
    String id = (String) getValue(eventData, ID);
    String destination = (String) getValue(eventData, DESTINATION);
    String payload = (String) getValue(eventData, PAYLOAD);
    Map<String, String> headers = JSonMapper.fromJson((String) getValue(eventData, HEADERS), Map.class);
    headers.put(Message.ID, id);
    headers.put("binlogfile", binlogFilename);
    headers.put("binlogposition", Long.toString(position));
    return new MessageWithDestination(destination, new MessageImpl(payload, headers), new BinlogFileOffset(binlogFilename, position));
}
Also used : BinlogFileOffset(io.eventuate.local.common.BinlogFileOffset) SQLException(java.sql.SQLException) MessageImpl(io.eventuate.tram.messaging.common.MessageImpl)

Aggregations

BinlogFileOffset (io.eventuate.local.common.BinlogFileOffset)1 MessageImpl (io.eventuate.tram.messaging.common.MessageImpl)1 SQLException (java.sql.SQLException)1