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


C# ISession.GetDestination方法代码示例

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


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

示例1: OpenWireConsumer

        /// <summary>
        /// 消息消费构造器
        /// </summary>
        /// <param name="brokerUri">地址</param>
        /// <param name="username">用户名</param>
        /// <param name="psw">密码</param>
        /// <param name="clientId">客户端标识 兼做队列接收目的地</param>
        /// <param name="isClient">true 客户端;false 服务端</param>
        public OpenWireConsumer(string brokerUri, string username, string psw, string clientId,bool isClient)
        {
            NMSConnectionFactory _factory = new NMSConnectionFactory(brokerUri, clientId);
            _connection = _factory.CreateConnection(username, psw);
            _connection.Start();
            _session = _connection.CreateSession(AcknowledgementMode.AutoAcknowledge);

            if (isClient)
            {
                _qReceiveDest = _session.GetDestination(clientId, DestinationType.TemporaryQueue);
            }
            else
            {
                _qReceiveDest = _session.GetQueue(clientId);
            }

            _messageConsumer = _session.CreateConsumer(_qReceiveDest);
            _messageConsumer.Listener += (message) =>
            {
                if (Listener != null)
                {
                    Listener(message);
                }
            };
        }
开发者ID:OldApple,项目名称:MQProxy,代码行数:33,代码来源:OpenWireMiddleware.cs

示例2: Queue

        public Queue(MsgDeliveryMode mode = MsgDeliveryMode.NonPersistent)
        {
            Uri msgQueue = new Uri("activemq:tcp://localhost:61616");

            _factory = new ConnectionFactory(msgQueue);
            try
            {
                _connection = _factory.CreateConnection();
            }
            catch (NMSConnectionException ex)
            {
                Log.FatalException("Error connecting to MQ server", ex);
                throw;
            }
            // TODO check _connection for null
            _connection.RequestTimeout = TimeSpan.FromSeconds(60);
            Session = _connection.CreateSession();

            // TODO need to find out if queue exists.
            // It creates a new queue if it doesn't exist.
            _destination = Session.GetDestination("queue://TwitterSearchStream");
            _consumer = Session.CreateConsumer(_destination);

            _producer = Session.CreateProducer(_destination);
            _producer.RequestTimeout = TimeSpan.FromSeconds(60);
            _producer.DeliveryMode = mode;

            _connection.Start();

            _connection.ExceptionListener += _connection_ExceptionListener;
            _connection.ConnectionInterruptedListener += _connection_ConnectionInterruptedListener;
        }
开发者ID:cfmayer,项目名称:Toketee,代码行数:32,代码来源:Queue.cs

示例3: Configure

        private void Configure(string destination)
        {
            Destination dest = new Destination(destination);

            Uri connectionUri = new Uri(dest.Host);
            _factory = new NMSConnectionFactory(connectionUri);
            _connection = _factory.CreateConnection();
            _session = _connection.CreateSession();
            _connection.Start();
            _destination = _session.GetDestination(dest.Queue);
        }
开发者ID:frenzqse,项目名称:loom-csharp-visualstudio,代码行数:11,代码来源:JMSPort.cs

示例4: Configure

        /// <summary>
        /// Configurate the Connection
        /// </summary>
        /// <param name="destination">Destionation</param>
        private void Configure(string destination)
        {
            Destination dest = new Destination(destination);

            Uri connectionUri = new Uri(dest.Host);
            factory = new Apache.NMS.ActiveMQ.ConnectionFactory(connectionUri);
            connection = factory.CreateConnection();
            session = connection.CreateSession();
            connection.Start();
            this.destination = session.GetDestination(dest.Queue);
        }
开发者ID:Mercynary,项目名称:loom-csharp,代码行数:15,代码来源:JMSPort.cs

示例5: Search

        public Search(IEnumerable<string> searchFilter)
        {
            // TODO app setting
            Uri msgQueue = new Uri("activemq:tcp://localhost:61616");

            _factory = new ConnectionFactory(msgQueue);

            try
            {
                _connection = _factory.CreateConnection();
            }
            catch (NMSConnectionException ex)
            {
                Log.FatalException("Error connecting to MQ server", ex);
                throw;
            }
            // TODO handle -- throws connectionclosedexception
            _session = _connection.CreateSession();

            // TODO app setting
            _destination = _session.GetDestination("queue://TwitterSearchStream");
            _producer = _session.CreateProducer(_destination);

            _connection.Start();
            _producer.DeliveryMode = MsgDeliveryMode.NonPersistent;
            _producer.RequestTimeout = TimeSpan.FromSeconds(60);

            // TODO app setting -- Put your username/password here
            searchStream = new SearchStream(uri, "username", "password");
            searchStream.StatusReceived += new EventHandler<StreamEvent>(searchStream_StatusReceived);

            var searchTerms = new Dictionary<string, string>();
            searchTerms.Add("track", string.Join(",", searchFilter.Select(HttpUtility.UrlEncode)));

            searchStream.StartStream(searchTerms);

            while (true)
            {
                Thread.Sleep(1000);
            }
        }
开发者ID:cfmayer,项目名称:Toketee,代码行数:41,代码来源:Search.cs

示例6: Configure

        /// <summary>
        /// Configurate the Connection
        /// </summary>
        /// <param name="destination">Destionation</param>
        protected void Configure()
        {
            if (close) return;
            if (nbrretry++ >= maxretries)
                handling = EExceptionHandling.ForwardException;

            try
            {
                Destination dest = new Destination(string_destination);
                Uri connectionUri = new Uri(dest.Host);
                factory = new Apache.NMS.ActiveMQ.ConnectionFactory(connectionUri);
                connection = factory.CreateConnection();
                session = connection.CreateSession();
                connection.Start();
                this.destination = session.GetDestination(dest.Queue);
                nbrretry = 0;
            }
            catch
            {
                switch (handling)
                {
                    case EExceptionHandling.ForwardException:
                        {
                            throw;
                        }
                    case EExceptionHandling.Retry:
                        {
                            Configure();
                            break;
                        }
                }
            }
        }
开发者ID:ChristophGr,项目名称:loom-csharp,代码行数:37,代码来源:JMSPort.cs


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