Configuration

Demo Client Configuration

Open $TAC_DEMOAGENT_DIR/grails-app/config/Config.groovy and scroll down to the bottom.

tacenergy {
  username = 'tacenergy1'
  password = 'secret'
  server = "tcp://localhost:61616"

databinding { retryCount = 5 retryWait = 1000 }

User Credentials and Server Url

Here you can enter your personal login credentials that you received during registration from the TAC Energy Server. The values are set to work without any changes with a locally running TAC Energy Server.

If you want to participate in competitions on a server other than localhost (your local machine) you need to adjust the server url accordingly before starting the demo client. Ask the respective server admin for the correct server url.

Data Binding

By default the TAC Energy demo client tries to parse an incoming XML message and to store the resulting object in the local database. E.g. the server sends a forecast message in XML format to the client. The TAC Energy demo client then automatically tries to read the XML message and to create a new DomainClasses instance in the local database. The raw XML message together with the saved Forecast domain instance is then provided as input for the AgentStrategyService as shown below.

def onForecastUpdateReceived(Forecast forecastInstance, String rawXml) {
  log.info "New Forecast received: ${forecastInstance}"
}

Due to the underlying communication structure sometimes it happens that e.g. a forecast message is retrieved and processed by the client before the corresponding Product notification was received. In this case storing the Forecast in the database will fail as the referenced product cannot be found. To circumvent this problem the TAC Energy demo client will retry parsing the incoming Forecast message several times before giving up. With the parameters retryCount and retryWait you can adjust how often the processing should be retried and how long the agent should wait (in milliseconds) between each attempt.

Database Configuration

HSQL DB Configuration

By default the TAC Energy demo agent uses a Hyper SQL in memory database for persisting and retrieving data. If you wish to see the data stored in this database just follow this tutorial that shows how to set up a database viewer for HSQLDB. Alternatively you may switch to another database like e.g. mysql. as described in the following sub section.

MySQL DB Configuration

If you wish to use a mysql database as data storage for you TAC Energy Client simply follow these instructions.

First you need to download and install the latest MySQL Server on your local machine (v5.1 is the latest version at the time of writing this guide). Make sure that it is installed and running correctly.

Now login to the database using the mysql client and the root user (you need to enter the password you chose for the root user during installation of the server).

mysql -u root -p

Afterwards you create a new database and a database user that the TAC Energy client can use later on.

create database mytacagentdb_dev; 
grant usage on *.* to tacdemoagent@localhost identified by 'my_db_password';
grant all privileges on mytacagentdb_dev.* to tacdemoagent@localhost ;

After you've accomplished this step you need to configure your agent to use the newly created mysql database. First of all you need to make sure that the demo agent uses the mysql jdbc driver. Open $DEMO_AGENT_DIR/grails-app/conf/BuildConfig.groovy and uncomment the line

runtime 'mysql:mysql-connector-java:5.1.5'

The next time you start your agents using grails run-app the jdbc driver will be downloaded from an internet driver repository (maven for the experts) and installed into your agent automatically. No further actions required on this. The last thing that remains is to tell you agent to use the new mysql database instead of HSQLDB. Open $DEMO_AGENT_DIR/grails-app/conf/DataSource.groovy and adjust the database parameters accordingly. For the database above the settings should look like this.

development {
	dataSource {
		dbCreate = "create-drop"
    driverClassName = "com.mysql.jdbc.Driver"
    dialect='org.hibernate.dialect.MySQL5InnoDBDialect'
    username = "tacdemoagent"
    password = 'my_db_password'
		url = "jdbc:mysql://localhost/mytacagentdb_dev"
	}
}

By default grails supports three different environments, test, dev, and prod. Read the corresponding section in the grails reference documentation to understand the details of this concept.