windows workflow 4.5: Get all idle workflows - workflow-foundation-4

I am using windows workflow 4.5. I have several stages where I break the flow and persist the information. I Have one service with 3 RecieveAndSend activities. I want to be able to start up a lot of workflows and then I want to to be able to query the persistence database to see all idle workflows and the points at which they are blocked. I would then be able to see the workflows get some correlation number and enter it and then resume that workflow.
Thank you!

From experience, using the persistence database other than to persist/re-hydrate workflows is a pain.
To monitor and record what a workflow is doing (or its persistence state) you use Workflow Tracking

Related

Using Firebase as a scheduler

2 years back, I was tasked to quickly build a system for an Health Club that was hit by the Covid pandemic. The system was built within a week & I used what technology I was comfortable with and deployed the system.
The requirements were simple - A member subscribes to a program and he gets regular, timely notifications via FCM. The signup date of the member is rolling, hence it has to follow the n+number of days & time schedule logic.
I built this using simple php with nodejs handling the scheduler. The scheduler runs every minute, checks the mariadb database and runs a loop to send these notifications. This is running correctly at the moment. Having said this, I know this is not the optimal way of doing a solution like this.
I would compare this to the "Autoresponders" we set in any mailing system. Once a person joins, we can schedule Autoresponders - the sending and delivery is managed by the mailing provider.
I wanted to understand if I can use Topics or Realtime / Firebase database to achieve this?
I know it's a super generic question, but if someone can point me in the right direction, I would appreciate it.
Regards,
Mihir.
PS: I am insisting on Firebase because my apps are already integrated with it and would not require much of work to run these changes.

ASP.NET sync long process w/ Requirements

