public void Initialize(AMQProtocolSession session)
      {
         if ( session == null )
            throw new ArgumentNullException("session");

         _session = session;
      }
Example #2
0
 public AMQMethodEvent(ushort channelId, AMQMethodBody method, AMQProtocolSession protocolSession)
 {
     _channelId = channelId;
     _method = method;
     _protocolSession = protocolSession;
 }
Example #3
0
        private void MakeBrokerConnection(IBrokerInfo brokerDetail)
        {
            try
            {
                _stateManager = new AMQStateManager();
                _protocolListener = new AMQProtocolListener(this, _stateManager);
                _protocolListener.AddFrameListener(_stateManager);

                /*
                // Currently there is only one transport option - BlockingSocket.
                String assemblyName = "Apache.Qpid.Client.Transport.Socket.Blocking.dll";
                String transportType = "Apache.Qpid.Client.Transport.Socket.Blocking.BlockingSocketTransport";

                // Load the transport assembly dynamically.
                _transport = LoadTransportFromAssembly(brokerDetail.getHost(), brokerDetail.getPort(), assemblyName, transportType);
                */

                _transport = new BlockingSocketTransport();
                
                // Connect.
                _transport.Connect(brokerDetail, this);                
                _protocolWriter = new ProtocolWriter(_transport.ProtocolWriter, _protocolListener);
                _protocolSession = new AMQProtocolSession(_transport.ProtocolWriter, _transport, this);
                _protocolListener.ProtocolSession = _protocolSession;

                // Now start the connection "handshake".
                _transport.ProtocolWriter.Write(new ProtocolInitiation());

                // Blocks until the connection has been opened.
                _stateManager.AttainState(AMQState.CONNECTION_OPEN);

                _failoverPolicy.attainedConnection();

                // XXX: Again this should be changed to a suitable notify.
                _connected = true;
            }
            catch (AMQException e)
            {
                _lastAMQException = e;
                throw; // rethrow
            }
        }
Example #4
0
 public AMQMethodEvent(ushort channelId, AMQMethodBody method, AMQProtocolSession protocolSession)
 {
     _channelId       = channelId;
     _method          = method;
     _protocolSession = protocolSession;
 }
 private IAMQCallbackHandler CreateCallbackHandler(string mechanism, AMQProtocolSession session)
 {
     Type type = CallbackHandlerRegistry.Instance.GetCallbackHandler(mechanism);
     IAMQCallbackHandler handler = 
         (IAMQCallbackHandler)Activator.CreateInstance(type);
     if ( handler == null )
         throw new AMQException("Unable to create callback handler: " + mechanism);
     handler.Initialize(session);
     return handler;
 }
 private byte[] DoAuthentication(string selectedMechanism, AMQProtocolSession ps)
 {
     ISaslClient saslClient = Sasl.Sasl.CreateClient(
         new string[] { selectedMechanism }, null, "AMQP", "localhost",
         new Hashtable(), CreateCallbackHandler(selectedMechanism, ps)
     );
     if ( saslClient == null )
     {
         throw new AMQException("Client SASL configuration error: no SaslClient could be created for mechanism " +
                                selectedMechanism);
     }
     ps.SaslClient = saslClient;
     try
     {
         return saslClient.HasInitialResponse ?
            saslClient.EvaluateChallenge(new byte[0]) : null;
     } catch ( Exception ex )
     {
         ps.SaslClient = null;
         throw new AMQException("Unable to create SASL client", ex);
     }
 }