ব্যাচ অনুরোধ পাঠান
সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
প্রতিটি HTTP সংযোগ যা আপনার অ্যাপ্লিকেশন একটি নির্দিষ্ট পরিমাণ ওভারহেড ফলাফল করে। এই লাইব্রেরি ব্যাচিং সমর্থন করে, আপনার অ্যাপ্লিকেশনকে একটি একক HTTP অনুরোধে একাধিক API কল করার অনুমতি দিতে। আপনি যখন ব্যাচিং ব্যবহার করতে চাইতে পারেন এমন পরিস্থিতির উদাহরণ:
- আপনার কাছে অনেক ছোট ছোট অনুরোধ আছে এবং HTTP অনুরোধ ওভারহেড কমিয়ে দিতে চান।
- আপনার অ্যাপ্লিকেশন অফলাইনে থাকাকালীন একজন ব্যবহারকারী ডেটাতে পরিবর্তন করেছেন, তাই আপনার অ্যাপ্লিকেশনটিকে প্রচুর আপডেট এবং মুছে ফেলার মাধ্যমে সার্ভারের সাথে তার স্থানীয় ডেটা সিঙ্ক্রোনাইজ করতে হবে৷
দ্রষ্টব্য : আপনি একটি একক ব্যাচ অনুরোধে 1,000 কলের মধ্যে সীমাবদ্ধ। আপনি যদি এর চেয়ে বেশি কল করতে চান তবে একাধিক ব্যাচের অনুরোধ ব্যবহার করুন।
দ্রষ্টব্য : আপনি একটি ব্যাচ অনুরোধে একটি মিডিয়া আপলোড বস্তু ব্যবহার করতে পারবেন না।
বিস্তারিত
আপনি একটি BatchRequest
অবজেক্ট ইনস্ট্যান্টিয়েট করে ব্যাচ অনুরোধ তৈরি করুন এবং তারপরে আপনি চালানো প্রতিটি অনুরোধের জন্য Queue
পদ্ধতিতে কল করুন। প্রতিটি অনুরোধের সাথে, যখন আপনার আবেদন সেই অনুরোধের প্রতিক্রিয়া পায় তখন কল করার জন্য একটি কলব্যাক পাস করুন। কলব্যাক ফাংশনের আর্গুমেন্ট হল:
- বিষয়বস্তু
- অনুরোধ ব্যর্থ হলে বিষয়বস্তুর প্রতিক্রিয়া, বা
null
। - ত্রুটি
- অনুরোধ সফল হলে ত্রুটি, বা
null
। - সূচক
- স্বতন্ত্র অনুরোধের সূচক।
- বার্তা
- সম্পূর্ণ HTTP বার্তা যা এর সমস্ত শিরোনাম এবং সামগ্রী অন্তর্ভুক্ত করে।
আপনি অনুরোধগুলি যোগ করার পরে, আপনি অনুরোধগুলি করার জন্য ExecuteAsync
পদ্ধতিতে কল করুন। নিম্নলিখিত কোড স্নিপেটে, দুটি API অনুরোধ একটি একক HTTP অনুরোধে ব্যাচ করা হয়, এবং প্রতিটি API অনুরোধ একটি কলব্যাক সরবরাহ করা হয়:
UserCredential credential;
using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read))
{
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
new[] { CalendarService.Scope.Calendar },
"user", CancellationToken.None, new FileDataStore("Calendar.Sample.Store"));
}
// Create the service.
var service = new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Google Calendar API Sample",
});
// Create a batch request.
var request = new BatchRequest(service);
request.Queue<CalendarList>(service.CalendarList.List(),
(content, error, i, message) =>
{
// Put your callback code here.
});
request.Queue<Event>(service.Events.Insert(
new Event
{
Summary = "Learn how to execute a batch request",
Start = new EventDateTime() { DateTime = new DateTime(2014, 1, 1, 10, 0, 0) },
End = new EventDateTime() { DateTime = new DateTime(2014, 1, 1, 12, 0, 0) }
}, "YOUR_CALENDAR_ID_HERE"),
(content, error, i, message) =>
{
// Put your callback code here.
});
// You can add more Queue calls here.
// Execute the batch request, which includes the 2 requests above.
await request.ExecuteAsync();
অন্য কিছু উল্লেখ না করা থাকলে, এই পৃষ্ঠার কন্টেন্ট Creative Commons Attribution 4.0 License-এর অধীনে এবং কোডের নমুনাগুলি Apache 2.0 License-এর অধীনে লাইসেন্স প্রাপ্ত। আরও জানতে, Google Developers সাইট নীতি দেখুন। Java হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-07-24 UTC-তে শেষবার আপডেট করা হয়েছে।
[null,null,["2025-07-24 UTC-তে শেষবার আপডেট করা হয়েছে।"],[[["\u003cp\u003eBatching allows you to combine multiple API calls into a single HTTP request to reduce overhead.\u003c/p\u003e\n"],["\u003cp\u003eThis is especially useful when dealing with many small requests or synchronizing data with numerous updates and deletes.\u003c/p\u003e\n"],["\u003cp\u003eBatch requests are limited to 1,000 calls; for larger volumes, use multiple batch requests.\u003c/p\u003e\n"],["\u003cp\u003eMedia uploads are not supported within batch requests.\u003c/p\u003e\n"],["\u003cp\u003eUtilize the \u003ccode\u003eBatchRequest\u003c/code\u003e object and its \u003ccode\u003eQueue\u003c/code\u003e method to structure and execute your batched API calls.\u003c/p\u003e\n"]]],[],null,["# Send Batch Requests\n\nEach HTTP connection that your application makes results in a certain amount of overhead.\nThis library supports batching,\nto allow your application to put several API calls into a single HTTP request.\nExamples of situations when you might want to use batching:\n\n- You have many small requests to make and would like to minimize HTTP request overhead.\n- A user made changes to data while your application was offline, so your application needs to synchronize its local data with the server by sending a lot of updates and deletes.\n\n\n**Note**: You're limited to 1,000 calls in a single batch request.\nIf you need to make more calls than that, use multiple batch requests.\n\n\n**Note** : You cannot use a\n[media upload](/api-client-library/dotnet/guide/media_upload)\nobject in a batch request.\n\nDetails\n-------\n\n\nYou create batch requests by instantiating a\n[`BatchRequest`](https://googleapis.dev/dotnet/Google.Apis/latest/api/Google.Apis.Requests.BatchRequest.html)\nobject and then calling the `Queue` method for each request you want to execute.\nWith each request, pass in a callback to be called when your application receives\nthe response to that request.\nThe callback function's arguments are:\n\ncontent\n: The content response, or `null` if the request failed.\n\nerror\n: The error, or `null` if the request succeeded.\n\nindex\n: The index of the individual request.\n\nmessage\n: The full HTTP message that includes all its headers and content.\nAfter you've added the requests, you call the `ExecuteAsync` method to make the requests.\n\n\u003cbr /\u003e\n\n\nIn the following code snippet,\ntwo API requests are batched into a single HTTP request,\nand each API request is supplied a callback: \n\n```gdscript\nUserCredential credential;\nusing (var stream = new FileStream(\"client_secrets.json\", FileMode.Open, FileAccess.Read))\n{\n credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(\n GoogleClientSecrets.Load(stream).Secrets,\n new[] { CalendarService.Scope.Calendar },\n \"user\", CancellationToken.None, new FileDataStore(\"Calendar.Sample.Store\"));\n}\n\n// Create the service.\nvar service = new CalendarService(new BaseClientService.Initializer()\n {\n HttpClientInitializer = credential,\n ApplicationName = \"Google Calendar API Sample\",\n });\n\n// Create a batch request.\nvar request = new BatchRequest(service);\nrequest.Queue\u003cCalendarList\u003e(service.CalendarList.List(),\n (content, error, i, message) =\u003e\n {\n // Put your callback code here.\n });\nrequest.Queue\u003cEvent\u003e(service.Events.Insert(\n new Event\n {\n Summary = \"Learn how to execute a batch request\",\n Start = new EventDateTime() { DateTime = new DateTime(2014, 1, 1, 10, 0, 0) },\n End = new EventDateTime() { DateTime = new DateTime(2014, 1, 1, 12, 0, 0) }\n }, \"YOUR_CALENDAR_ID_HERE\"),\n (content, error, i, message) =\u003e\n {\n // Put your callback code here.\n });\n// You can add more Queue calls here.\n\n// Execute the batch request, which includes the 2 requests above.\nawait request.ExecuteAsync();\n```"]]