Whenever message-oriented middleware is used within applications which run on heterogeneous software systems of multiple partners, and middleware protocols have to be replaced or to fulfil changing tasks, it may be considerably advantageous to have a modular system which supports the exchange of protocols and a dynamic adaptation to changing requirements. Our approach to middleware allows system developers to generate a modular stack of message-oriented middleware from a set of service specifications. We present a technique how service specifications can be translated into executable middleware code that includes a message queue, a stack of protocols chosen by the middleware developer, and a set of modules that implement the desired tasks.