当前位置: 首页>>代码示例>>C#>>正文


C# ISession.CreateDurableConsumer方法代码示例

本文整理汇总了C#中ISession.CreateDurableConsumer方法的典型用法代码示例。如果您正苦于以下问题:C# ISession.CreateDurableConsumer方法的具体用法?C# ISession.CreateDurableConsumer怎么用?C# ISession.CreateDurableConsumer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISession的用法示例。


在下文中一共展示了ISession.CreateDurableConsumer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ActiveMq

        public ActiveMq(bool durable)
        {
            _connectionFactory = new ConnectionFactory("tcp://localhost:61616");
            _connectionFactory.AsyncSend = true;
            _connectionFactory.ProducerWindowSize = int.MaxValue;
            _connection = _connectionFactory.CreateConnection();
            _connection.ClientId = "13AC0CF8-65FE-4638-8B85-62210DD89BEE";
            _connection.Start();
            _session = _connection.CreateSession();
            ActiveMQTopic topic = new ActiveMQTopic("topic");
            _consumer = _session.CreateDurableConsumer(topic, "durable", "2 > 1", false);

            _producer = _session.CreateProducer(topic);
            _producer.DeliveryMode = durable ? MsgDeliveryMode.Persistent : MsgDeliveryMode.NonPersistent;
        }
开发者ID:bling,项目名称:MessageQueuePerfTest,代码行数:15,代码来源:ActiveMq.cs

示例2: TryConnect

        private void TryConnect()
        {
            Task.Factory.StartNew(() =>
            {

                while (!_cts.IsCancellationRequested)
                {
                    if (!_isConnect)
                    {
                        _logger.Info("开始连接指令队列服务器![{0}-{1}]".GetFormat(_name, _uri));
                        try
                        {
                            _factory = new ConnectionFactory(_uri);
                            _connection = _factory.CreateConnection();
                            _connection.ConnectionInterruptedListener += () =>
                            {
                                _logger.Error("与指令队列服务器断开连接![{0}-{1}]".GetFormat(_name, _uri));
                                _isConnect = false;
                            };
                            _connection.ClientId = _clientId;
                            _connection.Start();
                            _session = _connection.CreateSession();
                            _consumer = _session.CreateDurableConsumer(new ActiveMQTopic(_name), _connection.ClientId, null, false);
                            _consumer.Listener += OnReceived;
                            _isConnect = true;
                            _logger.Info("连接指令队列服务器成功![{0}-{1}]".GetFormat(_name, _uri));
                        }
                        catch (Exception ex)
                        {
                            _logger.Error("连接指令队列服务器失败![{0}-{1}]".GetFormat(_name, _uri), ex);
                            _isConnect = false;
                        }
                    }
                    Thread.Sleep(10 * 1000);
                }

            }, _cts.Token);
        }
开发者ID:hhahh2011,项目名称:CH.Spartan,代码行数:38,代码来源:InstructionService.cs

示例3: CreateConsumer

 /// <summary>
 /// Creates a MessageConsumer for the given Session and Destination.
 /// </summary>
 /// <param name="session">The session to create a MessageConsumer for.</param>
 /// <param name="destination">The destination to create a MessageConsumer for.</param>
 /// <returns>The new MessageConsumer</returns>
 protected IMessageConsumer CreateConsumer(ISession session, IDestination destination)
 {
     // Only pass in the NoLocal flag in case of a Topic:
     // Some NMS providers, such as WebSphere MQ 6.0, throw IllegalStateException
     // in case of the NoLocal flag being specified for a Queue.
     if (PubSubDomain)
     {
         if (SubscriptionDurable && destination is ITopic)
         {
             return session.CreateDurableConsumer(
                 (ITopic) destination, DurableSubscriptionName, MessageSelector, PubSubNoLocal);
         }
         else
         {
             return session.CreateConsumer(destination, MessageSelector, PubSubNoLocal);
         }
     }
     else
     {
         return session.CreateConsumer(destination, MessageSelector);
     }
 }
开发者ID:Binodesk,项目名称:spring-net,代码行数:28,代码来源:SimpleMessageListenerContainer.cs

示例4: CreateConsumer

 /// <summary>
 /// Create a message consumer to the given destination
 /// </summary>
 /// <param name="session">session to connect to</param>
 /// <param name="destination">destination topic to read from</param>
 /// <param name="appendedText">optional text to append to durable subscriber name</param>
 /// <returns>a consumer to the given destination</returns>
 private IMessageConsumer CreateConsumer(ISession session, ITopic destination, string appendedText = null)
 {
     string subscriberId = ConfigurationManager.AppSettings["ActiveMQDurableSubscriberId"];
     if (!string.IsNullOrEmpty(subscriberId))
         return session.CreateDurableConsumer(destination, string.Concat(subscriberId, appendedText), null, false);
     else
         return session.CreateConsumer(destination);
 }
开发者ID:blueghostuk,项目名称:trainnotifier-server,代码行数:15,代码来源:NMSConnector.cs


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