diff options
| author | Arnaud Simon <arnaudsimon@apache.org> | 2008-04-02 09:55:27 +0000 |
|---|---|---|
| committer | Arnaud Simon <arnaudsimon@apache.org> | 2008-04-02 09:55:27 +0000 |
| commit | 42dcda5fb197d0fa85788c9aa04d6c1b2ae1822d (patch) | |
| tree | fb7241e67c2133e4c5f36d9842bdf744370d2c02 /qpid/java/common | |
| parent | eb34891fb4886a975039df3aa58ecbffa299acd6 (diff) | |
| download | qpid-python-42dcda5fb197d0fa85788c9aa04d6c1b2ae1822d.tar.gz | |
QPID-829 Remove 0.10 specific URL. The code path is now selected based on broker response. We first try the highest protocol version and update the handler if the broker replies with a different protocol version. NOTE that we need to update the current java broker and 0.8 client for handling protocol headers. This should happen with the M2.1 merge. For the moment we only support an in VM 0.8 broker. Moreover, we'll need to migrate to a 0.10 vs 99.0 protocol version.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@643822 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/common')
7 files changed, 116 insertions, 4 deletions
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/AMQProtocolException.java b/qpid/java/common/src/main/java/org/apache/qpid/AMQProtocolException.java new file mode 100644 index 0000000000..bbc569839a --- /dev/null +++ b/qpid/java/common/src/main/java/org/apache/qpid/AMQProtocolException.java @@ -0,0 +1,38 @@ +package org.apache.qpid; + +import org.apache.qpid.protocol.AMQConstant; + +/* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +public class AMQProtocolException extends AMQException +{ + /** + * Constructor for a Protocol Exception + * <p> This is the only provided constructor and the parameters have to be + * set to null when they are unknown. + * + * @param msg A description of the reason of this exception . + * @param errorCode A string specifyin the error code of this exception. + * @param cause The linked Execption. + */ + public AMQProtocolException(AMQConstant errorCode, String msg, Throwable cause) + { + super(errorCode, msg, cause); + } +} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java b/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java index 375df2a45d..8dee790a9e 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/protocol/AMQConstant.java @@ -153,6 +153,15 @@ public final class AMQConstant public static final AMQConstant FRAME_MIN_SIZE = new AMQConstant(4096, "frame min size", true); + /** + * The server does not support the protocol version + */ + public static final AMQConstant UNSUPPORTED_BROKER_PROTOCOL_ERROR = new AMQConstant(542, "broker unsupported protocol", true); + /** + * The client imp does not support the protocol version + */ + public static final AMQConstant UNSUPPORTED_CLIENT_PROTOCOL_ERROR = new AMQConstant(543, "client unsupported protocol", true); + /** The AMQP status code. */ private int _code; diff --git a/qpid/java/common/src/main/java/org/apache/qpidity/ErrorCode.java b/qpid/java/common/src/main/java/org/apache/qpidity/ErrorCode.java index 4ff6939139..4b18c46d16 100644 --- a/qpid/java/common/src/main/java/org/apache/qpidity/ErrorCode.java +++ b/qpid/java/common/src/main/java/org/apache/qpidity/ErrorCode.java @@ -6,6 +6,7 @@ public enum ErrorCode UNDEFINED(1,"undefined",true), MESSAGE_REJECTED(2,"message_rejected",true), CONNECTION_ERROR(3,"connection was closed",true), + UNSUPPORTED_PROTOCOL(4, "protocol version is unsupported", true), //This might change in the spec, the error class is not applicable NO_ERROR(200,"reply-success",true), diff --git a/qpid/java/common/src/main/java/org/apache/qpidity/ProtocolException.java b/qpid/java/common/src/main/java/org/apache/qpidity/ProtocolException.java new file mode 100644 index 0000000000..596143a1b9 --- /dev/null +++ b/qpid/java/common/src/main/java/org/apache/qpidity/ProtocolException.java @@ -0,0 +1,36 @@ +/* Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.qpidity; + +public class ProtocolException extends QpidException +{ + /** + * Constructor for a Ptotocol Exception. + * <p> This is the only provided constructor and the parameters have to be set to null when + * they are unknown. + * @param message A description of the reason of this exception. + * @param errorCode A string specifyin the error code of this exception. + * @param cause The linked Execption. + * + */ + public ProtocolException(String message, ErrorCode errorCode, Throwable cause) + { + super(message, errorCode, cause); + } +} diff --git a/qpid/java/common/src/main/java/org/apache/qpidity/ToyClient.java b/qpid/java/common/src/main/java/org/apache/qpidity/ToyClient.java index e455be0873..10b68bbb20 100644 --- a/qpid/java/common/src/main/java/org/apache/qpidity/ToyClient.java +++ b/qpid/java/common/src/main/java/org/apache/qpidity/ToyClient.java @@ -75,7 +75,9 @@ class ToyClient extends SessionDelegate } public void closed() {} }); - conn.send(new ConnectionEvent(0, new ProtocolHeader(1, TransportConstants.CONNECTION_VERSION_MAJOR, TransportConstants.CONNECTION_VERSION_MINOR))); + conn.send(new ConnectionEvent(0, new ProtocolHeader(1, + TransportConstants.getVersionMajor(), + TransportConstants.getVersionMinor()))); Channel ch = conn.getChannel(0); Session ssn = new Session(); diff --git a/qpid/java/common/src/main/java/org/apache/qpidity/transport/ConnectionDelegate.java b/qpid/java/common/src/main/java/org/apache/qpidity/transport/ConnectionDelegate.java index 21c7b8c16b..4815f1025f 100644 --- a/qpid/java/common/src/main/java/org/apache/qpidity/transport/ConnectionDelegate.java +++ b/qpid/java/common/src/main/java/org/apache/qpidity/transport/ConnectionDelegate.java @@ -83,7 +83,8 @@ public abstract class ConnectionDelegate extends MethodDelegate<Channel> if (hdr.getMajor() != 0 && hdr.getMinor() != 10) { // XXX - ch.getConnection().send(new ConnectionEvent(0, new ProtocolHeader(1, TransportConstants.CONNECTION_VERSION_MAJOR, TransportConstants.CONNECTION_VERSION_MINOR))); + ch.getConnection().send(new ConnectionEvent(0, new ProtocolHeader(1, TransportConstants.getVersionMajor(), + TransportConstants.getVersionMinor()))); ch.getConnection().close(); } else @@ -282,4 +283,9 @@ public abstract class ConnectionDelegate extends MethodDelegate<Channel> { _virtualHost = host; } + + public String getUnsupportedProtocol() + { + return null; + } } diff --git a/qpid/java/common/src/main/java/org/apache/qpidity/transport/TransportConstants.java b/qpid/java/common/src/main/java/org/apache/qpidity/transport/TransportConstants.java index 47f7f17578..54429a1a4f 100644 --- a/qpid/java/common/src/main/java/org/apache/qpidity/transport/TransportConstants.java +++ b/qpid/java/common/src/main/java/org/apache/qpidity/transport/TransportConstants.java @@ -2,6 +2,26 @@ package org.apache.qpidity.transport; public class TransportConstants { - public static final byte CONNECTION_VERSION_MAJOR = 99; - public static final byte CONNECTION_VERSION_MINOR = 0; + private static byte _protocol_version_minor = 0; + private static byte _protocol_version_major = 99; + + public static void setVersionMajor(byte value) + { + _protocol_version_major = value; + } + + public static void setVersionMinor(byte value) + { + _protocol_version_minor = value; + } + + public static byte getVersionMajor() + { + return _protocol_version_major; + } + + public static byte getVersionMinor() + { + return _protocol_version_minor; + } } |
