Skip to content

Commit

Permalink
fix(real time read): added check to assert clinet is still connected …
Browse files Browse the repository at this point in the history
…and reconnect if not when fetching new data

resolves PRODSUP-4052
  • Loading branch information
roehlerw committed May 24, 2023
1 parent 3f13556 commit c9f7947
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions PluginSalesforce/API/Factory/PushTopicConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public void Disconnect()

public async IAsyncEnumerable<string> GetCurrentMessages()
{
if (!_bayeuxClient.Connected) {
Connect();
}

var messages = _listener.GetMessages();

foreach (var message in messages)
Expand Down
8 changes: 4 additions & 4 deletions PluginSalesforce/API/Read/ReadRecordsRealTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public static async Task<int> ReadRecordsRealTimeAsync(RequestHelper client, Rea
? JsonConvert.DeserializeObject<RealTimeState>(request.RealTimeStateJson)
: new RealTimeState();

// build cometd client
var conn = connectionFactory.GetPushTopicConnection(client, @"/topic/" + realTimeSettings.ChannelName);

try
Expand All @@ -61,11 +62,10 @@ public static async Task<int> ReadRecordsRealTimeAsync(RequestHelper client, Rea

using (var db = new LiteDatabase(Path.Join(path, $"{jobId}_RealTimeReadRecords.db")))
{
var realtimeRecordsCollection = db.GetCollection<RealTimeRecord>(CollectionName);

// build cometd client
conn.Connect();


var realtimeRecordsCollection = db.GetCollection<RealTimeRecord>(CollectionName);

// a full init needs to happen
if (jobVersion > realTimeState.JobVersion || shapeVersion > realTimeState.ShapeVersion)
{
Expand Down

0 comments on commit c9f7947

Please sign in to comment.