diff options
| author | Robert Greig <rgreig@apache.org> | 2007-01-25 17:03:28 +0000 |
|---|---|---|
| committer | Robert Greig <rgreig@apache.org> | 2007-01-25 17:03:28 +0000 |
| commit | 96296840180eefa351681653690a8c93a044d2b7 (patch) | |
| tree | 1b31c42f9276c4e2547307e27bb7d5c15bb825fc /java | |
| parent | 8a0f93bf04d6460dc79373372f82e57e08a0d264 (diff) | |
| download | qpid-python-96296840180eefa351681653690a8c93a044d2b7.tar.gz | |
QPID-318 : Patch supplied by Rob Godfrey - remove hard-coding of protocol values
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@499851 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
9 files changed, 31 insertions, 49 deletions
diff --git a/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQPFastProtocolHandler.java b/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQPFastProtocolHandler.java index 474714680b..dd56fe87ec 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQPFastProtocolHandler.java +++ b/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQPFastProtocolHandler.java @@ -162,7 +162,8 @@ public class AMQPFastProtocolHandler extends IoHandlerAdapter implements Protoco // TODO: Connect this to the session version obtained from ProtocolInitiation for this session. // Be aware of possible changes to parameter order as versions change. protocolSession.write(ConnectionCloseBody.createAMQFrame(0, - (byte)8, (byte)0, // AMQP version (major, minor) + session.getProtocolMajorVersion(), + session.getProtocolMinorVersion(), // AMQP version (major, minor) 0, // classId 0, // methodId 200, // replyCode diff --git a/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBean.java b/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBean.java index b5fec39626..0b21d26d32 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBean.java +++ b/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBean.java @@ -206,7 +206,8 @@ public class AMQProtocolSessionMBean extends AMQManagedObject implements Managed // TODO: Connect this to the session version obtained from ProtocolInitiation for this session. // Be aware of possible changes to parameter order as versions change. final AMQFrame response = ConnectionCloseBody.createAMQFrame(0, - (byte)8, (byte)0, // AMQP version (major, minor) + _session.getProtocolMajorVersion(), + _session.getProtocolMinorVersion(), // AMQP version (major, minor) 0, // classId 0, // methodId AMQConstant.REPLY_SUCCESS.getCode(), // replyCode diff --git a/java/broker/src/main/java/org/apache/qpid/server/queue/SubscriptionImpl.java b/java/broker/src/main/java/org/apache/qpid/server/queue/SubscriptionImpl.java index e120752959..181f41fbec 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/queue/SubscriptionImpl.java +++ b/java/broker/src/main/java/org/apache/qpid/server/queue/SubscriptionImpl.java @@ -399,7 +399,8 @@ public class SubscriptionImpl implements Subscription // TODO: Connect this to the session version obtained from ProtocolInitiation for this session. // Be aware of possible changes to parameter order as versions change. protocolSession.writeFrame(BasicCancelOkBody.createAMQFrame(channel.getChannelId(), - (byte)8, (byte)0, // AMQP version (major, minor) + protocolSession.getProtocolMajorVersion(), + protocolSession.getProtocolMinorVersion(), consumerTag // consumerTag )); _closed = true; @@ -417,22 +418,4 @@ public class SubscriptionImpl implements Subscription } - private ByteBuffer createEncodedDeliverFrame(long deliveryTag, AMQShortString routingKey, AMQShortString exchange) - { - // AMQP version change: Hardwire the version to 0-8 (major=8, minor=0) - // TODO: Connect this to the session version obtained from ProtocolInitiation for this session. - // Be aware of possible changes to parameter order as versions change. - AMQFrame deliverFrame = BasicDeliverBody.createAMQFrame(channel.getChannelId(), - (byte)8, (byte)0, // AMQP version (major, minor) - consumerTag, // consumerTag - deliveryTag, // deliveryTag - exchange, // exchange - false, // redelivered - routingKey // routingKey - ); - ByteBuffer buf = ByteBuffer.allocate((int) deliverFrame.getSize()); // XXX: Could cast be a problem? - deliverFrame.writePayload(buf); - buf.flip(); - return buf; - } } diff --git a/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java b/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java index 79647e8dee..8bc98bc495 100644 --- a/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java +++ b/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java @@ -134,11 +134,10 @@ public class BasicMessageProducer extends Closeable implements org.apache.qpid.j { // Declare the exchange // Note that the durable and internal arguments are ignored since passive is set to false - // AMQP version change: Hardwire the version to 0-8 (major=8, minor=0) - // TODO: Connect this to the session version obtained from ProtocolInitiation for this session. - // Be aware of possible changes to parameter order as versions change. + // TODO: Be aware of possible changes to parameter order as versions change. AMQFrame declare = ExchangeDeclareBody.createAMQFrame(_channelId, - (byte)8, (byte)0, // AMQP version (major, minor) + _protocolHandler.getProtocolMajorVersion(), + _protocolHandler.getProtocolMinorVersion(), null, // arguments false, // autoDelete false, // durable @@ -528,7 +527,8 @@ public class BasicMessageProducer extends Closeable implements org.apache.qpid.j // TODO: Connect this to the session version obtained from ProtocolInitiation for this session. // Be aware of possible changes to parameter order as versions change. AMQFrame publishFrame = BasicPublishBody.createAMQFrame(_channelId, - (byte)8, (byte)0, // AMQP version (major, minor) + _protocolHandler.getProtocolMajorVersion(), + _protocolHandler.getProtocolMinorVersion(), destination.getExchangeName(), // exchange immediate, // immediate mandatory, // mandatory @@ -575,9 +575,13 @@ public class BasicMessageProducer extends Closeable implements org.apache.qpid.j // weight argument of zero indicates no child content headers, just bodies // AMQP version change: Hardwire the version to 0-8 (major=8, minor=0) // TODO: Connect this to the session version obtained from ProtocolInitiation for this session. - AMQFrame contentHeaderFrame = ContentHeaderBody.createAMQFrame(_channelId, BasicConsumeBody.getClazz((byte)8, (byte)0), 0, - contentHeaderProperties, - size); + AMQFrame contentHeaderFrame = + ContentHeaderBody.createAMQFrame(_channelId, + BasicConsumeBody.getClazz(_protocolHandler.getProtocolMajorVersion(), + _protocolHandler.getProtocolMinorVersion()), + 0, + contentHeaderProperties, + size); if (_logger.isDebugEnabled()) { _logger.debug("Sending content header frame to " + destination); diff --git a/java/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseMethodHandler.java b/java/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseMethodHandler.java index 17869154c2..520f4e9534 100644 --- a/java/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseMethodHandler.java +++ b/java/client/src/main/java/org/apache/qpid/client/handler/ChannelCloseMethodHandler.java @@ -59,10 +59,9 @@ public class ChannelCloseMethodHandler implements StateAwareMethodListener _logger.debug("Channel close reply code: " + errorCode + ", reason: " + reason); } - // AMQP version change: Hardwire the version to 0-8 (major=8, minor=0) - // TODO: Connect this to the session version obtained from ProtocolInitiation for this session. - // Be aware of possible changes to parameter order as versions change. - AMQFrame frame = ChannelCloseOkBody.createAMQFrame(evt.getChannelId(), (byte)8, (byte)0); + + // TODO: Be aware of possible changes to parameter order as versions change. + AMQFrame frame = ChannelCloseOkBody.createAMQFrame(evt.getChannelId(), method.getMajor(), method.getMinor()); protocolSession.writeFrame(frame); if (errorCode != AMQConstant.REPLY_SUCCESS.getCode()) { diff --git a/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionCloseMethodHandler.java b/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionCloseMethodHandler.java index b9f97f7a46..e9931bf21f 100644 --- a/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionCloseMethodHandler.java +++ b/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionCloseMethodHandler.java @@ -61,10 +61,8 @@ public class ConnectionCloseMethodHandler implements StateAwareMethodListener AMQShortString reason = method.replyText; // TODO: check whether channel id of zero is appropriate - // AMQP version change: Hardwire the version to 0-8 (major=8, minor=0) - // TODO: Connect this to the session version obtained from ProtocolInitiation for this session. // Be aware of possible changes to parameter order as versions change. - protocolSession.writeFrame(ConnectionCloseOkBody.createAMQFrame((short)0, (byte)8, (byte)0)); + protocolSession.writeFrame(ConnectionCloseOkBody.createAMQFrame((short)0, method.getMajor(), method.getMinor())); if (errorCode != 200) { diff --git a/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionSecureMethodHandler.java b/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionSecureMethodHandler.java index 165b83e05d..4961c3296b 100644 --- a/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionSecureMethodHandler.java +++ b/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionSecureMethodHandler.java @@ -59,7 +59,7 @@ public class ConnectionSecureMethodHandler implements StateAwareMethodListener // TODO: Connect this to the session version obtained from ProtocolInitiation for this session. // Be aware of possible changes to parameter order as versions change. AMQFrame responseFrame = ConnectionSecureOkBody.createAMQFrame(evt.getChannelId(), - (byte)8, (byte)0, // AMQP version (major, minor) + body.getMajor(), body.getMinor(), response); // response protocolSession.writeFrame(responseFrame); } diff --git a/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionTuneMethodHandler.java b/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionTuneMethodHandler.java index 2adafb8be7..25986ebf21 100644 --- a/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionTuneMethodHandler.java +++ b/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionTuneMethodHandler.java @@ -62,34 +62,30 @@ public class ConnectionTuneMethodHandler implements StateAwareMethodListener protocolSession.setConnectionTuneParameters(params); stateManager.changeState(AMQState.CONNECTION_NOT_OPENED); - protocolSession.writeFrame(createTuneOkFrame(evt.getChannelId(), params)); + protocolSession.writeFrame(createTuneOkFrame(evt.getChannelId(), params,frame.getMajor(), frame.getMinor())); String host = protocolSession.getAMQConnection().getVirtualHost(); AMQShortString virtualHost = new AMQShortString("/" + host); - protocolSession.writeFrame(createConnectionOpenFrame(evt.getChannelId(), virtualHost, null, true)); + protocolSession.writeFrame(createConnectionOpenFrame(evt.getChannelId(), virtualHost, null, true,frame.getMajor(), frame.getMinor())); } - protected AMQFrame createConnectionOpenFrame(int channel, AMQShortString path, AMQShortString capabilities, boolean insist) + protected AMQFrame createConnectionOpenFrame(int channel, AMQShortString path, AMQShortString capabilities, boolean insist, byte major, byte minor) { - // AMQP version change: Hardwire the version to 0-8 (major=8, minor=0) - // TODO: Connect this to the session version obtained from ProtocolInitiation for this session. // Be aware of possible changes to parameter order as versions change. return ConnectionOpenBody.createAMQFrame(channel, - (byte)8, (byte)0, // AMQP version (major, minor) + major, minor, // AMQP version (major, minor) capabilities, // capabilities insist, // insist path); // virtualHost } - protected AMQFrame createTuneOkFrame(int channel, ConnectionTuneParameters params) + protected AMQFrame createTuneOkFrame(int channel, ConnectionTuneParameters params, byte major, byte minor) { - // AMQP version change: Hardwire the version to 0-8 (major=8, minor=0) - // TODO: Connect this to the session version obtained from ProtocolInitiation for this session. // Be aware of possible changes to parameter order as versions change. return ConnectionTuneOkBody.createAMQFrame(channel, - (byte)8, (byte)0, // AMQP version (major, minor) + major, minor, params.getChannelMax(), // channelMax params.getFrameMax(), // frameMax params.getHeartbeat()); // heartbeat diff --git a/java/cluster/src/main/java/org/apache/qpid/server/cluster/ClientHandlerRegistry.java b/java/cluster/src/main/java/org/apache/qpid/server/cluster/ClientHandlerRegistry.java index a371748b9e..5300912716 100644 --- a/java/cluster/src/main/java/org/apache/qpid/server/cluster/ClientHandlerRegistry.java +++ b/java/cluster/src/main/java/org/apache/qpid/server/cluster/ClientHandlerRegistry.java @@ -122,9 +122,9 @@ public class ClientHandlerRegistry extends AMQStateManager class ConnectionTuneHandler extends ConnectionTuneMethodHandler { - protected AMQFrame createConnectionOpenFrame(int channel, AMQShortString path, AMQShortString capabilities, boolean insist) + protected AMQFrame createConnectionOpenFrame(int channel, AMQShortString path, AMQShortString capabilities, boolean insist, byte major, byte minor) { - return super.createConnectionOpenFrame(channel, path, new AMQShortString(ClusterCapability.add(capabilities, _identity)), insist); + return super.createConnectionOpenFrame(channel, path, new AMQShortString(ClusterCapability.add(capabilities, _identity)), insist, major, minor); } } } |
