本文整理匯總了C#中System.ServiceModel.MsmqIntegration.MsmqIntegrationBinding類的典型用法代碼示例。如果您正苦於以下問題:C# MsmqIntegrationBinding類的具體用法?C# MsmqIntegrationBinding怎麽用?C# MsmqIntegrationBinding使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MsmqIntegrationBinding類屬於System.ServiceModel.MsmqIntegration命名空間,在下文中一共展示了MsmqIntegrationBinding類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: SubmitPurchaseOrder
[ServiceContract(Namespace = "http://Microsoft.ServiceModel.Samples")]
[ServiceKnownType(typeof(PurchaseOrder))]
public interface IOrderProcessor
{
[OperationContract(IsOneWay = true, Action = "*")]
void SubmitPurchaseOrder(MsmqMessage<PurchaseOrder> msg);
}
示例2: SubmitPurchaseOrder
public class OrderProcessorService : IOrderProcessor
{
[OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]
public void SubmitPurchaseOrder(MsmqMessage<PurchaseOrder> ordermsg)
{
PurchaseOrder po = (PurchaseOrder)ordermsg.Body;
Random statusIndexer = new Random();
po.Status = (OrderStates)statusIndexer.Next(3);
Console.WriteLine("Processing {0} ", po);
}
// Host the service within this EXE console application.
public static void Main()
{
// Get base address from appsettings in configuration.
Uri baseAddress = new Uri(ConfigurationManager.AppSettings["baseAddress"]);
// Create a ServiceHost for the CalculatorService type and provide the base address.
using (ServiceHost serviceHost = new ServiceHost(typeof(IOrderProcessor), baseAddress))
{
// Open the ServiceHostBase to create listeners and start listening for messages.
serviceHost.Open();
// The service can now be accessed.
Console.WriteLine("The service is ready.");
Console.WriteLine("The service is running in the following account: {0}", WindowsIdentity.GetCurrent().Name);
Console.WriteLine("Press <ENTER> to terminate service.");
Console.WriteLine();
Console.ReadLine();
// Close the ServiceHostBase to shutdown the service.
serviceHost.Close();
}
}
}
示例3: MsmqIntegrationBinding
MsmqIntegrationBinding binding = new MsmqIntegrationBinding();
EndpointAddress address = new EndpointAddress("msmq.formatname:DIRECT=OS:.\\private$\\Orders");
ChannelFactory<IOrderProcessor> channelFactory = new ChannelFactory<IOrderProcessor>(binding, address);
IOrderProcessor channel = channelFactory.CreateChannel();
PurchaseOrder po = new PurchaseOrder();
po.customerId = "somecustomer.com";
po.poNumber = Guid.NewGuid().ToString();
PurchaseOrderLineItem lineItem1 = new PurchaseOrderLineItem();
lineItem1.productId = "Blue Widget";
lineItem1.quantity = 54;
lineItem1.unitCost = 29.99F;
PurchaseOrderLineItem lineItem2 = new PurchaseOrderLineItem();
lineItem2.productId = "Red Widget";
lineItem2.quantity = 890;
lineItem2.unitCost = 45.89F;
po.orderLineItems = new PurchaseOrderLineItem[2];
po.orderLineItems[0] = lineItem1;
po.orderLineItems[1] = lineItem2;
MsmqMessage<PurchaseOrder> ordermsg = new MsmqMessage<PurchaseOrder>(po);
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
{
channel.SubmitPurchaseOrder(ordermsg);
scope.Complete();
}
Console.WriteLine("Order has been submitted:{0}", po);