• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# SendOptions类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中SendOptions的典型用法代码示例。如果您正苦于以下问题:C# SendOptions类的具体用法?C# SendOptions怎么用?C# SendOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SendOptions类属于命名空间,在下文中一共展示了SendOptions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Audit

        public void Audit(SendOptions sendOptions, TransportMessage transportMessage)
        {
            // Revert the original body if needed (if any mutators were applied, forward the original body as received)
            transportMessage.RevertToOriginalBodyIfNeeded();

            // Create a new transport message which will contain the appropriate headers
            var messageToForward = new TransportMessage(transportMessage.Id, transportMessage.Headers)
            {
                Body = transportMessage.Body,
                Recoverable = transportMessage.Recoverable,
                TimeToBeReceived = sendOptions.TimeToBeReceived.HasValue ? sendOptions.TimeToBeReceived.Value : transportMessage.TimeToBeReceived
            };

            messageToForward.Headers[Headers.ProcessingMachine] = RuntimeEnvironment.MachineName;
            messageToForward.Headers[Headers.ProcessingEndpoint] = EndpointName;

            if (transportMessage.ReplyToAddress != null)
            {
                messageToForward.Headers[Headers.OriginatingAddress] = transportMessage.ReplyToAddress.ToString();
            }

            // Send the newly created transport message to the queue
            MessageSender.Send(messageToForward, new SendOptions(sendOptions.Destination)
            {
                ReplyToAddress = Configure.PublicReturnAddress
            });
        }
开发者ID:xqfgbc,项目名称:NServiceBus,代码行数:27,代码来源:DefaultMessageAuditer.cs


示例2: SendMessage

        void SendMessage(TransportMessage message, SendOptions sendOptions, IModel channel)
        {

            var destination = sendOptions.Destination;

            string callbackAddress;

            if (sendOptions.GetType().FullName.EndsWith("ReplyOptions") &&
                message.Headers.TryGetValue(CallbackHeaderKey, out callbackAddress))
            {
                destination = Address.Parse(callbackAddress);
            }

            //set our callback address
            if (!string.IsNullOrEmpty(CallbackQueue))
            {
                message.Headers[CallbackHeaderKey] = CallbackQueue;     
            }
           
            var properties = channel.CreateBasicProperties();

            RabbitMqTransportMessageExtensions.FillRabbitMqProperties(message, sendOptions, properties);

            RoutingTopology.Send(channel, destination, message, properties);
        }
开发者ID:MyDealerLot,项目名称:NServiceBus.RabbitMQ,代码行数:25,代码来源:RabbitMqMessageSender.cs


示例3: ToDeliveryOptions

        public static DeliveryOptions ToDeliveryOptions(this Dictionary<string, string> options)
        {
            var operation = options["Operation"].ToLower();

            switch (operation)
            {
                case "publish":
                    return new PublishOptions(Type.GetType(options["EventType"]))
                    {
                        ReplyToAddress = Address.Parse(options["ReplyToAddress"])
                    };

                case "send":
                case "audit":
                    var sendOptions = new SendOptions(options["Destination"]);

                    ApplySendOptionSettings(sendOptions, options);

                    return sendOptions;

                case "reply":
                    var replyOptions = new ReplyOptions(Address.Parse(options["Destination"]), options["CorrelationId"])
                    {
                        ReplyToAddress = Address.Parse(options["ReplyToAddress"])
                    };
                    ApplySendOptionSettings(replyOptions, options);

                    return replyOptions;

                default:
                    throw new Exception("Unknown operation: " + operation);
            }


        }
开发者ID:xqfgbc,项目名称:NServiceBus,代码行数:35,代码来源:TransportOperationConverter.cs


