When you create a new service, it is automatically subclassed off DsspServiceBase. This does some of the work for you in setting up and managing your CCR and DSS environment.
As you noted, an Interleave is created called MainPortInterleave. It is important to use CombineWith to add your service handlers to this interleave because it provides exclusive access to resources such as your service state. If you create your own Interleaves then they will not all be coordinated.
You use Choice and JoinedReceive to handle internal messages, as you suggest. There are often situations where you don't want to go through the main interleave because it is not relevant. It really depends on your logic.
In terms of message processing, a Choice is equivalent to an OR and a Join is equivalent to an AND. So if your code cannot proceed until two messages arrive (AND) then a Join is appropriate.
The most common use of Choice is to handle possible exceptions, including timeouts. In this case you want to receive either the response OR an exception but you can never receive both.
Another point about an Interleave is that you can't (easily) see what messages are waiting for the various ports. The interleave manages incoming messages so the ports will always appear to be empty. However, if you simply forward messages to another port then you can do your own throttling.
Trevor
|