Home

 

Running the application

To run the application on a single queue manager, first start the queue manager and then enter the following command:

 runmqsc QMgrName < amqsresa.tst

whereQMgrName is the queue manager that the results service will use (ifQMgrName is omitted, the default queue manager will be assumed). This creates the appropriate queues on the queue manager. Then start the broker (see Controlling the broker).

The results service program is started by entering the following:

 amqsres QMgrName

QMgrName is optional, and defaults to the default queue manager. The results service produces the following output:

 Results Service is ready for match input,
 instances of amqsgam can now be started.

We can now start one or more match simulators by entering the following command:

 amqsgam Team1 Team2 QMgrName

QMgrName is optional, as before.

Typical output from a match simulator is:

 Match between Team1 and Team2
 GOAL! Team2 scores after 20 minutes
 GOAL! Team1 scores after 25 minutes
 GOAL! Team1 scores after 38 minutes
 GOAL! Team2 scores after 73 minutes
 Full time

This would produce corresponding output from the results service, for example:

 LATEST: Team1 0, Team2 0
 LATEST: Team1 0, Team2 1
 LATEST: Team1 1, Team2 1
 LATEST: Team1 2, Team2 1
 LATEST: Team1 2, Team2 2
 FULLTIME: Team1 2, Team2 2

A match simulator can be run on a different queue manager in the broker hierarchy if required. In this case, we need to enter the following command to create the appropriate stream queue on that queue manager:

 runmqsc QMgrName < amqsgama.tst

You must do this before starting the results service and the match simulator.

The team names must be 31 characters or less in length, and contain no blanks. The simulator runs for 30 seconds and scores goals at random for each side.

The simulator publishes event publications on the following topics:

 Sport/Soccer/Event/MatchStarted
 Sport/Soccer/Event/ScoreUpdate
 Sport/Soccer/Event/MatchEnded

The UserData is contained in a formatted string following the NameValueString of the MQRFH header. In the case of 'MatchStarted' or 'MatchEnded' it consists of both team names in the following structure:

 {
    MQCHAR32  Team1;
    MQCHAR32  Team2;
 }

For a 'ScoreUpdate' the UserData consists of the name of the team that scored, for example:

    MQCHAR32  TeamThatScored;

The team names are NULL padded to 32 characters.

The results service program subscribes to these three topics to monitor the state of play in the matches that are active. It publishes the latest score in the match between Team1 and Team2 on the following topic:

Sport/Soccer/State/LatestScore/Team1 Team2

In this case the UserData is a variable string containing the data in the format:

"Team1Score Team2Score"

For example"0 0" or "2 1".

Figure 20 illustrates the situation when four match simulators are running.

Figure 20. Results service running with four match simulators. The match simulators send event publications to three topics (MatchStarted, ScoreUpdate, MatchEnded). The results service subscribes to these, and sends state publications to four state topics (the LatestScore for each match).

When a match has ended, the retained publication that contains its latest score is deleted. After a period of inactivity (45 seconds), the results service deregisters the subscription from theSport/Soccer/Event/* topic and the program ends with the message:

 Results Service has ended

If the results service program (

amqsres) is stopped and restarted while the match simulators are still running, the results are restored to their correct values and processing continues as before.



 

Home