I am working with an e-commerce platform, and I have a task to synchronize with some remote accounting software. The task requires syncing orders, products, inventory...etc. With large amounts of data being synced,the process can take awhile. So, I don't think asp.net application would be the best place to handle this. So, the requirements are:
To be able to schedule this process to run overnight
To be able to manually fire off this process and pass into it some variables like order numbers to export.
Possibly get back status info when fired off manually.
Has to work on .net 3.5
Issues: Can't use a windows service because the site is hosted remotely on a shared service, and the host won't allow a service.
Ideas: I'm having a really hard time finding the best way to handle this outside asp.net that fits all requirements, but I do have access to their FTP and thought possibly a console app that hosts a web-service may work, and I can put Quartz scheduler in global file to fire off service from the site.
Anyway, please offer some thoughts and experiences if you have them on which methods have worked for you.
Can't use a windows service because the site is hosted remotely on a shared service, and the host won't allow a service.
That might be a problem. Does this hosting service provide any other kind of scheduling functionality? If not then you may need to consider changing your hosting services.
You're correct in that ASP.NET is not the tool you'd use for scheduling tasks. A web application is a request/response system (and is very much at the mercy of the hosting process, IIS usually for ASP.NET). So you need some way to schedule the task to execute at regular intervals. Windows Services, Windows Task Scheduler, or some other task scheduling tool.
As for the requirement to be able to invoke the process manually, that's a simple matter of separating the invocation of the logic from the logic itself. Picture the following components:
A module which performs the logic, not bound to any UI or any way of invoking it. Basically a Class Library project (or part of one).
A Windows Service or Console Application which references the Class Library and invokes the logic.
A Web Application which references the Class Library and invokes the logic.
Once you've sorted out how to schedule the Console Application, just schedule it and it's all set. If the process returns some information then the Console Application can also perform any notifications necessary to inform people of that information.
The Web Application can then also have an interface somewhere to invoke the process manually. Since the process "can take a while" then of course you won't want the interface to wait for it to complete. This can result in timeouts and leave the system in an unknown state. Instead you'd want to return the UI to the user indicating that the process has started (or been queued) and that they will be notified with the results when it completes. There are a couple of options for this...
You can use a BackgroundWorker to actually invoke the process. When the process completes, send a notification to the user who invoked it.
You can write a record to a database table to "queue" the process and have something like a Windows Service or scheduled Console Application (same scenario as above) which regularly polls that table for queued tasks, performs the task, and sends the notification. (Of course updating the status in the table along the way so it doesn't perform it twice.)
There are pros and cons either way, it's really up to you how you'd like to proceed. Ultimately you're looking at two main things here:
Separate the logic itself from the scheduling/invocation of the logic.
Utilize a scheduling system to schedule tasks. (If your hosting provider doesn't have one, find one that does.)

SQLDependency solution for Azure table?

I want to use Azure table to store data which is posted by users. And whenever a user post something to some other user it should give out a notification to this user. I have looked into Comet solution with PokeIn to see if there are a way for it. As I'm new to this technique I would like to know the approach before writing the code.
My though to tackle this problem so far is that you can make reverse ajax call to the server. And then at the server it will continuously check the database, with a while-loop, if something has changed. A sleep will be put so it won't overload the server. However this would introduce a lot of unnecessary checks to the database. I have asked a question here earlier, about how to do long polling. And one of the answer suggested to use SqlDependency. However this is MS SQL specific. I want to know how to do it in Azure tables, if it is possible.
Any comments or answer to the general approach would be much appreciated.
I am answering this question based on your question essentially posted first paragraph in which how to use Windows Azure Tables (Without any Database) to write such solution (fellow SO professionals may have different approach). Windows Azure table essentially are key value pair database so there are no such functionality as SQLDependency.
As first approach, with Windows Azure Tables and Windows Azure Queues you can create such solution. When you write something to Azure Tables, you post a message to Azure Queue. In a separate thread you can keep checking for queue state and once there is a message you can take necessary action. The drawback to this approach is that you would need to constantly peeking the queue and depend on how aggressive you are in your polling, it will add transaction cost (about 10,000 for $0.001) but aggressive checking will adds up a lot quickly.
Another solution is to use Windows Azure Table and Service Bus. With Service bus you don't need to use poll instead you can develop a solution in which you will be notified when there is an update to your tables and then rest you can take care.
I have seen both the solution implemented by users and depend on application usability the cost varies so does coding complexity. Before choosing Windows Azure Queue or Service Bus, i would suggest reading the article below to understand the differences in between two to make better decision:
Windows Azure Queues and Windows Azure Service Bus Queues - Compared and Contrasted

How do I implement Quartz.Net to schedule tasks for my MVC3 web app?

I'm building a project to send messages to users. The client wants a way to schedule these messages to be sent out at a certain time, for example, he creates the message at 2am but wants it to be sent out at 10am without his intervention, where do I begin with this sort of thing? I'm using ASP.NET MVC3, any help is appreciated.
Update
Darin has suggested Quartz.net, I've finally gotten around to attempting to set it up. But I'm not really understanding how to implement it with my web app.
I'm assuming I should be able to make an httprequest from my service to an action on my webapp, triggered by quartz. But I'm not sure how to communicate between the webapp and this service, such as sending instructions to the quartz server.
So far, I've created a windows service, set up the installers, and added the Quartz.net server 2010 solution to my service project, am I on the right track?
Using a managed Windows Service with Quartz.NET or a console application which you would schedule with the Windows task scheduler seems like a good approaches to achieve that.
Welp, there are scheduled tasks... either make a localhost request at a specific time, or write an executable/service to be called.
A possible alternative if you can't use scheduled tasks (but may be dependent upon the website being available to the Internet) is to make a remote request-maker program or use a website monitoring service. Have either of those make a request to a particular page/querystring on your site periodically. Then, make the web application perform a particular task (send an email) whenever that resource is requested.
A few free monitoring services are limited to one request every hour or half-hour, or you can pay to have it checked more often. The resource's code could be made to record the message-sending event, (thus making them only get sent once, regardless of how often the request is made)

Looking for guidance on WF4

We have a rather large document routing framework that's currently implemented in SharePoint (with a large set of cumbersome SP workflows), and it's running into the edge of what SP can do easily. It's slated for a rewrite into .NET
I've spent the past week or so reading and watching WF4 discussions and demonstrations to get an idea of WF4, because I think it's the right solution. I'm having difficulty envisioning how the system will be configured, though, so I need guidance on a few points from people with experience:
Let's say I have an approval that has to be made on a document. When the wf starts, it'll decide who should approve, and send that person an email notification. Inside the notification, the user would have an option to load an ASP.NET page to approve or reject. The workflow would then have to be resumed from the send email step. If I'm planning on running this as a WCF WF Service, how do I get back into the correct instance of the paused service? (considering I've configured AppFabric and persistence) I somewhat understand the idea of a correlation handle, but don't think it's meant for this case.
Logging and auditing will be key for this system. I see the AppFabric makes event logs of this data, but I haven't cracked the underlying database--is it simple to use for reporting, or should I create custom logging activities to put around my actions? From experience, which would you suggest?
Thanks for any guidance you can provide. I'm happy to give further examples if necessary.
To send messages to a specific workflow instance you need to set up message correlation between your different Receive activities. In order to do that you need some unique value as part of your message data.
The Appfabric logging works well but if you want to create custom a custom logging solution you don't need to add activities to your workflow. Instead you create a custom TrackingParticipant to do the work for you. How you store the data is then up to you.
Your scenario is very similar to the one I used for the Introduction to Workflow Services Hands On Lab in the Visual Studio 2010 Training Kit. I suggest you take a look at the hands on lab or the Windows Server AppFabric / Workflow Services Demo - Contoso HR sample code.

Resources