Message Queue tool (MSMQ)

Source: Internet
Author: User
Tags msmq

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.