MassTransit Provider

Feb 14, 2011 at 4:58 AM
Edited Feb 14, 2011 at 5:28 AM

Change set 5503 introduces a new MassTransit provider - This provider supports access to CIPl collections over a service bus. 

The client side looks like a normal CIPl provider and builds a StrongWrapper using a CIP4MassTransitConnectionAttribute - the wrapper has two parameters

1. BusId - an arbitrary string identifying the bus which will be used by the provider
2. TimeOutInMilliSecs - default is 5000 

The server side is implemented by the RequestMessageReceiver class implemented by the MassTransit provider. You can write your own service to call this class or you can use the CIP4.BusDriver exe to call the class. The class is invoked with the following information:

1. The busId corresponding to the BusId used by the client
2. A LoggerDelegate logger
3. The Assembly object for the asembly that contains the Types used  by the client (at the moment they must all be in the same assembly)
4. A  Dictionary containing the CIP4ConnectionAttribute connections that should be used by the server to connect to the underlying stores. The dictionary is indexed by collection name (the collection names must correspond to the names used on the client side)

For example, the CIP4.BusDriver.exe could be invoked as follows:


 CIP4.BusDriver.exe /BusId PeopleBus /ItemAssemblyName C:\CIP4\V04.04\CIP4\Tests\TestPersonType\bin\Debug\TestPersonType.dll /ProviderAssemblyName CIP4.DataProvider.MassTransit.dll 
/LoggingLevel Trace /ConnectionProperty "People.ProviderKind:XmlFile" /ConnectionProperty "People.XmlFileName:c:\temp\PeopleData.xml" /ConnectionProperty
"PeopleCrudTest.XmlFileName:c:\temp\PeopleCrudTest.xml" /ConnectionProperty "PeopleCrudTest.ProviderKind:XmlFile" /ConnectionProperty
"PeopleCrudTest2.XmlFileName:c:\temp\PeopleCrudTest2.xml" /ConnectionProperty "PeopleCrudTest2.ProviderKind:XmlFile"


A corresponding client might be


            CIP4MassTransitConnectionAttribute connection =
                new CIP4MassTransitConnectionAttribute {BusId = "PeopleBus", TimeOutInMilliSecs = 300000};
            using (StrongWrapper wrapper = new StrongWrapper(connection, logger))
                    PersonType fred =
                        new PersonType
                            Name = "fred",
                            Tags = new List {"one", "two"}

                    wrapper.SaveItems(new List {fred});

                    PersonType fredAgain = wrapper.GetViaExternalID(new ExternalIDType("fred"));

                    if (fredAgain == null || fredAgain.Name != "fred")
                        Console.WriteLine("where's fred?");

                    wrapper.PurgeItems(new List {new ExternalIDType("fred")});