Beispiel #1
0
    def _on_connected(self):
        """
        This is called by our connection Adapter to let us know that we've
        connected and we can notify our connection strategy.
        """
        self._set_connection_state(self.CONNECTION_PROTOCOL)

        # Start the communication with the RabbitMQ Broker
        self._send_frame(frame.ProtocolHeader())
Beispiel #2
0
    def _check_for_protocol_mismatch(self, value):
        """Invoked when starting a connection to make sure it's a supported
        protocol.

        :param pika.frame.Method value: The frame to check
        :raises: ProtocolVersionMismatch

        """
        if (value.method.version_major,
                value.method.version_minor) != spec.PROTOCOL_VERSION[0:2]:
            raise exceptions.ProtocolVersionMismatch(frame.ProtocolHeader(),
                                                     value)
Beispiel #3
0
    def _handshake(self):
        connection_start = self.rpc0(self.channel_number0, frame.ProtocolHeader(), [spec.Connection.Start])
        self.server_properties = connection_start.server_properties
        self.publisher_confirms = self.server_properties['capabilities']['publisher_confirms']
        self.basic_nack = self.server_properties['capabilities']['basic.nack']
        (auth_type, response) = self.parameters.credentials.response_for(connection_start)
        tune = self.rpc0(self.channel_number0, spec.Connection.StartOk(self.client_properties, auth_type, response,
                                                                       self.parameters.locale), [spec.Connection.Tune])
        self.channel_max = tune.channel_max or self.parameters.channel_max
        self.frame_max = tune.frame_max or self.parameters.frame_max
        self.heartbeat = min(tune.heartbeat, self.parameters.heartbeat)

        self.send_method(self.channel_number0, spec.Connection.TuneOk(self.channel_max, self.frame_max,
                                                                      self.heartbeat))
        self.rpc0(self.channel_number0, spec.Connection.Open(self.parameters.virtual_host, '', False),
                  [spec.Connection.OpenOk])
 def test_name_or_value_protocol_header(self):
     self.assertEqual(callback._name_or_value(frame.ProtocolHeader()),
                      'ProtocolHeader')
Beispiel #5
0
 def protocol_header_marshal_test(self):
     protocol_header = frame.ProtocolHeader()
     self.assertEqual(protocol_header.marshal(), self.PROTOCOL_HEADER)