示例4: ToBrokeredMessage

        public static BrokeredMessage ToBrokeredMessage(this TransportMessage message, SendOptions options, SettingsHolder settings, bool expectDelay, Configure config)
        {
            var brokeredMessage = BrokeredMessageBodyConversion.InjectBody(message.Body);

            SetHeaders(message, options, settings, config, brokeredMessage);

            var timeToSend = DelayIfNeeded(options, expectDelay);
                        
            if (timeToSend.HasValue)
                brokeredMessage.ScheduledEnqueueTimeUtc = timeToSend.Value;

            TimeSpan? timeToLive = null;
            if (message.TimeToBeReceived < TimeSpan.MaxValue)
            {
                timeToLive = message.TimeToBeReceived;
            }
            else if (options.TimeToBeReceived.HasValue && options.TimeToBeReceived < TimeSpan.MaxValue)
            {
                timeToLive = options.TimeToBeReceived.Value;
            }

            if (timeToLive.HasValue)
            {
                if (timeToLive.Value <= TimeSpan.Zero) return null;

                brokeredMessage.TimeToLive = timeToLive.Value;
            }
            GuardMessageSize(brokeredMessage);

            return brokeredMessage;
        }
开发者ID:danielmarbach,项目名称:NServiceBus.AzureServiceBus,代码行数:31,代码来源:BrokeredMessageConverter.cs


示例5: Send

        public void Send(TransportMessage message, SendOptions sendOptions)
        {
            Address destination = null;
            try
            {
                destination = DetermineDestination(sendOptions);
            
                var connectionInfo = connectionStringProvider.GetForDestination(sendOptions.Destination);
                var queue = new TableBasedQueue(destination, connectionInfo.Schema);
                if (sendOptions.EnlistInReceiveTransaction)
                {
                    SqlTransaction currentTransaction;
                    if (connectionStore.TryGetTransaction(connectionInfo.ConnectionString, out currentTransaction))
                    {
                        queue.Send(message, sendOptions, currentTransaction.Connection, currentTransaction);
                    }
                    else
                    {
                        SqlConnection currentConnection;
                        if (connectionStore.TryGetConnection(connectionInfo.ConnectionString, out currentConnection))
                        {
                            queue.Send(message, sendOptions, currentConnection);
                        }
                        else
                        {
                            using (var connection = sqlConnectionFactory.OpenNewConnection(connectionInfo.ConnectionString))
                            {
                                queue.Send(message, sendOptions, connection);
                            }
                        }
                    }
                }
                else 
                {
                    // Suppress so that even if DTC is on, we won't escalate
                    using (var tx = new TransactionScope(TransactionScopeOption.Suppress))
                    {
                        using (var connection = sqlConnectionFactory.OpenNewConnection(connectionInfo.ConnectionString))
                        {
                            queue.Send(message, sendOptions, connection);
                        }

                        tx.Complete();
                    }
                }
            }
            catch (SqlException ex)
            {
                if (ex.Number == 208)
                {
                    ThrowQueueNotFoundException(destination, ex);
                }

                ThrowFailedToSendException(destination, ex);
            }
            catch (Exception ex)
            {
                ThrowFailedToSendException(destination, ex);
            }
        }
开发者ID:adamralph,项目名称:NServiceBus.SqlServer,代码行数:60,代码来源:SqlServerMessageSender.cs


示例6: RequiresImmediateDispatch_Should_Return_True_When_Immediate_Dispatch_Requested

        public void RequiresImmediateDispatch_Should_Return_True_When_Immediate_Dispatch_Requested()
        {
            var options = new SendOptions();
            options.RequireImmediateDispatch();

            Assert.IsTrue(options.RequiredImmediateDispatch());
        }
开发者ID:Particular,项目名称:NServiceBus,代码行数:7,代码来源:ImmediateDispatchOptionExtensionsTests.cs


