Search in sources :

Example 1 with ProtocolVersion

use of org.apache.qpid.server.protocol.ProtocolVersion in project qpid-broker-j by apache.

the class AMQPConnection_0_8Impl method protocolInitiationReceived.

private synchronized void protocolInitiationReceived(ProtocolInitiation pi) {
    // this ensures the codec never checks for a PI message again
    _decoder.setExpectProtocolInitiation(false);
    try {
        // Fails if not correct
        ProtocolVersion pv = pi.checkVersion();
        setProtocolVersion(pv);
        StringBuilder mechanismBuilder = new StringBuilder();
        for (String mechanismName : getPort().getAuthenticationProvider().getAvailableMechanisms(getTransport().isSecure())) {
            if (mechanismBuilder.length() != 0) {
                mechanismBuilder.append(' ');
            }
            mechanismBuilder.append(mechanismName);
        }
        String mechanisms = mechanismBuilder.toString();
        String locales = "en_US";
        Map<String, Object> props = Collections.emptyMap();
        for (ConnectionPropertyEnricher enricher : getPort().getConnectionPropertyEnrichers()) {
            props = enricher.addConnectionProperties(this, props);
        }
        FieldTable serverProperties = FieldTable.convertToFieldTable(props);
        AMQMethodBody responseBody = getMethodRegistry().createConnectionStartBody((short) getProtocolMajorVersion(), (short) pv.getActualMinorVersion(), serverProperties, mechanisms.getBytes(US_ASCII), locales.getBytes(US_ASCII));
        writeFrame(responseBody.generateFrame(0));
        _state = ConnectionState.AWAIT_START_OK;
        _sender.flush();
    } catch (QpidException e) {
        LOGGER.debug("Received unsupported protocol initiation for protocol version: {} ", getProtocolVersion());
        writeFrame(new ProtocolInitiation(ProtocolVersion.getLatestSupportedVersion()));
        _sender.flush();
    }
}
Also used : QpidException(org.apache.qpid.server.QpidException) ConnectionPropertyEnricher(org.apache.qpid.server.plugin.ConnectionPropertyEnricher) ProtocolVersion(org.apache.qpid.server.protocol.ProtocolVersion)

Aggregations

QpidException (org.apache.qpid.server.QpidException)1 ConnectionPropertyEnricher (org.apache.qpid.server.plugin.ConnectionPropertyEnricher)1 ProtocolVersion (org.apache.qpid.server.protocol.ProtocolVersion)1