BizTalk:使用ExplorerOM创建MSMQ发送端口和接收端口

以下程序将创建一个名为MyApp的Biztalk应用程序,并为该程序添加一个MSMQ类型的接收端口和发送端口。接收端口将从"FORMATNAME:DIRECT=TCP:[FE80::F8F9:67DA:BCF7:7F35]/PRIVATE$/MQIn"处接收消息,然后将消息转发给发送端口。发送端口收到消息后,会将消息发送至FORMATNAME:DIRECT=TCP:[FE80::F8F9:67DA:BCF7:7F35]/PRIVATE$/MQOut"。

 

using System;  
using Microsoft.BizTalk.ExplorerOM;  
 
namespace ExplorerOMTest  
{  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            BtsCatalogExplorer catalog = null;  
            try 
            {  
                // Connect BizTalk  
                catalog = new BtsCatalogExplorer();  
                catalog.ConnectionString = "Data Source=.;Initial Catalog=BizTalkMgmtDb;Integrated Security=SSPI;";  
 
                // Create Application  
                IBizTalkApplication application = catalog.AddNewApplication();  
                application.Name = "MyApp";  
                catalog.SaveChanges();  
 
                // Create ReceivePort  
                IReceivePort2 rp = application.AddNewReceivePort(false);  
                rp.Name = "MyRP";  
                IReceiveLocation2 rl = rp.AddNewReceiveLocation();  
                rl.Name = "MyRL";  
                rl.TransportType = catalog.ProtocolTypes["MSMQ"];  
                rl.ReceivePipeline = catalog.Pipelines["Microsoft.BizTalk.DefaultPipelines.PassThruReceive"];  
                rl.Address = @"FORMATNAME:DIRECT=TCP:[FE80::F8F9:67DA:BCF7:7F35]/PRIVATE$/MQIn"; // use IPv6  
                rl.TransportTypeData = "<CustomProps><AdapterConfig vt=/"8/"><Config ><queue>" + rl.Address + "</queue><uri>" + rl.Address + "</uri><batchSize>20</batchSize><transactional>false</transactional><serialProcessing>false</serialProcessing><onFailure>suspendResumable</onFailure></Config></AdapterConfig></CustomProps>";  
                  
                // Create SendPort  
                ISendPort2 sp = application.AddNewSendPort(false, false);  
                sp.Name = "MySP";  
                sp.PrimaryTransport.TransportType = catalog.ProtocolTypes["MSMQ"];  
                sp.PrimaryTransport.Address = @"FORMATNAME:DIRECT=TCP:[FE80::F8F9:67DA:BCF7:7F35]/PRIVATE$/MQOut"; // use IPv6  
                sp.PrimaryTransport.TransportTypeData = "<CustomProps><AdapterConfig vt=/"8/"><Config ><queue>" + sp.PrimaryTransport.Address + "</queue><uri>" + sp.PrimaryTransport.Address + "</uri><maximumMessageSize>1024</maximumMessageSize><acknowledgeType>None</acknowledgeType><timeOut>4</timeOut><priority>Normal</priority><recoverable>false</recoverable><encryptionAlgorithm>None</encryptionAlgorithm><useAuthentication>false</useAuthentication><segmentationSupport>false</segmentationSupport><transactional>false</transactional><useJournalQueue>false</useJournalQueue><useDeadLetterQueue>true</useDeadLetterQueue><ackTypeEnumsValue>0</ackTypeEnumsValue><timeOutUnits>Days</timeOutUnits><bodyType>8209</bodyType></Config></AdapterConfig></CustomProps>";  
                sp.SendPipeline = catalog.Pipelines["Microsoft.BizTalk.DefaultPipelines.PassThruTransmit"];  
                sp.Filter = "<Filter><Group><Statement Property=/"BTS.ReceivePortName/" Operator=/"0/" Value=/"" + rp.Name + "/" /></Group></Filter>";  
                  
                // Start BizTalk Application  
                application.Start(ApplicationStartOption.StartAll);  
                  
                // Save changes  
                catalog.SaveChanges();  
            }  
            catch (Exception ex)  
            {  
                // Cancel changes  
                Console.WriteLine("Exception: " + ex.Message);  
                if (catalog != null)  
                    catalog.DiscardChanges();  
            }  
        }  
    }  

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值