public override void Open(TimeSpan timeout)
        {
            if (State != CommunicationState.Created && State != CommunicationState.Closed)
            {
                throw new InvalidOperationException(string.Format("Cannot open the channel from the {0} state.", State));
            }

            OnOpening();

            var qr = (QueueQueryResult)_session.queueQuery(_queueName).Result;

            if (qr.getQueue() == null)
            {
                // create the queue
                _session.queueDeclare(_queueName, null, null);
            }
            // bind the queue
            _session.exchangeBind(_queueName, "amq.direct", _queueName, null);
            var myListener = new WCFListener(_queue);

            _session.attachMessageListener(myListener, "myDest");
            _session.messageSubscribe(_queueName, "myDest", MessageAcceptMode.EXPLICIT, MessageAcquireMode.PRE_ACQUIRED,
                                      null,
                                      0, null);
            // issue credits
            _session.messageSetFlowMode("myDest", MessageFlowMode.WINDOW);
            _session.messageFlow("myDest", MessageCreditUnit.BYTE, ClientSession.MESSAGE_FLOW_MAX_BYTES);
            _session.sync();

            OnOpened();
        }
Example #2
0
        public override void Open(TimeSpan timeout)
        {
            if (State != CommunicationState.Created && State != CommunicationState.Closed)
                throw new InvalidOperationException(string.Format("Cannot open the channel from the {0} state.", State));

            OnOpening();

            var qr = (QueueQueryResult) _session.queueQuery(_queueName).Result;
            if (qr.getQueue() == null)
            {
                // create the queue 
                _session.queueDeclare(_queueName, null, null);
            }
            // bind the queue 
            _session.exchangeBind(_queueName, "amq.direct", _queueName, null);
            var myListener = new WCFListener(_queue);
            _session.attachMessageListener(myListener, "myDest");
            _session.messageSubscribe(_queueName, "myDest", MessageAcceptMode.EXPLICIT, MessageAcquireMode.PRE_ACQUIRED,
                                      null,
                                      0, null);
            // issue credits     
            _session.messageSetFlowMode("myDest", MessageFlowMode.WINDOW);
            _session.messageFlow("myDest", MessageCreditUnit.BYTE, ClientSession.MESSAGE_FLOW_MAX_BYTES);
            _session.sync();

            OnOpened();
        }