From 7371045bd79b57356f163a2b6e55605c7718704a Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Fri, 26 Jul 2013 21:30:48 +0000 Subject: QPID-4941: Remove long deprecated example code for old qpid::client API git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1507463 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/examples/old_api/failover/CMakeLists.txt | 22 -- .../examples/old_api/failover/declare_queues.cpp | 61 ---- .../failover/failover_declare_queues.vcproj | 394 --------------------- .../failover/failover_replaying_sender.vcproj | 394 --------------------- .../failover/failover_resuming_receiver.vcproj | 394 --------------------- .../examples/old_api/failover/replaying_sender.cpp | 97 ----- .../old_api/failover/resuming_receiver.cpp | 127 ------- 7 files changed, 1489 deletions(-) delete mode 100644 qpid/cpp/examples/old_api/failover/CMakeLists.txt delete mode 100644 qpid/cpp/examples/old_api/failover/declare_queues.cpp delete mode 100644 qpid/cpp/examples/old_api/failover/failover_declare_queues.vcproj delete mode 100644 qpid/cpp/examples/old_api/failover/failover_replaying_sender.vcproj delete mode 100644 qpid/cpp/examples/old_api/failover/failover_resuming_receiver.vcproj delete mode 100644 qpid/cpp/examples/old_api/failover/replaying_sender.cpp delete mode 100644 qpid/cpp/examples/old_api/failover/resuming_receiver.cpp (limited to 'qpid/cpp/examples/old_api/failover') diff --git a/qpid/cpp/examples/old_api/failover/CMakeLists.txt b/qpid/cpp/examples/old_api/failover/CMakeLists.txt deleted file mode 100644 index 05db8fad51..0000000000 --- a/qpid/cpp/examples/old_api/failover/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -# -# 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. -# - -add_example(failover declare_queues) -add_example(failover resuming_receiver) -add_example(failover replaying_sender) diff --git a/qpid/cpp/examples/old_api/failover/declare_queues.cpp b/qpid/cpp/examples/old_api/failover/declare_queues.cpp deleted file mode 100644 index a677870c53..0000000000 --- a/qpid/cpp/examples/old_api/failover/declare_queues.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * - * 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 -#include -#include - -#include -#include - -using namespace qpid::client; - -using namespace std; - -int main(int argc, char ** argv) -{ - ConnectionSettings settings; - if (argc > 1) settings.host = argv[1]; - if (argc > 2) settings.port = atoi(argv[2]); - - FailoverManager connection(settings); - try { - bool complete = false; - while (!complete) { - Session session = connection.connect().newSession(); - try { - session.queueDeclare(arg::queue="message_queue"); - complete = true; - } catch (const qpid::TransportFailure&) {} - } - connection.close(); - return 0; - } catch (const std::exception& error) { - std::cout << "Failed:" << error.what() << std::endl; - return 1; - } - -} - - - - - diff --git a/qpid/cpp/examples/old_api/failover/failover_declare_queues.vcproj b/qpid/cpp/examples/old_api/failover/failover_declare_queues.vcproj deleted file mode 100644 index c87c72affd..0000000000 --- a/qpid/cpp/examples/old_api/failover/failover_declare_queues.vcproj +++ /dev/null @@ -1,394 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/qpid/cpp/examples/old_api/failover/failover_replaying_sender.vcproj b/qpid/cpp/examples/old_api/failover/failover_replaying_sender.vcproj deleted file mode 100644 index 6d22fa6770..0000000000 --- a/qpid/cpp/examples/old_api/failover/failover_replaying_sender.vcproj +++ /dev/null @@ -1,394 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/qpid/cpp/examples/old_api/failover/failover_resuming_receiver.vcproj b/qpid/cpp/examples/old_api/failover/failover_resuming_receiver.vcproj deleted file mode 100644 index ba5061e248..0000000000 --- a/qpid/cpp/examples/old_api/failover/failover_resuming_receiver.vcproj +++ /dev/null @@ -1,394 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/qpid/cpp/examples/old_api/failover/replaying_sender.cpp b/qpid/cpp/examples/old_api/failover/replaying_sender.cpp deleted file mode 100644 index 22a7e1ebd3..0000000000 --- a/qpid/cpp/examples/old_api/failover/replaying_sender.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - * - * 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 -#include -#include -#include -#include -#include - -#include -#include - -using namespace qpid; -using namespace qpid::client; -using namespace qpid::framing; - -using namespace std; - -class Sender : public FailoverManager::Command -{ - public: - Sender(const std::string& queue, uint count); - void execute(AsyncSession& session, bool isRetry); - uint getSent(); - private: - MessageReplayTracker sender; - const uint count; - uint sent; - Message message; - -}; - -Sender::Sender(const std::string& queue, uint count_) : sender(10), count(count_), sent(0) -{ - message.getDeliveryProperties().setRoutingKey(queue); -} - -void Sender::execute(AsyncSession& session, bool isRetry) -{ - if (isRetry) sender.replay(session); - else sender.init(session); - while (sent < count) { - stringstream message_data; - message_data << ++sent; - message.setData(message_data.str()); - message.getHeaders().setInt("sn", sent); - sender.send(message); - if (count > 1000 && !(sent % 1000)) { - std::cout << "sent " << sent << " of " << count << std::endl; - } - } - message.setData("That's all, folks!"); - sender.send(message); -} - -uint Sender::getSent() -{ - return sent; -} - -int main(int argc, char ** argv) -{ - ConnectionSettings settings; - if (argc > 1) settings.host = argv[1]; - if (argc > 2) settings.port = atoi(argv[2]); - - FailoverManager connection(settings); - Sender sender("message_queue", argc > 3 ? atoi(argv[3]) : 1000); - try { - connection.execute(sender); - std::cout << "Sent " << sender.getSent() << " messages." << std::endl; - connection.close(); - return 0; - } catch(const std::exception& error) { - std::cout << "Failed: " << error.what() << std::endl; - } - return 1; -} diff --git a/qpid/cpp/examples/old_api/failover/resuming_receiver.cpp b/qpid/cpp/examples/old_api/failover/resuming_receiver.cpp deleted file mode 100644 index d1886ce861..0000000000 --- a/qpid/cpp/examples/old_api/failover/resuming_receiver.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * - * 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 -#include -#include -#include - -#include -#include - - -using namespace qpid; -using namespace qpid::client; -using namespace qpid::framing; - -using namespace std; - - -class Listener : public MessageListener, - public FailoverManager::Command, - public FailoverManager::ReconnectionStrategy -{ - public: - Listener(); - void received(Message& message); - void execute(AsyncSession& session, bool isRetry); - void check(); - void editUrlList(std::vector& urls); - private: - Subscription subscription; - uint count; - uint skipped; - uint lastSn; - bool gaps; -}; - -Listener::Listener() : count(0), skipped(0), lastSn(0), gaps(false) {} - -void Listener::received(Message & message) -{ - if (message.getData() == "That's all, folks!") { - std::cout << "Shutting down listener for " << message.getDestination() - << std::endl; - - std::cout << "Listener received " << count << " messages (" << skipped << " skipped)" << std::endl; - subscription.cancel(); - } else { - uint sn = message.getHeaders().getAsInt("sn"); - if (lastSn < sn) { - if (sn - lastSn > 1) { - std::cout << "Error: gap in sequence between " << lastSn << " and " << sn << std::endl; - gaps = true; - } - lastSn = sn; - ++count; - } else { - ++skipped; - } - } -} - -void Listener::check() -{ - if (gaps) throw Exception("Detected gaps in sequence; messages appear to have been lost."); -} - -void Listener::execute(AsyncSession& session, bool isRetry) -{ - if (isRetry) { - std::cout << "Resuming from " << count << std::endl; - } - SubscriptionManager subs(session); - subscription = subs.subscribe(*this, "message_queue"); - subs.run(); -} - -void Listener::editUrlList(std::vector& urls) -{ - /** - * A more realistic algorithm would be to search through the list - * for prefered hosts and ensure they come first in the list. - */ - if (urls.size() > 1) std::rotate(urls.begin(), urls.begin() + 1, urls.end()); -} - -int main(int argc, char ** argv) -{ - ConnectionSettings settings; - if (argc > 1) settings.host = argv[1]; - if (argc > 2) settings.port = atoi(argv[2]); - - Listener listener; - FailoverManager connection(settings, &listener); - - try { - connection.execute(listener); - connection.close(); - listener.check(); - std::cout << "Completed without error." << std::endl; - return 0; - } catch(const std::exception& error) { - std::cout << "Failure: " << error.what() << std::endl; - } - return 1; -} - - - -- cgit v1.2.1