2.2 consume

The consume function block is executed for each UDR or bytearray passing the agent. For Java agent, there will be two separate consume blocks, one for passing UDR and the other for bytearray. Within a consume block, validation, modification and routing can be performed. Each UDR or bytearray is referred to by the special input variable.

The function block will parse in the input data as well as the Agent Environment object. For more on the Agent Environment object, please refer to 3. Java General Functions.

Example - consume blocks

The consume block for UDR would have the type UDRInterface option.

public void consume(UDRInterface input, AgentEnv env) throws Exception {
	env.debug("input");
	env.route(input);
}


The consume block for bytearray would have the type byte[] option.

public void consume(byte[] input, AgentEnv env) throws Exception {
	env.debug("input");
	env.route(input);
}

When handling several types of UDRs in the same Java agent, the code must first determine what type is currently handled, then cast it to the correct type.