Session_OnEnd event on Global.asa, concurrency issue - vbscript

In my application,I am using Session_OnEnd event on global.asa file to log the logged out user details to one of my table. For that I am creating an object of one of my VB component from Session_OnEnd event and from there I am inserting into one of my table.
In certain scenarios (Multiple user’s session end happens at a time), we are getting an Unhandled exception while creating above object, since my 1st request is already in processing status.
Anybody of you suggest any good method to overcome this issue?
Dim objClean
Set objClean= Server.CreateObject("Clean.clsClean")
Call objClean.Cleanup(Session, Application)
Set objClean= Nothing
Set objClean= Server.CreateObject("Clean.clsClean") this line is throwing an exception in my case.

Related

Data Loss Prevention policy making OpenMsgStore fail (0x80040312)

When DLP policy is enabled, Redemption fails with the error:
"All business e-mail messages are protected based on a policy set in your organization. There was an error opening the protected e-mail message."
ulLowLevelError: 2147746578 (i.e. 0x80040312)
ulContext: 805701633 (0x30060801)
Is there any way around this?
The error occurs when trying to access the IPMRootFolder property of a Store object:
// A previous version of the code was multi-threaded, it is no longer.
Session = OutlookRpcLoader.new_RDOSession();
Session.Logon(ProfileName: profile, ShowDialog: false, NewSession: true);
var stores = Session.Stores;
var store = stores["{STORE-NAME}"];
var root = store.IPMRootFolder;
The call stack shows that Redemption.IRDOStore.get_IPMRootFolder() threw the exception.
Edit
This is seen when using Redemption version 5.22.0.5498 loaded via the RedemptionLoader class in .NET (registry-free COM).
When testing with Redemption version 5.19.0.5238 from VBScript using CreateObject(), the error doesn't occur.
Could anything have changed between v5.19 and v5.22?
First of all, you need to detect where your code is running - whether it is the foreground or background thread. I'd suggest checking the ThreadID of the process. The foreground thread has the value set to 1. All background threads will values greater than one. If it is a secondary thread you need to create a new Redemption session on a secondary thread where you are going to use and set the MAPIOBJECT property to the object retrieved from the main thread. For example, a raw sketch in VB.NET:
Dim PrimaryRDOSession As New Redemption.RDOSession()
PrimaryRDOSession.Login([...])
Dim WorkerThread as New System.Threading.Thread(AddressOf ThreadProc)
WorkerThread.Start(PrimaryRDOSession.MAPIOBJECT)
Sub ThreadProc(ByVal param as Object)
Dim ThdRDOSession As New Redemption.RDOSession()
ThdRDOSession.MAPIOBJECT = param
' do other stuff
End Sub
Don't use objects created on the main thread if you are on a secondary one. Ensure you are consistent when using the objects.
I believe this was caused by AppLocker rules blocking unsigned binaries. The resolution was to either code-sign the files or add the program to the AppLocker allow-list.

How to stop Spring batch job when error in processor

In my batch job, I have a single step with reading from Database , processing the record and writing back the same record to same table.(ie updating record with processed values or error reason if processing failed).
I am using AsyncItemProcessor for multi thread processing. When I get error in ItemProcessor.process() method, I throw an exception and batch job ends with FAILED status. This failed status is a requirement.
Because, its AsyncItemProcessor, I am unable to access ItemProcessListener.onProcessError().
How do I write the errorMessage to Item Table when there is an error ?
This is a known limitation of using the AsyncItemProcessor which is mentioned in its Javadoc:
While not an exhaustive list, things like StepExecution.filterCount will not
reflect the number of filtered items and
ItemProcessListener.onProcessError(Object, Exception) will not be called.
There is an open issue to update the reference documentation as well.
How do I write the errorMessage to Item Table when there is an error ?
The AsyncItemProcessor submits a FutureTask to the task executor and the only way to know if an exception happened in the task is by unwrapping the future (the exception will be actually wrapped in a java.util.concurrent.ExecutionException when the FutureTask.get is called). Now since the future is unwrapped in the AsyncItemWriter, you can use an ItemWriteListener and react to processing errors. You can find a complete example here.

How can i clear previous error log in Testcomplete