示例7: Defer

        public void Defer(TransportMessage message, SendOptions sendOptions)
        {
            message.Headers[TimeoutManagerHeaders.RouteExpiredTimeoutTo] = sendOptions.Destination.ToString();

            DateTime deliverAt;

            if (sendOptions.DelayDeliveryWith.HasValue)
            {
                deliverAt = DateTime.UtcNow + sendOptions.DelayDeliveryWith.Value;
            }
            else
            {
                if (sendOptions.DeliverAt.HasValue)
                {
                    deliverAt = sendOptions.DeliverAt.Value;    
                }
                else
                {
                    throw new ArgumentException("A delivery time needs to be specified for Deferred messages");
                }
                
            }

            message.Headers[TimeoutManagerHeaders.Expire] = DateTimeExtensions.ToWireFormattedString(deliverAt);
            
            try
            {
                MessageSender.Send(message, new SendOptions(TimeoutManagerAddress));
            }
            catch (Exception ex)
            {
                Log.Error("There was a problem deferring the message. Make sure that DisableTimeoutManager was not called for your endpoint.", ex);
                throw;
            }
        }
开发者ID:xqfgbc,项目名称:NServiceBus,代码行数:35,代码来源:TimeoutManagerDeferrer.cs


示例8: SendTestMessage

        public async Task<ActionResult> SendTestMessage(SendTestMessage sendTestMessage)
        {
            try
            {
                var sendOptions = new SendOptions
                {
                    ContentType = sendTestMessage.ContentType,
                    Importance = sendTestMessage.Importance
                };

                var message = new TestMessage
                {
                    Text = sendTestMessage.MessageText
                };

                var bus = await _busManager.GetBus();
                var sentMessage = await bus.Send(message, sendOptions);
                return View("Index", new SendTestMessage
                {
                    MessageSent = true,
                    SentMessageId = sentMessage.MessageId
                });
            }
            catch (Exception ex)
            {
                sendTestMessage.ErrorsOccurred = true;
                sendTestMessage.ErrorMessage = ex.ToString();
            }
            return View("Index", sendTestMessage);
        }
开发者ID:tdbrian,项目名称:Platibus,代码行数:30,代码来源:SendTestMessageController.cs


示例9: RequestImmediateDispatch

 async Task RequestImmediateDispatch(IPipelineContext context)
 {
     #region RequestImmediateDispatch
     SendOptions options = new SendOptions();
     options.RequireImmediateDispatch();
     await context.Send(new MyMessage(), options);
     #endregion
 }
开发者ID:odelljl,项目名称:docs.particular.net,代码行数:8,代码来源:Usage.cs


示例10: SendEnumMessage

 public async Task<ActionResult> SendEnumMessage()
 {
     EnumMessage message = new EnumMessage();
     SendOptions sendOptions = new SendOptions();
     sendOptions.SetDestination("Samples.Callbacks.Receiver");
     Task<Status> statusTask = MvcApplication.BusSession.Request<Status>(message, sendOptions);
     return View("SendEnumMessage", await statusTask);
 }
开发者ID:cdnico,项目名称:docs.particular.net,代码行数:8,代码来源:HomeController.cs


示例11: SendOptions_GetCorrelationId_Should_Return_Null_When_No_CorrelationId_Configured

        public void SendOptions_GetCorrelationId_Should_Return_Null_When_No_CorrelationId_Configured()
        {
            var options = new SendOptions();

            var correlationId = options.GetCorrelationId();

            Assert.IsNull(correlationId);
        }
开发者ID:Particular,项目名称:NServiceBus,代码行数:8,代码来源:CorrelationContextExtensionsTests.cs


示例12: Simple

 async void Simple(IEndpointInstance endpoint, SendOptions sendOptions, ILog log)
 {
     #region EnumCallback
     Message message = new Message();
     Status response = await endpoint.Request<Status>(message, sendOptions);
     log.Info("Callback received with response:" + response);
     #endregion
 }
开发者ID:odelljl,项目名称:docs.particular.net,代码行数:8,代码来源:Usage.cs


示例13: GetDeliveryDate_Should_Return_The_Configured_Delivery_Date

        public void GetDeliveryDate_Should_Return_The_Configured_Delivery_Date()
        {
            var options = new SendOptions();
            DateTimeOffset deliveryDate = new DateTime(2012, 12, 12, 12, 12, 12);
            options.DoNotDeliverBefore(deliveryDate);

            Assert.AreEqual(deliveryDate, options.GetDeliveryDate());
        }
