The Talon Manual

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
java
java
// Use the source message as a factory for creating a repeated buffer backed field
// ... an initial buffer length of 1024 bytes with a native, off heap backing buffer:
private final XbufRepeatedStringFieldBuffer canceledOrderIds = 
         CancelOrdersMessage.createOrderIdsFieldBuffer(1024, true);

@EventHandler
public void onMessage(CancelOrdersMessage message) {

    // When the buffer backed field is passed an iterator from
    // a message it can figure out that it is a field buffer iterator
    // and do bulk copy. 
    canceledOrderIds.setValuesFrom(message.getOrderIdsIterator()); 

    // The orderIds can be iterated in a Zero Garbage fashion
    canceledOrderIds.toFirst();
    while(canceledOrderIds.hasNext()) {
       orderIdscanceledOrderIds.nextInto(tmpOrderId);
       System.out.append("Order ID: ").append(tmpOrderId).append("\n");
    } 
}

...