NoOrchestration,PassPipelineSet dynamic sending port attributes
Generally, the dynamic sending port must be used.OrchestrationUsing expressions (Expression) Specifies the destination address of the sending port.Port_1 (Microsoft. xlangs. basetypes. Address) =Http://www.tradingpartner.com/receive.ashx The specific address can be based on the inputMessagePassXpathExpression orPromoteAttribute acquisition, but each process can only receive the specifiedSchemaMessage. If you want to make a general message-based route, it is not very convenient.
The actual situation is as follows:100Items DifferentSchemaYou need to route the message according to the content of the message instance. The specific address is stored in the "route table" and can be dynamically maintained.Orchestration,RecivemessageIs defined as a commonXmldocumentProcess, pass in the processXpathAfter obtaining the value, go to the corresponding address in the "route table" and set the dynamic sending port address.
Obviously, this is very inefficient, nonstandard, and prone to conflicts.
Now you can use custom developmentReceivepipelineComponent, inPipelineDuring the execution, the required address is upgraded through the attribute (PromoteIn this way, the dynamic sending port can be directly sent to the specified destination based on the specific attribute value.
Note: The dynamic sending port can only subscribe to messages with the promote outboundtransporttype and outboundtransportlocation attributes. If the two attributes are not upgraded, messages cannot be subscribed through the receiveportname or other attributes.
Code:
IbasemessagecontextContext = inmsg. context;
IbasemessagepartBodypart = inmsg. bodypart;
StreamOriginalstrm = bodypart. getoriginaldatastream ();
StringInval =String. Empty;
StringOutboundaddress =String. Empty;
String[] Fixstr;
Inval =Convert. Tostring (context. Read (This. _ Propname,This. _ Propnamespaces ));
If(String. Isnullorempty (inval ))
{
// Inval = getinmessagevalue (originalstrm );
}
// Outboundaddress = This. gettransportlocation (inval );
Outboundaddress =@ "MSMQ: //. \ private $ \ mq1";
If(Outboundaddress. indexof ("://")> 0)
{
Fixstr = outboundaddress. Split (':');
This. _ Proptransporttype = fixstr [0];
IntFirstidx = outboundaddress. indexof ("//");
Outboundaddress = outboundaddress. substring (firstidx + 2 );
}
If(This. _ Proptransporttype. tolower (). Trim () ="MSMQ")
{
Context. Promote ("Transactional",Http://schemas.microsoft.com/BizTalk/2003/msmq-properties",This. _ Proptransactional );
Context. Promote ("Timeout",Http://schemas.microsoft.com/BizTalk/2003/msmq-properties", 4 );
Context. Promote ("Timeoutunits",Http://schemas.microsoft.com/BizTalk/2003/msmq-properties","Days");
}
Context. Promote ("Outboundtransporttype",Http://schemas.microsoft.com/BizTalk/2003/system-properties",This. _ Proptransporttype );
Context. Promote ("Outboundtransportlocation",Http://schemas.microsoft.com/BizTalk/2003/system-properties", Outboundaddress );
If(!String. Isnullorempty (This. _ Propspid. Trim ()))
Context. Promote ("Spid",Http://schemas.microsoft.com/BizTalk/2003/system-properties",This. _ Propspid );
Bodypart. Data = originalstrm;
PC. resourcetracker. addresource (originalstrm );
ReturnInmsg;
This naturally improves performance and facilitates maintenance.