I am publishing the platform event in one salesforce org to another org though HTTP callout. The target org is listening to the event for the first record. i.e. If the source org publish 5 records, the target org is listening the first record.
Here is my logic:
/*Scheduler */ public class SchedulerClass{ //Get all the records from staging table and initiate queueable ID jobID = System.enqueueJob(new QueuableClass(stagingList)); } /*Queueable Class */ public class QueuableClass{ public QueuableClass(stagingList){ this.stagingList = stagingList; } public void execute(QueueableContext context){ Stage_Object stageRec = stagingList.remove(0); doCallout(stageRec); if(stagingList!= null && stagingList.size() >0){ ID jobID = System.enqueueJob(new QueuableClass(stagingList)); } } private void doCallout(stageRec){ HttpRequest request= new HttpRequest(); request.setMethod('POST'); request.setEndpoint('callout:targeOrg/services/data/v58.0/sobjects/eventUpdate__e'); request.setHeader('Content-Type','application/json;charset=UTF-8'); request.setBody(); Http http = new Http(); HTTPResponse response = http.send(request); } } The debug log in the source org is showing that the PE is fired successfully for all the records in the list but the in target org, the debug log for 'Automated User' is showing the first record.
http.send(request);? what trigger/flow are you using for handling published events?