A Flux agent is a component in the Flux architecture that receives work from a Flux engine. Flux is designed to regulate assigning tasks so idle agents will receive work when others are busy. Starting a Flux agent can be achieved through a simple java call or in code.
From the Command Line
You will need to know the server your engine is on and login information if you are running a secure engine. Using a command prompt or shell, from the root of the install directory for Flux, the basic syntax is as follows:
For unsecure engines:
java -cp .;flux.jar flux.Main agent-server -enginehost {server} start
For secure engines:
java -cp .;flux.jar flux.Main agent-server -enginehost {server} -engineusername {username} -enginepassword {password} start
There are many more configuration options for running a Flux agent, such as using a configuration file, supplying a registry port, or using an agent pool. To view a list of additional options, use the command java -cp .;flux.jar flux.Main agent-server -h in the root of your Flux install.
You can view a list of agents currently connected to the flux engine in the Operations Console under the tab "Agents" (shown below).
Agents can be disposed of using the command
For an unsecure engine:
java -cp .;flux.jar flux.Main agent-client -enginehost {server} dispose
For a secure engine:
java -cp .;flux.jar flux.Main agent-client -enginehost {server} -engineusername {username} -enginepassword {password} dispose
You can also install a Flux agent as a service. See
Installing Flux as a Windows Service in the Wiki for more details, just substitution the command to start a Flux engine with the command to start your Flux agent.
There is a full example and walkthrough of this in examples/end_users/agents
In Code
Creating a Flux agent is similar to creating many other elements of Flux in code. The basic setup is creating an AgentFactory, making and setting up an AgentConfiguration, and then using the two to make an Agent object. Consider the following code:bq. // Create Factory and Configuration
AgentFactory aFactory = AgentFactory.makeInstance();
AgentConfiguration aConf = aFactory.makeAgentConfiguration();
// Set configuration options
aConf.setEngineHost(?localhost?); // Your server?s location goes here
// If you are using an unsecure engine, this is all the configuration you need
// But if you are using a secure engine, you will need to add the next two lines
aConf.setEngineUsername(?admin?); // Your username
aConf.setEnginePassword(?admin?); // Your password
// Make the agent
Agent myAgent = aFactory.makeAgent(aConf);
// And when you are ready to dispose of the agent
myAgent.dispose();
There are many additional configuration options for creating a Flux agent. For a full list and methods for setting them, see the Flux javadocs under the class "AgentConfiguration."
A full example can be found in /examples/software_developers/agents