powertac/powertac-server — Issue #499: Server message dispatching scheme is awkward, inflexible
Author: jecollins
Created: 2012-03-09 17:36:59+00:00
State: open
Labels: Bug, Server environment

In the server, incoming messages are categorized into three sets: tariff messages, sim messages, and market messages. Actually, market messages are the set of all messages that are neither tariff messages nor sim messages. The idea was that tariff messages went to the TariffMarket, sim messages went to the CompetitionControl, and market messages went to the Auctioneer. Now we have some new message types for balancing, and they don't exactly fit into these categories. Worse, every time you add a new message type, you have to make changes in two other places:

* in server.MessageRouter, you have to add the type to one of the categories, or even make up a new category and modify the code.
* in the module that should be handling the incoming message, you have to add a handler, and you have to make sure the Router knows you want messages in its category, which means you have to know which list contains that message type in MessageRouter.

This is nasty. Far better would be the scheme used in sample-broker, where each message-processing module registers for specifically the message types it wants to see. That way, only the modules that want to see a new message type need to be updated when a new message type is introduced.