How do I design an adaptor for MSMQ and Web Service RRS feed

  • General discussion

  • Hi,

    I'm after some ideas (free consultancy is another way of putting it). I've got to write a system that takes xml data, does some processing and writes it to a database. Easy!

    However, the xml data will be stored in flat files for the first 6 months, then in MSMQ messages for the next 12 months, then finally as HTTP after that.

    So I need to design an adaptor system that can be changed to allow for flat files, MSMQ and web services. The data may be split over several messages (due to limitations with the sender).

    Has anyone done this and can offer a place to start? Biztalk may be the answer but that is probably not possible for me. Any coding will be in C#.

    Hope someone can help?
    Wednesday, June 17, 2009 12:20 PM

All replies

  • Sounds similiar to a requirement I had a few projects back;

    I had to get data from an external supplier and persist it in a database.  The supplier wasn't agreed and could change so we didn't know how we were going to get the data.  It could have been a web service, flat file, MSMQ or something else.

    Biztalk would have been overengineering this system so I encapsulated the algorithm to get the data as a strategy pattern (see GoF) and used a factory and reflection to create the concrete strategy.  The strategy pattern returned the data in a format I defined (XML).

    This decoupled the algorithm from the client minimizing the amount of changes needed when the supplier changed.  All that was required was adding a new concrete strategy class and changing the name of the concrete class created in the factory.

    There are a number of DI containers around but I simply stored the name of the concrete class in a config file and used reflection to create it.  As the client only used the strategy interface, no changes were needed in the client code.

    Hope this helps.

    Pl mark as answer or helpful if you found this useful
    Wednesday, June 17, 2009 3:43 PM