web::http::http_request delete_message(const cloud_queue& queue, const cloud_queue_message& message, web::http::uri_builder uri_builder, const std::chrono::seconds& timeout, operation_context context) { uri_builder.append_query(U("popreceipt"), message.pop_receipt()); web::http::http_request request = queue_base_request(web::http::methods::DEL, uri_builder, timeout, context); return request; }
web::http::http_request update_message(const cloud_queue& queue, const cloud_queue_message& message, std::chrono::seconds visibility_timeout, bool update_contents, web::http::uri_builder uri_builder, const std::chrono::seconds& timeout, operation_context context) { uri_builder.append_query(U("popreceipt"), message.pop_receipt()); uri_builder.append_query(U("visibilitytimeout"), visibility_timeout.count()); web::http::http_request request = queue_base_request(web::http::methods::PUT, uri_builder, timeout, context); if (update_contents) { protocol::message_writer writer; std::string content = writer.write(message.content_as_string()); request.set_body(content); } return request; }
web::http::uri generate_queue_message_uri(const web::http::uri& base_uri, const cloud_queue& queue, const cloud_queue_message& message) { if (base_uri.is_empty()) { return web::http::uri(); } web::http::uri_builder builder(base_uri); builder.append_path(queue.name(), /* do_encoding */ true); builder.append_path(U("messages")); builder.append_path(message.id(), /* do_encoding */ true); return builder.to_uri(); }
pplx::task<void> cloud_queue::update_message_async(cloud_queue_message& message, std::chrono::seconds visibility_timeout, bool update_content, queue_request_options& options, operation_context context) { if (message.id().empty()) { throw std::invalid_argument(protocol::error_empty_message_id); } if (message.pop_receipt().empty()) { throw std::invalid_argument(protocol::error_empty_message_pop_receipt); } if (visibility_timeout.count() < 0LL) { throw std::invalid_argument(protocol::error_negative_visibility_timeout); } if (visibility_timeout.count() > 604800LL) { throw std::invalid_argument(protocol::error_large_visibility_timeout); } queue_request_options modified_options = get_modified_options(options); storage_uri uri = protocol::generate_queue_message_uri(service_client(), *this, message); std::shared_ptr<core::storage_command<void>> command = std::make_shared<core::storage_command<void>>(uri); command->set_build_request(std::bind(protocol::update_message, message, visibility_timeout, update_content, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); command->set_authentication_handler(service_client().authentication_handler()); command->set_preprocess_response([&message] (const web::http::http_response& response, const request_result& result, operation_context context) mutable { protocol::preprocess_response_void(response, result, context); message.set_pop_receipt(protocol::parse_pop_receipt(response)); message.set_next_visible_time(protocol::parse_next_visible_time(response)); }); return core::executor<void>::execute_async(command, modified_options, context); }
web::http::http_request update_message(const cloud_queue_message& message, std::chrono::seconds visibility_timeout, bool update_contents, web::http::uri_builder& uri_builder, const std::chrono::seconds& timeout, operation_context context) { uri_builder.append_query(core::make_query_parameter(_XPLATSTR("popreceipt"), message.pop_receipt())); uri_builder.append_query(core::make_query_parameter(_XPLATSTR("visibilitytimeout"), visibility_timeout.count(), /* do_encoding */ false)); web::http::http_request request = queue_base_request(web::http::methods::PUT, uri_builder, timeout, context); if (update_contents) { protocol::message_writer writer; std::string content = writer.write(message); request.set_body(content); } return request; }
web::http::http_request add_message(const cloud_queue& queue, const cloud_queue_message& message, std::chrono::seconds time_to_live, std::chrono::seconds initial_visibility_timeout, web::http::uri_builder uri_builder, const std::chrono::seconds& timeout, operation_context context) { if (time_to_live.count() >= 0LL && time_to_live.count() != 604800LL) { uri_builder.append_query(U("messagettl"), time_to_live.count()); } if (initial_visibility_timeout.count() > 0LL) { uri_builder.append_query(U("visibilitytimeout"), initial_visibility_timeout.count()); } web::http::http_request request = queue_base_request(web::http::methods::POST, uri_builder, timeout, context); protocol::message_writer writer; std::string content = writer.write(message.content_as_string()); request.set_body(content); return request; }
web::http::uri generate_queue_message_uri(const web::http::uri& base_uri, const cloud_queue& queue, const cloud_queue_message& message) { return generate_queue_message_uri(base_uri, queue, message.id()); }