All you need to do is to simplify the msmq call code and make it replaceable. After implementation, the call message queue code becomes as follows:
QueueService srv =srv.Prepare<DTO1>srv.Send<DTO1>( DTO1() { p1=, p2= msgId=srv.Send<DTO1>( DTO1() { p1 = , p2 = DTO1 msg = srv.Receive<DTO1>DTO1 msg = srv.Receive<DTO1>(srv.SendResponse<DTO1>msg=srv.ReceiveResponse<DTO1>(msgId);
There are two main points:
- Breakthrough in msmq message size limit (4 m breakthrough)
- Serialization and deserialization of generic T objects
Breakthrough size limit
- If the size is within 4 MB, msmq is directly encapsulated (MessageLocation = InQueue)
- If it is 4 MB away, It is encapsulated by a network shared file (MessageLocation = InNetwork)
Serialization and deserialization of generic T objects
- The object type to be passed is MessageWrapper.
- Embedded in MessageWrapper other objects to be passed and corresponding types and module names, so that MessageWrapper can be automatically xml-based and anti-xml-based.
The MessageWrapper code is as follows:
== RealObjectType { ; RealObjectModule { ; RealObjectXml { ; NetworkLocation { ; MessageLocation PersistenceType { ; Inject<T>.RealObjectType = .RealObjectModule = xml = SerializeUtils.Serialize2XML( T Extract<T>= AppDomain.CurrentDomain.Load(.RealObjectModule.TrimEnd(= assembly.GetType( xml = xml = (.PersistenceType === (.PersistenceType === fileBroker.GetContentAndDelete( SaveXML( (xml.Length >.NetworkLocation =.PersistenceType =.RealObjectXml =.PersistenceType =
The code is relatively simple and will not be introduced.