diff options
| author | Rafael H. Schloming <rhs@apache.org> | 2009-12-26 12:42:57 +0000 |
|---|---|---|
| committer | Rafael H. Schloming <rhs@apache.org> | 2009-12-26 12:42:57 +0000 |
| commit | 248f1fe188fe2307b9dcf2c87a83b653eaa1920c (patch) | |
| tree | d5d0959a70218946ff72e107a6c106e32479a398 /cpp/src/qpid/cluster/RetractClient.cpp | |
| parent | 3c83a0e3ec7cf4dc23e83a340b25f5fc1676f937 (diff) | |
| download | qpid-python-248f1fe188fe2307b9dcf2c87a83b653eaa1920c.tar.gz | |
synchronized with trunk except for ruby dir
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/qpid.rnr@893970 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/cluster/RetractClient.cpp')
| -rw-r--r-- | cpp/src/qpid/cluster/RetractClient.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/cpp/src/qpid/cluster/RetractClient.cpp b/cpp/src/qpid/cluster/RetractClient.cpp new file mode 100644 index 0000000000..7d9f52fc39 --- /dev/null +++ b/cpp/src/qpid/cluster/RetractClient.cpp @@ -0,0 +1,61 @@ +/* + * + * 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. + * + */ +#include "qpid/cluster/RetractClient.h" +#include "qpid/cluster/UpdateClient.h" +#include "qpid/framing/ClusterConnectionRetractOfferBody.h" +#include "qpid/client/ConnectionAccess.h" +#include "qpid/client/ConnectionImpl.h" +#include "qpid/log/Statement.h" + +namespace qpid { +namespace cluster { + +using namespace framing; + +namespace { + +struct AutoClose { + client::Connection& connection; + AutoClose(client::Connection& c) : connection(c) {} + ~AutoClose() { connection.close(); } +}; +} + +RetractClient::RetractClient(const Url& u, const client::ConnectionSettings& cs) + : url(u), connectionSettings(cs) +{} + +RetractClient::~RetractClient() { delete this; } + + +void RetractClient::run() { + try { + client::Connection c = UpdateClient::catchUpConnection(); + c.open(url, connectionSettings); + AutoClose ac(c); + AMQFrame retract((ClusterConnectionRetractOfferBody())); + client::ConnectionAccess::getImpl(c)->handle(retract); + } catch (const std::exception& e) { + QPID_LOG(error, " while retracting retract to " << url << ": " << e.what()); + } +} + +}} // namespace qpid::cluster |
