Running the Soccer Results sample
The Soccer Results sample includes two small applications to run from the command line:
- SoccerResults, the subscriber, which subscribes to the results of all the soccer matches being played. You run only one instance of SoccerResults at a time.
- SoccerGame, the publisher, which simulates soccer matches and publishes event information as goals are scored. You can run one or more instances of SoccerGame at the same time.
The SoccerResults and SoccerGame applications are installed as part of the WebSphere Message Brokers run time:
- On Windows, the SoccerResults and SoccerGame applications are in install_dir\sample\soccer\bin
- On Linux and Unix, the applications are installed in install_dir/sample/soccer/bin
where install_dir is the directory in which WebSphere Message Brokers is installed.
Start SoccerResults, the subscriber application, before you start any instances of SoccerGame, the publisher application. If you start the SoccerGame application first, the SoccerResults application might miss some results publications.
To run the sample:
- Start the SoccerResults application:
- On the command line, change to the directory that contains the SoccerResults application.
- Enter the following command, where WBRK61_DEFAULT_QUEUE_MANAGER is the name of the broker's queue manager in the Default Configuration:
soccerResults WBRK61_DEFAULT_QUEUE_MANAGER
The SoccerResults application displays a message indicating that it has registered a subscription and started successfully. WebSphere Message Brokers is case-sensitive so you must type the queue manager's name exactly as it was created.
- Start the SoccerGame application:
- At a new command prompt, change to the directory that contains the SoccerGame application.
- Enter the following command, where WBRK61_DEFAULT_QUEUE_MANAGER is the name of the broker's queue manager in the Default Configuration, Team1 is the name of one team, and Team2 is the name of the other team:
soccerGame Team1 Team2 WBRK61_DEFAULT_QUEUE_MANAGER
Team names can only contain characters "_", 0-9, a-z, and A-Z. Use the "_" character to represent a space in the name of the team. For example:
soccerGame Hudford_Harriers Drafton_Dynamos WBRK61_DEFAULT_QUEUE_MANAGER
Things to try
When you have run the Soccer Results sample, experiment with the different capabilities of publish/subscribe messaging:
- Simulate the use of retained publications. (Do not try this step if your broker operates as a WebSphere MQ trusted application because the queue manager of a trusted application cannot release the subscription queue (SOCCER_SUBSCRIPTION) when the SoccerResults application ends.):
- After a couple of goals have been scored, change to the window running the SoccerResults application, and prematurely end the process pressing Ctrl+C.
- Wait about 30 seconds, then restart the SoccerResults application. The current matches are restored to their last known score, and the score is updated with any additional goals that were scored while the application was stopped. If you restart the SoccerResults application too quickly, the subscriber queue might fail to open (error code 2042 (MQRC_OBJECT_IN_USE)). This happens if the queue manager does not recognize that the application has failed, and does not release the queue, which was opened for the exclusive use of the application that failed. After a few seconds, try restarting the application again.
- Start another instance of the SoccerGame application using different team names. If you run two instances of SoccerGame at the same time, the results server receives the scores of both games.
Back to sample home