How can i clear previous error log in Testcomplete
as the object is visible after some time. I am using Do until loop to wait and get the object, the error is logged when the object is not visible.
But the object is visible after some time loop is ran. Can i clear the previous error logs, or do i have any other solution for it. Please help...
Thanks
You might want to use the objects Exists property as it does not throw error messages (afaik). A quick draft (untested):
while not Aliases.Device.Mapped.Name.Of.Object.Exists
' Wait
wend

spring entity concurrency control while persisting into database

I am trying to control concurrent access to same object in spring+jpa configuration.
For Example, I have an entity named A. Now multiple processes updating the same object of A.
I am using versioning field but controlling it but here is the issue:
For example 2 processes reads the same entity (A) having version=1.
Now one process update the entity and version gets incremented.
when 2nd process tries to persist the object, Optimistic lock exception would be thrown.
I am using spring services and repository to access the objects.
Could you please help me here?
What's the problem then? That's how it's supposed to work.
You can catch the JpaOptimisticLockingFailureException and then decide what to do from there.
This, for example, would give a validation error message on a Spring MVC form:
...
if(!bindingResult.hasErrors()) {
try {
fooRepository.save(foo);
} catch (JpaOptimisticLockingFailureException exp){
bindingResult.reject("", "This record was modified by another user. Try refreshing the page.");
}
}
...

Why would a WCF OracleDB receive location be triggered by its FK instead of an actual update on its table?

Strange behavior in our receive locations:
RL_REPRESENTATIVE is waiting for a notification from the REPRESENTATIVE table (fields: (PK)id, fname, lname, etc).
RL_CLIENT_REPRESENTATIVE is waiting for a notification from the CLIENT_REPRESENTATIVE table (fields: (FK)id_rep, (FK)id_client).
When both of the locations are active and I commit a change in the CLIENT_REPRESENTATIVE.id_rep table I get a couple of warnings (apparently from RL_REPRESENTATIVE).
The adapter "WCF OracleDB" raised an error message. Details "System.InvalidOperationException: The notification query returned an error. Info="Error". Source="Data". Type="Change".
at Microsoft.Adapters.OracleDB.OracleDBInboundContract.Notification_TryReceive(OracleCommonExecutionHelper executionHelper, Message& wcfMessage)
at Microsoft.Adapters.OracleDB.OracleDBInboundContract.TryReceive(TimeSpan timeout, Message& message, IInboundReply& reply)
at Microsoft.ServiceModel.Channels.Common.Channels.AdapterInputChannel.TryReceive(TimeSpan timeout, Message& message)
at System.ServiceModel.Dispatcher.InputChannelBinder.TryReceive(TimeSpan timeout, RequestContext& requestContext)
at System.ServiceModel.Dispatcher.ErrorHandlingReceiver.TryReceive(TimeSpan timeout, RequestContext& requestContext)".
and
The adapter "WCF OracleDB" raised an error message. Details "The WCF service host at address oracledb://d01-isis:1521/D01ISIS/Dedicated?CallingTable=REPRESENTATIVE has faulted and as a result no more messages can be received on the corresponding receive location. To fix the issue, BizTalk Server will automatically attempt to restart the service host.".
Otherwise the process that is activated by a modification in CLIENT_REPRESENTATIVE takes place with no problems.
(If I update, instead, id_client in CLIENT_REPRESENTATIVE - the error comes from another receive location that subscribes to notifications from the CLIENT table.)
Two further clues:
If I disable RL_REPRESENTATIVE, the warnings won't appear.
If I update both CLIENT_REPRESENTATIVE.id_rep and REPRESENTATIVE.fname and commit both in the same transaction, the warnings won't appear.
Note that there are no triggers in either tables and all my timeouts are set to almost 24 hours.
I suspect that the FK constraint does its job in a way that ends up sending a notification to the port but I never get the actual message that I'm supposed to receive.
Question: Is there a parameter in Oracle that controls this behavior? Have any Biztalk devs ever run into this problem?
It could be:
the order in which things are saved.
a transactional problem, receive locations on seperate transactions, therefore it looks like related items are missing
a locking problem related to the transactional problem
The way to track it down would be to setup profiling on the database, and see exactly which commands are sent in which order.
In the end, the solution was to change a flag in all the receive locations (NotifyOnListenerStart) to "false".
After further development, this solution was not complete - the errant triggering is occurring again - so I'm toggling the check to off until I (or someone else) finds the correct solution.
Edit: This is a side-effect of the FK, changing its value seems to trigger a notification of a change in the table containing the PK (despite there not being any).

Resources