I have a State Machine workflow which I am self-hosting within a WorkflowApplication.
When I resume a persisted workflow, I need to be able to extract the value of a given root-level variable (hence it should be in scope) - out of the workflow and into my hosting environment - just to be clear, I need to access the variables from OUTSIDE of the workflow.
I have followed instructions here: HOW to get Context of WorkflowApplication? but I am not receiving any events (upon resumption) that would contain the values of the root-level variables.
I am starting to think that the 'resume' of a workflow does not fire any tracking that allows one to grab root level variables.
Does anybody have a clearer explanation, perhaps a test harness?
Thanks
Related
I'm having a problem on my application. It's an ASP.NET application set up on IIS 10.
Let's say one system page is accessible by 20 users. The page works perfectly (no logical error on coding) every action works and delivers the expected values requested by users.
The problem is, whenever someone requests let's say, the same method as another user at the same time (with different values), the application randomly throws an error to one of these users. We've checked for log errors and all of them are system index out of range errors, which never happened in our QA server.
I randomly thought about testing that exact scenario (adding different values with another user at the same time) and I saw it happen for the first time on the QA server. We've managed to reproduce the error multiple times.
While we don't discard the possibility that this could be another issue, did anyone else experience something like that?
The question is: Can IIS manage the same requests, multiple times at the same time within the same instance without any trouble? Does it run on multiple threads or something like that?
Thanks for taking time for answering this, if you need any info
Stick to your question
Yes IIS can handle very easily (more efficient as well)
As per your application concern without code I can't point out but you may consider few points
Is it happening for just one method or for all. If it happening for just one that means you are trying to use such a code that may used by another user
You are using such a array or list which is null or empty for other user. Like a user has First Name Followed by Last Name But other user don't fill last name and you are using that last name property
May be u r using HttpContext and trying to use same as for different users
May be You are using types which are not Thread safe
So these can be possible cases but without code we can't assume.
About your problem, for multiple requests from different user, iis will create a thread in the application pool for each request. For multiple requests from the same user, it will only run in one thread and affect only the user's instance. Unless the instance or resource is a shared resource and your code does not perform any lock operations.
IIS, including most web servers, use threads to process requests, so multiple requests will be executed in parallel unless you place a lock. A web server usually has a minimum and a maximum number of work programs. These work programs are adjusted according to the CPU or memory of the current hardware. If resources are exhausted, new requests will be queued until new resources are available.
So what you need to do may be to modify the application code to take multi-threading and synchronization into consideration.
I am using NHibernate and ASP.NET/MVC. I use one session per request to handle database operations. For integration testing I am looking for a way to have each test run in an isolated mode that will not change the database and interfere with other tests running in parallel. Something like a transaction that can be rolled back at the end of the test. The main challenge is that each test can make multiple requests. If one request changes data the next request must be able to see these changes etc.
I tried binding the session to the auth cookie to create child sessions for the following requests of a test. But that does not work well, as neither sessions nor transactions are threadsafe in NHibernate. (it results in trying to open multiple DataReaders on the same connection)
I also checked if TransactionScope could be a way, but could not figure out how to use it from multple threads/requests.
What could be a good way to make this happen?
I typically do this by operating on different data.
for example, say I have an integration test which checks a basket total for an e-commerce website.
I would go and create a new user, activate it, add some items to a basket, calculate the total, delete all created data and assert on whatever I need.
so the flow is : create the data you need, operate on it, check it, delete it. This way all the tests can run in parallel and don't interfere with each other, plus the data is always cleaned up.
At the risk of revealing my ignorance I confess that I am confused about the purpose of the lock_id and locked columns in the custom ASP.NET session store example from Microsoft. I get that this schema is designed for consumption in a multi-threaded environment and by many applications, so it makes sense that the PK includes the session identifier as well as the application identifier, allowing applications to re-use session identifiers. What doesn't make sense is the fact that the lock_id does not appear to reference a foreign key constraint.
Since Microsoft didn't include much information about the nature and reasons for the lock_id I am led to assume that it is obvious. Intuitively, it makes sense that it would be useful to indicate whether a session is being handled by, say, a particular application server at a given time, but I don't see how this physically translates into the schema.
Any clarification is appreciated.
FWIW, this answer is equal parts guess and knowledge.
guess:
The database schema is used by a class called SessionStateStoreProvider, or one of its subclasses. In particular, it defines a method called:
GetItemExclusive
Now, I don't know for sure that the parameters it takes in map directly to the columns stored in the schema (and I'm not saying it's aliens, but...).
knowledge:
As for what they are used for, the answer lies in your original question:
I get that this schema is designed for consumption in a multi-threaded
environment and by many applications
Within a single application, there may be multiple threads serving the same session id (consider if you had one asp.net website that saw a single user load two pages simultaneously). The default behavior of .NET Session State is to lock the session id for one of those pages, and assigning a random lock id to it. When that page finished, it would release the lock and the next thread in line would grab it and assign a new lock id. Normally, this would all take place in memory, but if you are persisting the session state model to the database then it makes sense for the lock id to go as well. Support for this behavior is why lock id is required in addition to application id and session id.
As part of the requirements for my project, I need to set up objects so that they begin/expire. This has to be done without a user actually going to the page, as I need to set up notifications for these events. Meaning it has to run without user interaction. I already have a date/time start/end property for each of the objects. What is the best way of doing this?
Publishing/expiring is not a function of watching for the date to occur and doing something; you merely take those dates into account when querying objects from your database. For example, if you were dealing with a blog, in your index view, you would only bring in posts that are "published" based on the appropriate date column.
Now as far as notification goes, that's a case where you'll need some process that checks the date values on a regular basis. You can't (or at least shouldn't) do this with your web application, since web servers are not designed to handle long running tasks.
Revalee is a project you might want to check out. It allows you to schedule tasks to be run in an external process from your web application.
How can I add and remove a TrackingParticipant to a WorkflowServiceHost that is currently executing workflow instances, alternatively change the TrackingProfile of an already existing TrackingParticipant of that host?
The reason I need to do this is that the WorkflowServiceHost is executing workflows on certain events in our system, so it may run several workflows simultaneously. Now I need to enable tracing of these activities during runtime for diagnostic purposes upon a user request, an then disable them again when the user no longer needs them. I can't restart the host because the workflows may be long running. However adding an extension to a WorkflowServiceHost that has already been associated with a workflow throws an exception. And the TrackingProfile of a TrackingParticipant seems to only be changeable at construction(?).
One way would be to simply have my TrackingParticipant have a boolean flag that indicated whether it was enabled or not, and then have it always track everything, but simply doing nothing with them if it was disabled. However, when I tried this the perfomance impact was not acceptable. Having a tracking participant that did absolutely nothing in its Track method made an example workflow consisting of a simple while-loop take 10 times longer to execute.
So is there any way to accomplish what I want here? And if not, why not?