开发者ID:Particular,项目名称:NServiceBus,代码行数:8,代码来源:DelayedDeliveryOptionExtensionsTests.cs


示例14: IsRoutingToThisEndpoint_Should_Return_True_When_Routed_To_This_Endpoint

        public void IsRoutingToThisEndpoint_Should_Return_True_When_Routed_To_This_Endpoint()
        {
            var options = new SendOptions();

            options.RouteToThisEndpoint();

            Assert.IsTrue(options.IsRoutingToThisEndpoint());
        }
开发者ID:Particular,项目名称:NServiceBus,代码行数:8,代码来源:RoutingOptionExtensionsTests.cs


示例15: SendEnumMessage

 public async Task<ActionResult> SendEnumMessage()
 {
     var message = new EnumMessage();
     var sendOptions = new SendOptions();
     sendOptions.SetDestination("Samples.Callbacks.Receiver");
     Task<Status> statusTask = MvcApplication.EndpointInstance.Request<Status>(message, sendOptions);
     return View("SendEnumMessage", await statusTask.ConfigureAwait(false));
 }
开发者ID:chriscatilo,项目名称:docs.particular.net,代码行数:8,代码来源:HomeController.cs


示例16: SendIntMessage

 public async Task<ActionResult> SendIntMessage()
 {
     IntMessage message = new IntMessage();
     SendOptions sendOptions = new SendOptions();
     sendOptions.SetDestination("Samples.Callbacks.Receiver");
     Task<int> statusTask = MvcApplication.Endpoint.Request<int>(message, sendOptions);
     return View("SendIntMessage", await statusTask);
 }
开发者ID:vanwyngardenk,项目名称:docs.particular.net,代码行数:8,代码来源:HomeController.cs


示例17: SendObjectMessage

 public async Task<ActionResult> SendObjectMessage()
 {
     ObjectMessage message = new ObjectMessage();
     SendOptions sendOptions = new SendOptions();
     sendOptions.SetDestination("Samples.Callbacks.Receiver");
     Task<ObjectResponseMessage> responseTask = MvcApplication.Endpoint.Request<ObjectResponseMessage>(message, sendOptions);
     return View("SendObjectMessage", await responseTask);
 }
开发者ID:vanwyngardenk,项目名称:docs.particular.net,代码行数:8,代码来源:HomeController.cs


示例18: IsRoutingToThisInstance_Should_Return_True_When_Routed_To_This_Instance

        public void IsRoutingToThisInstance_Should_Return_True_When_Routed_To_This_Instance()
        {
            var options = new SendOptions();

            options.RouteToThisInstance();

            Assert.IsTrue(options.IsRoutingToThisInstance());
        }
开发者ID:Particular,项目名称:NServiceBus,代码行数:8,代码来源:RoutingOptionExtensionsTests.cs


示例19: GetDeliveryDelay_Should_Return_The_Configured_Delay_TimeSpan

        public void GetDeliveryDelay_Should_Return_The_Configured_Delay_TimeSpan()
        {
            var options = new SendOptions();
            var delay = TimeSpan.FromMinutes(42);
            options.DelayDeliveryWith(delay);

            Assert.AreEqual(delay, options.GetDeliveryDelay());
        }
开发者ID:Particular,项目名称:NServiceBus,代码行数:8,代码来源:DelayedDeliveryOptionExtensionsTests.cs


示例20: SendOptions_GetDestination_Should_Return_Null_When_No_Destination_Configured

        public void SendOptions_GetDestination_Should_Return_Null_When_No_Destination_Configured()
        {
          var options = new SendOptions();

          var destination = options.GetDestination();

          Assert.IsNull(destination);
        }
开发者ID:Particular,项目名称:NServiceBus,代码行数:8,代码来源:RoutingOptionExtensionsTests.cs



注:本文中的SendOptions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SendOrPostCallback类代码示例发布时间:2022-05-24
下一篇:
C# SendCodeViewModel类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap