Skip to content

Commit

Permalink
Add try catch to queue processing logic
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeWalker committed Apr 30, 2021
1 parent 9bf4ddd commit da30ed6
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 63 deletions.
4 changes: 2 additions & 2 deletions cllc-public-app/ClientApp/extra-webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ module.exports = {
options: {
presets: ['@babel/preset-env'],
plugins: ['@babel/plugin-transform-runtime'],
cacheDirectory: false,
cacheCompression: false
cacheDirectory: true,
cacheCompression: true

}

Expand Down
138 changes: 78 additions & 60 deletions one-stop-service/OneStopUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -493,74 +493,92 @@ public async Task CheckForNewLicences(PerformContext hangfireContext)
var item = dynamicsClient.GetLicenceByIdWithChildren(queueItem._adoxioLicenceValue);

string licenceId = item.AdoxioLicencesid;

switch ((OneStopHubStatusChange)queueItem.AdoxioStatuschangedescription)
try
{
case OneStopHubStatusChange.Issued:
case OneStopHubStatusChange.TransferComplete:
if ((OneStopHubStatusChange)queueItem.AdoxioStatuschangedescription ==
OneStopHubStatusChange.TransferComplete)
{
// send a change status to the old licensee
await SendChangeStatusRest(hangfireContext, licenceId,
(OneStopHubStatusChange)queueItem.AdoxioStatuschangedescription, queueItem.AdoxioOnestopmessageitemid);
}
// Do not attempt to send licence records that have no establishment (for example, Marketer Licence records)
if (item.AdoxioEstablishment != null)
{

string programAccountCode = "001";
if (item.AdoxioBusinessprogramaccountreferencenumber != null)
{
programAccountCode = item.AdoxioBusinessprogramaccountreferencenumber;
}

// set the maximum code.
string cacheKey = "_BPAR_" + item.AdoxioLicencesid;
string suffix = programAccountCode.TrimStart('0');
if (int.TryParse(suffix, out int newNumber))
{
newNumber += 10; // 10 tries.
}
else

switch ((OneStopHubStatusChange) queueItem.AdoxioStatuschangedescription)
{
case OneStopHubStatusChange.Issued:
case OneStopHubStatusChange.TransferComplete:
if ((OneStopHubStatusChange) queueItem.AdoxioStatuschangedescription ==
OneStopHubStatusChange.TransferComplete)
{
newNumber = 10;
// send a change status to the old licensee
await SendChangeStatusRest(hangfireContext, licenceId,
(OneStopHubStatusChange) queueItem.AdoxioStatuschangedescription,
queueItem.AdoxioOnestopmessageitemid);
}
_cache.Set(cacheKey, newNumber);

if (hangfireContext != null)
// Do not attempt to send licence records that have no establishment (for example, Marketer Licence records)
if (item.AdoxioEstablishment != null)
{
hangfireContext.WriteLine($"SET key {cacheKey} to {newNumber}");

string programAccountCode = "001";
if (item.AdoxioBusinessprogramaccountreferencenumber != null)
{
programAccountCode = item.AdoxioBusinessprogramaccountreferencenumber;
}

// set the maximum code.
string cacheKey = "_BPAR_" + item.AdoxioLicencesid;
string suffix = programAccountCode.TrimStart('0');
if (int.TryParse(suffix, out int newNumber))
{
newNumber += 10; // 10 tries.
}
else
{
newNumber = 10;
}

_cache.Set(cacheKey, newNumber);

if (hangfireContext != null)
{
hangfireContext.WriteLine($"SET key {cacheKey} to {newNumber}");
}

await SendProgramAccountRequestREST(hangfireContext, licenceId, suffix,
queueItem.AdoxioOnestopmessageitemid);

}
await SendProgramAccountRequestREST(hangfireContext, licenceId, suffix, queueItem.AdoxioOnestopmessageitemid);

}

break;
case OneStopHubStatusChange.Cancelled:
case OneStopHubStatusChange.EnteredDormancy:
case OneStopHubStatusChange.DormancyEnded:
case OneStopHubStatusChange.Expired:
case OneStopHubStatusChange.CancellationRemoved:
case OneStopHubStatusChange.Renewed:
case OneStopHubStatusChange.Suspended:
case OneStopHubStatusChange.SuspensionEnded:

await SendChangeStatusRest(hangfireContext, licenceId,
(OneStopHubStatusChange)queueItem.AdoxioStatuschangedescription, queueItem.AdoxioOnestopmessageitemid);
break;

case OneStopHubStatusChange.ChangeOfAddress:
await SendChangeAddressRest(hangfireContext, licenceId, queueItem.AdoxioOnestopmessageitemid);
break;
case OneStopHubStatusChange.ChangeOfName:
await SendChangeNameRest(hangfireContext, licenceId, queueItem.AdoxioOnestopmessageitemid, false);
break;
case OneStopHubStatusChange.LicenceDeemedAtTransfer:
await SendChangeNameRest(hangfireContext, licenceId, queueItem.AdoxioOnestopmessageitemid, true);
break;

break;
case OneStopHubStatusChange.Cancelled:
case OneStopHubStatusChange.EnteredDormancy:
case OneStopHubStatusChange.DormancyEnded:
case OneStopHubStatusChange.Expired:
case OneStopHubStatusChange.CancellationRemoved:
case OneStopHubStatusChange.Renewed:
case OneStopHubStatusChange.Suspended:
case OneStopHubStatusChange.SuspensionEnded:

await SendChangeStatusRest(hangfireContext, licenceId,
(OneStopHubStatusChange) queueItem.AdoxioStatuschangedescription,
queueItem.AdoxioOnestopmessageitemid);
break;

case OneStopHubStatusChange.ChangeOfAddress:
await SendChangeAddressRest(hangfireContext, licenceId,
queueItem.AdoxioOnestopmessageitemid);
break;
case OneStopHubStatusChange.ChangeOfName:
await SendChangeNameRest(hangfireContext, licenceId,
queueItem.AdoxioOnestopmessageitemid, false);
break;
case OneStopHubStatusChange.LicenceDeemedAtTransfer:
await SendChangeNameRest(hangfireContext, licenceId,
queueItem.AdoxioOnestopmessageitemid, true);
break;
}

currentItem++;
}
catch (Exception e)
{
Log.Logger.Error(e, "Unexpected Error while processing item.");
}
currentItem++;

if (currentItem > maxLicencesPerInterval)
{
Expand Down
1 change: 0 additions & 1 deletion openshift/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ for component in ${components}; do
popd >/dev/null
done

echo "DONE. SETTINGSFOLDER is ${SETTINGSFOLDER}"

0 comments on commit da30ed6

Please sign in to comment.