Inspirel banner

Programming Distributed Systems with YAMI4

4.3.24 Java

Creating an agent object in Java with 5 dispatcher threads instead of default one can be achieved with the following code:

import com.inspirel.yami.Agent;
import com.inspirel.yami.OptionNames;
import com.inspirel.yami.Parameters;
// ...

{
    Parameters options = new Parameters();
    options.setInteger(OptionNames.DISPATCHER_THREADS, 5);

    Agent myAgent = new Agent(options);
    // ...
}

The OptionNames class defines convenient string constants for all available configuration options.

Any subset of options can be used in a single parameters object and those options which are not provided are considered to have their default values.

No parameters object needs to be provided if all-default setup is intended, as shown in the following example:

import com.inspirel.yami.Agent;
// ...

{
    Agent myAgent = new Agent();
    // ...
}

Agents should be properly closed, which is achieved with the close() method call.