diff options
Diffstat (limited to 'qpid/dotnet/Qpid.Client/Client/Handler')
12 files changed, 721 insertions, 0 deletions
diff --git a/qpid/dotnet/Qpid.Client/Client/Handler/BasicDeliverMethodHandler.cs b/qpid/dotnet/Qpid.Client/Client/Handler/BasicDeliverMethodHandler.cs new file mode 100644 index 0000000000..def1e78e8c --- /dev/null +++ b/qpid/dotnet/Qpid.Client/Client/Handler/BasicDeliverMethodHandler.cs @@ -0,0 +1,42 @@ +/* + * + * 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. + * + */ +using log4net; +using Apache.Qpid.Client.Message; +using Apache.Qpid.Client.Protocol; +using Apache.Qpid.Client.State; +using Apache.Qpid.Framing; + +namespace Apache.Qpid.Client.Handler +{ + public class BasicDeliverMethodHandler : IStateAwareMethodListener + { + private static readonly ILog _logger = LogManager.GetLogger(typeof(BasicDeliverMethodHandler)); + + public void MethodReceived(AMQStateManager stateManager, AMQMethodEvent evt) + { + UnprocessedMessage msg = new UnprocessedMessage(); + msg.DeliverBody = (BasicDeliverBody) evt.Method; + msg.ChannelId = evt.ChannelId; + _logger.Debug("New JmsDeliver method received"); + evt.ProtocolSession.UnprocessedMessageReceived(msg); + } + } +} diff --git a/qpid/dotnet/Qpid.Client/Client/Handler/BasicReturnMethodHandler.cs b/qpid/dotnet/Qpid.Client/Client/Handler/BasicReturnMethodHandler.cs new file mode 100644 index 0000000000..f413dfc9c6 --- /dev/null +++ b/qpid/dotnet/Qpid.Client/Client/Handler/BasicReturnMethodHandler.cs @@ -0,0 +1,44 @@ +/* + * + * 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. + * + */ +using log4net; +using Apache.Qpid.Client.Message; +using Apache.Qpid.Client.Protocol; +using Apache.Qpid.Client.State; +using Apache.Qpid.Framing; + +namespace Apache.Qpid.Client.Handler +{ + public class BasicReturnMethodHandler : IStateAwareMethodListener + { + private static readonly ILog _logger = LogManager.GetLogger(typeof(BasicReturnMethodHandler)); + + public void MethodReceived(AMQStateManager stateManager, AMQMethodEvent evt) + { + _logger.Debug("New Basic.Return method received"); + UnprocessedMessage msg = new UnprocessedMessage(); + msg.DeliverBody = null; + msg.BounceBody = (BasicReturnBody) evt.Method; + msg.ChannelId = evt.ChannelId; + + evt.ProtocolSession.UnprocessedMessageReceived(msg); + } + } +} diff --git a/qpid/dotnet/Qpid.Client/Client/Handler/ChannelCloseMethodHandler.cs b/qpid/dotnet/Qpid.Client/Client/Handler/ChannelCloseMethodHandler.cs new file mode 100644 index 0000000000..9ed09a0d01 --- /dev/null +++ b/qpid/dotnet/Qpid.Client/Client/Handler/ChannelCloseMethodHandler.cs @@ -0,0 +1,68 @@ +/* + * + * 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. + * + */ +using log4net; +using Apache.Qpid.Client.Protocol; +using Apache.Qpid.Client.State; +using Apache.Qpid.Protocol; +using Apache.Qpid.Framing; + +namespace Apache.Qpid.Client.Handler +{ + public class ChannelCloseMethodHandler : IStateAwareMethodListener + { + private static readonly ILog _logger = LogManager.GetLogger(typeof(ChannelCloseMethodHandler)); + + public void MethodReceived(AMQStateManager stateManager, AMQMethodEvent evt) + { + _logger.Debug("ChannelClose method received"); + ChannelCloseBody method = (ChannelCloseBody) evt.Method; + + int errorCode = method.ReplyCode; + string reason = method.ReplyText; + if (_logger.IsDebugEnabled) + { + _logger.Debug("Channel close reply code: " + errorCode + ", reason: " + reason); + } + + AMQFrame frame = ChannelCloseOkBody.CreateAMQFrame(evt.ChannelId); + evt.ProtocolSession.WriteFrame(frame); + + if ( errorCode != AMQConstant.REPLY_SUCCESS.Code ) + { + _logger.Debug("Channel close received with errorCode " + errorCode + ", throwing exception"); + if ( errorCode == AMQConstant.NO_CONSUMERS.Code ) + throw new AMQNoConsumersException(reason); + if ( errorCode == AMQConstant.NO_ROUTE.Code ) + throw new AMQNoRouteException(reason); + if ( errorCode == AMQConstant.INVALID_ARGUMENT.Code ) + throw new AMQInvalidArgumentException(reason); + if ( errorCode == AMQConstant.INVALID_ROUTING_KEY.Code ) + throw new AMQInvalidRoutingKeyException(reason); + // any other + throw new AMQChannelClosedException(errorCode, "Error: " + reason); + } + evt.ProtocolSession.ChannelClosed(evt.ChannelId, errorCode, reason); + } + } +} + + + diff --git a/qpid/dotnet/Qpid.Client/Client/Handler/ConnectionCloseMethodHandler.cs b/qpid/dotnet/Qpid.Client/Client/Handler/ConnectionCloseMethodHandler.cs new file mode 100644 index 0000000000..66cff3bc65 --- /dev/null +++ b/qpid/dotnet/Qpid.Client/Client/Handler/ConnectionCloseMethodHandler.cs @@ -0,0 +1,68 @@ +/* + * + * 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. + * + */ +using System; +using System.Threading; +using log4net; +using Apache.Qpid.Client.Protocol; +using Apache.Qpid.Client.State; +using Apache.Qpid.Framing; +using Apache.Qpid.Protocol; + +namespace Apache.Qpid.Client.Handler +{ + public class ConnectionCloseMethodHandler : IStateAwareMethodListener + { + private static readonly ILog _logger = LogManager.GetLogger(typeof(ConnectionCloseMethodHandler)); + + public void MethodReceived(AMQStateManager stateManager, AMQMethodEvent evt) + { + _logger.Debug("ConnectionClose frame received"); + ConnectionCloseBody method = (ConnectionCloseBody) evt.Method; + + int errorCode = method.ReplyCode; + String reason = method.ReplyText; + + // send CloseOK + evt.ProtocolSession.WriteFrame(ConnectionCloseOkBody.CreateAMQFrame(evt.ChannelId)); + + if ( errorCode != AMQConstant.REPLY_SUCCESS.Code ) + { + if ( errorCode == AMQConstant.NOT_ALLOWED.Code ) + { + _logger.Info("Authentication Error: " + Thread.CurrentThread.Name); + evt.ProtocolSession.CloseProtocolSession(); + + //todo this is a bit of a fudge (could be conssidered such as each new connection needs a new state manager or at least a fresh state. + stateManager.ChangeState(AMQState.CONNECTION_NOT_STARTED); + + throw new AMQAuthenticationException(errorCode, reason); + } else + { + _logger.Info("Connection close received with error code " + errorCode); + throw new AMQConnectionClosedException(errorCode, "Error: " + reason); + } + } + // this actually closes the connection in the case where it is not an error. + evt.ProtocolSession.CloseProtocolSession(); + stateManager.ChangeState(AMQState.CONNECTION_CLOSED); + } + } +} diff --git a/qpid/dotnet/Qpid.Client/Client/Handler/ConnectionCloseOkHandler.cs b/qpid/dotnet/Qpid.Client/Client/Handler/ConnectionCloseOkHandler.cs new file mode 100644 index 0000000000..038da15731 --- /dev/null +++ b/qpid/dotnet/Qpid.Client/Client/Handler/ConnectionCloseOkHandler.cs @@ -0,0 +1,41 @@ +/* + * + * 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. + * + */ +using log4net; +using Apache.Qpid.Client.Protocol; +using Apache.Qpid.Client.State; +using Apache.Qpid.Framing; + +namespace Apache.Qpid.Client.Handler +{ + public class ConnectionCloseOkHandler : IStateAwareMethodListener + { + private static readonly ILog _logger = LogManager.GetLogger(typeof(ConnectionCloseOkHandler)); + + public void MethodReceived(AMQStateManager stateManager, AMQMethodEvent evt) + { + _logger.Debug("ConnectionCloseOk frame received"); +// ConnectionCloseOkBody method = (ConnectionCloseOkBody)evt.Method; + stateManager.ChangeState(AMQState.CONNECTION_CLOSED); + } + } +} + + diff --git a/qpid/dotnet/Qpid.Client/Client/Handler/ConnectionOpenOkMethodHandler.cs b/qpid/dotnet/Qpid.Client/Client/Handler/ConnectionOpenOkMethodHandler.cs new file mode 100644 index 0000000000..a12e4ead60 --- /dev/null +++ b/qpid/dotnet/Qpid.Client/Client/Handler/ConnectionOpenOkMethodHandler.cs @@ -0,0 +1,35 @@ +/* + * + * 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. + * + */ +using Apache.Qpid.Client.Protocol; +using Apache.Qpid.Client.State; + +namespace Apache.Qpid.Client.Handler +{ + public class ConnectionOpenOkMethodHandler : IStateAwareMethodListener + { + public void MethodReceived(AMQStateManager stateManager, AMQMethodEvent evt) + { + stateManager.ChangeState(AMQState.CONNECTION_OPEN); + } + } +} + + diff --git a/qpid/dotnet/Qpid.Client/Client/Handler/ConnectionRedirectMethodHandler.cs b/qpid/dotnet/Qpid.Client/Client/Handler/ConnectionRedirectMethodHandler.cs new file mode 100644 index 0000000000..08cc580b17 --- /dev/null +++ b/qpid/dotnet/Qpid.Client/Client/Handler/ConnectionRedirectMethodHandler.cs @@ -0,0 +1,68 @@ +/* + * + * 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. + * + */ +using log4net; +using Apache.Qpid.Client.Protocol; +using Apache.Qpid.Client.State; + +namespace Apache.Qpid.Client.Handler +{ + public class ConnectionRedirectMethodHandler : IStateAwareMethodListener + { +// private static readonly ILog _logger = LogManager.GetLogger(typeof(ConnectionRedirectMethodHandler)); + + private const int DEFAULT_REDIRECT_PORT = 5672; + + private static ConnectionRedirectMethodHandler _handler = new ConnectionRedirectMethodHandler(); + + public static ConnectionRedirectMethodHandler GetInstance() + { + return _handler; + } + + private ConnectionRedirectMethodHandler() + { + } + + public void MethodReceived(AMQStateManager stateManager, AMQMethodEvent evt) + { + /*_logger.Info("ConnectionRedirect frame received"); + ConnectionRedirectBody method = (ConnectionRedirectBody) evt.Method; + + // the host is in the form hostname:port with the port being optional + int portIndex = method.Host.IndexOf(':'); + String host; + int port; + if (portIndex == -1) + { + host = method.Host; + port = DEFAULT_REDIRECT_PORT; + } + else + { + host = method.Host.Substring(0, portIndex); + port = Int32.Parse(method.Host.Substring(portIndex + 1)); + } + evt.ProtocolSession.Failover(host, port);*/ + } + } +} + + diff --git a/qpid/dotnet/Qpid.Client/Client/Handler/ConnectionSecureMethodHandler.cs b/qpid/dotnet/Qpid.Client/Client/Handler/ConnectionSecureMethodHandler.cs new file mode 100644 index 0000000000..9333d4d0a6 --- /dev/null +++ b/qpid/dotnet/Qpid.Client/Client/Handler/ConnectionSecureMethodHandler.cs @@ -0,0 +1,60 @@ +/* + * + * 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. + * + */ +using Apache.Qpid.Client.Protocol; +using Apache.Qpid.Client.State; +using Apache.Qpid.Framing; +using Apache.Qpid.Sasl; + +namespace Apache.Qpid.Client.Handler +{ + public class ConnectionSecureMethodHandler : IStateAwareMethodListener + { + public void MethodReceived(AMQStateManager stateManager, AMQMethodEvent evt) + { + ISaslClient saslClient = evt.ProtocolSession.SaslClient; + if ( saslClient == null ) + { + throw new AMQException("No SASL client set up - cannot proceed with authentication"); + } + + + ConnectionSecureBody body = (ConnectionSecureBody)evt.Method; + + try + { + // Evaluate server challenge + byte[] response = saslClient.EvaluateChallenge(body.Challenge); + // 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 responseFrame = ConnectionSecureOkBody.CreateAMQFrame( + evt.ChannelId, response); + evt.ProtocolSession.WriteFrame(responseFrame); + } catch ( SaslException e ) + { + throw new AMQException("Error processing SASL challenge: " + e, e); + } + } + } +} + + + diff --git a/qpid/dotnet/Qpid.Client/Client/Handler/ConnectionStartMethodHandler.cs b/qpid/dotnet/Qpid.Client/Client/Handler/ConnectionStartMethodHandler.cs new file mode 100644 index 0000000000..c54662286b --- /dev/null +++ b/qpid/dotnet/Qpid.Client/Client/Handler/ConnectionStartMethodHandler.cs @@ -0,0 +1,144 @@ +/* + * + * 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. + * + */ +using System; +using System.Collections; +using System.Text; +using log4net; +using Apache.Qpid.Client.Protocol; +using Apache.Qpid.Client.Security; +using Apache.Qpid.Client.State; +using Apache.Qpid.Framing; +using Apache.Qpid.Sasl; + + +namespace Apache.Qpid.Client.Handler +{ + public class ConnectionStartMethodHandler : IStateAwareMethodListener + { + private static readonly ILog _log = LogManager.GetLogger(typeof(ConnectionStartMethodHandler)); + + public void MethodReceived(AMQStateManager stateManager, AMQMethodEvent evt) + { + ConnectionStartBody body = (ConnectionStartBody) evt.Method; + AMQProtocolSession ps = evt.ProtocolSession; + + try + { + if ( body.Mechanisms == null ) + { + throw new AMQException("mechanism not specified in ConnectionStart method frame"); + } + string mechanisms = Encoding.UTF8.GetString(body.Mechanisms); + string selectedMechanism = ChooseMechanism(mechanisms); + if ( selectedMechanism == null ) + { + throw new AMQException("No supported security mechanism found, passed: " + mechanisms); + } + + byte[] saslResponse = DoAuthentication(selectedMechanism, ps); + + if (body.Locales == null) + { + throw new AMQException("Locales is not defined in Connection Start method"); + } + string allLocales = Encoding.ASCII.GetString(body.Locales); + string[] locales = allLocales.Split(' '); + string selectedLocale; + if (locales != null && locales.Length > 0) + { + selectedLocale = locales[0]; + } + else + { + throw new AMQException("No locales sent from server, passed: " + locales); + } + + stateManager.ChangeState(AMQState.CONNECTION_NOT_TUNED); + FieldTable clientProperties = new FieldTable(); + clientProperties["product"] = "Apache.Qpid.NET"; + clientProperties["version"] = "1.0"; + clientProperties["platform"] = GetFullSystemInfo(); + clientProperties["instance"] = ps.ClientID; + AMQFrame frame = ConnectionStartOkBody.CreateAMQFrame( + evt.ChannelId, clientProperties, selectedMechanism, + saslResponse, selectedLocale); + ps.WriteFrame(frame); + } + catch (Exception e) + { + throw new AMQException(_log, "Unable to decode data: " + e, e); + } + } + + private string GetFullSystemInfo() + { + StringBuilder sysInfo = new StringBuilder(); + // check if we're running on mono or .net + Type monoRuntime = Type.GetType("Mono.Runtime"); + if ( monoRuntime != null ) + sysInfo.Append("Mono"); + else + sysInfo.Append(".NET"); + sysInfo.Append(" ").Append(Environment.Version); + sysInfo.Append(", ").Append(Environment.OSVersion); + return sysInfo.ToString(); + } + + private string ChooseMechanism(string mechanisms) + { + return CallbackHandlerRegistry.Instance.ChooseMechanism(mechanisms); + } + + 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); + } + } + + 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; + } + } +} diff --git a/qpid/dotnet/Qpid.Client/Client/Handler/ConnectionTuneMethodHandler.cs b/qpid/dotnet/Qpid.Client/Client/Handler/ConnectionTuneMethodHandler.cs new file mode 100644 index 0000000000..15a1d908b7 --- /dev/null +++ b/qpid/dotnet/Qpid.Client/Client/Handler/ConnectionTuneMethodHandler.cs @@ -0,0 +1,63 @@ +/* + * + * 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. + * + */ +using System; +using log4net; +using Apache.Qpid.Client.Protocol; +using Apache.Qpid.Client.State; +using Apache.Qpid.Framing; + +namespace Apache.Qpid.Client.Handler +{ + public class ConnectionTuneMethodHandler : IStateAwareMethodListener + { + private static readonly ILog _logger = LogManager.GetLogger(typeof(ConnectionTuneMethodHandler)); + + public void MethodReceived(AMQStateManager stateManager, AMQMethodEvent evt) + { + _logger.Debug("ConnectionTune frame received"); + ConnectionTuneBody frame = (ConnectionTuneBody) evt.Method; + AMQProtocolSession session = evt.ProtocolSession; + + ConnectionTuneParameters parameters = session.ConnectionTuneParameters; + if (parameters == null) + { + parameters = new ConnectionTuneParameters(); + } + + _logger.Debug(String.Format("ConnectionTune.heartbeat = {0}.", frame.Heartbeat)); + + parameters.FrameMax = frame.FrameMax; + parameters.Heartbeat = frame.Heartbeat; + session.ConnectionTuneParameters = parameters; + + stateManager.ChangeState(AMQState.CONNECTION_NOT_OPENED); + session.WriteFrame(ConnectionTuneOkBody.CreateAMQFrame( + evt.ChannelId, frame.ChannelMax, frame.FrameMax, frame.Heartbeat)); + session.WriteFrame(ConnectionOpenBody.CreateAMQFrame( + evt.ChannelId, session.AMQConnection.VirtualHost, null, true)); + + if (frame.Heartbeat > 0) + { + evt.ProtocolSession.AMQConnection.StartHeartBeatThread(frame.Heartbeat); + } + } + } +} diff --git a/qpid/dotnet/Qpid.Client/Client/Handler/QueueDeleteOkMethodHandler.cs b/qpid/dotnet/Qpid.Client/Client/Handler/QueueDeleteOkMethodHandler.cs new file mode 100644 index 0000000000..70aa3e1078 --- /dev/null +++ b/qpid/dotnet/Qpid.Client/Client/Handler/QueueDeleteOkMethodHandler.cs @@ -0,0 +1,44 @@ +/* + * + * 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. + * + */ +using log4net; +using Apache.Qpid.Client.Message; +using Apache.Qpid.Client.Protocol; +using Apache.Qpid.Client.State; +using Apache.Qpid.Framing; + +namespace Apache.Qpid.Client.Handler +{ + public class QueueDeleteOkMethodHandler : IStateAwareMethodListener + { + + private static readonly ILog _logger = LogManager.GetLogger(typeof(QueueDeleteOkMethodHandler)); + + public void MethodReceived(AMQStateManager stateManager, AMQMethodEvent evt) + { + QueueDeleteOkBody body = (QueueDeleteOkBody)evt.Method; + if (body != null) + { + _logger.InfoFormat("Received Queue.Delete-Ok message, message count {0}", body.MessageCount); + } + } + + } +} diff --git a/qpid/dotnet/Qpid.Client/Client/Handler/QueuePurgeOkMethodHandler.cs b/qpid/dotnet/Qpid.Client/Client/Handler/QueuePurgeOkMethodHandler.cs new file mode 100644 index 0000000000..22db70575d --- /dev/null +++ b/qpid/dotnet/Qpid.Client/Client/Handler/QueuePurgeOkMethodHandler.cs @@ -0,0 +1,44 @@ +/* + * + * 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. + * + */ +using log4net; +using Apache.Qpid.Client.Message; +using Apache.Qpid.Client.Protocol; +using Apache.Qpid.Client.State; +using Apache.Qpid.Framing; + +namespace Apache.Qpid.Client.Handler +{ + public class QueuePurgeOkMethodHandler : IStateAwareMethodListener + { + + private static readonly ILog _logger = LogManager.GetLogger(typeof(QueuePurgeOkMethodHandler)); + + public void MethodReceived(AMQStateManager stateManager, AMQMethodEvent evt) + { + QueuePurgeOkBody body = (QueuePurgeOkBody)evt.Method; + if (body != null) + { + _logger.InfoFormat("Received Queue.Purge-Ok message, message count {0}", body.MessageCount); + } + } + + } +} |