I have an activity that schedules an operation to an external API and then has to continue only when this external API finishes, which is indicated by an Event. I currently use a NativActitivy.
my idea would have been to set a bookmark and then register an event handler that would trigger the bookmark. Sadly, it seems I can not resume a bookmark wihtout a context.
What is the best way to do that?
The flow is this:
* Activity starts
* Activity sets bookmark for external API completion.
* Avtiovity calls into external API AND registers event handler
* Activity event handler listens to all completion events until the right one comes (there is a paramter that identifies which request was completed)
* Activity then resumes the bookmark and completes.
Anyone has a code sample for that? I currently use a natie activity but am willing to change.
You must create an extension to do it.
Think about it: While you are waiting for the external event to occur, your workflow is idle. So you need a guy(IWorkflowInstanceExtension) outside your workflow to bring things up again
Examples at:
http://blogs.msdn.com/b/patcarna/archive/2010/01/19/windows-workflow-4-0-workflow-instance-extensions.aspx
http://msmvps.com/blogs/theproblemsolver/archive/2010/01/27/using-wf4-bookmarks-with-iworkflowinstanceextension.aspx
Related
I am trying to identify when a servlet is initilazed (not the init() method called), when container try to load an individual servlet ? Or, any mechanism which keeps track of servlet initialized / destroyed / pending to load.
I am aware of the ServletContextListner, which invoked on application start & shutdown. But, I am looking for kind of listener, which probably trigger on individual servlet load / destroy event.
So, scenario would be like :
/Servlet1
/Servlet2
An listener which trigger on servlet1 load and then for Servlet2.
I guess this is the listener you are looking for .You want to know each time a request comes in, so that you can log it.
javax.servlet.ServletRequestListener . Following are the methods requestInitialized requestDestroyed
New to firebase and trying to understand how things work. I have an android app and plan to use the offline support and I'm trying to figure out whether or not I need to use callbacks. When I make a call like:
productNode.child("price").setValue(product.price)
Does that call to setValue happen synchronously on the main thread and the sync to the cloud happens asynchronously? Or does both execute asynchronously on a background thread?
The Firebase client immediately updates its local copy of the data with the new value. As part of this it fires any local (value, child_*) events that are needed.
Sending of the data to the database happens on a separate thread. If you want to know when this has completed, you can register a CompletionListener.
If the server somehow cannot complete the write operation (typically because the write violates a security rule), the client will fire any additional events that are needed to get the app back into the correct state. So in the case of a value listener it will then fire a second value event with the previous value.
So I'm integrating SignalR and HotTowel, although really I think this is a matter of how to integrate with Durandal itself.
The issue is I have obviously multiple views. Some of these views I want to respond to SignalR messages. The question is how to do this integration considering that SignalR events have to be started before I call SignalR's hub start method.
So take the example I have view1 and view2. I want each to do something when a SignalR message is received and in the context of that view (so let's say update the DOM somehow). It's an SPA obviously so calling the SignalR start method for each view seems like a bad idea, so starting SignalR once at boot sounds like the right plan, but at that point my views may not have been loaded, and still how would I ensure that my events have the right context for the page.
This is based on my understanding that all events for SignalR have to be registered before I call start. Any thoughts clever people of StackOverflow?
Edit to expand on the problem
Part of the website involves uploading files for parsing and processing to import into a database. I have created a view where the file is selected and uploaded (using FineUploader) to a WebApiController. The controller does the basic steps of checking the uploaded file and then starts an async task to actually do the parsing and processing, while immediately returning the basic "Yep that uploaded fine" message.
This causes the list of 'in progress' files to refresh and the file appears with an 'Uploaded' status. As the async task occurs, the file is parsed, then processed against a rules system, and then finally imported into another back end data store. As each of these status changes occur, SignalR sends messages to the client to notify them of these changes, and thus update the status against the filename. In order for this to occur I must attach a function to the event as it received in SignalR. That even needs some kind of reference to my view (actually viewmodel) so it can update the correct value.
As SignalR should be started once with a call to hub.Start(), I am trying to do it during the 'boot' phase. However when my SPA starts, that view has not been loaded, and therefore neither has that viewmodel, and therefore my function that is responsible for initialising SignalR can have no understanding of the view/viewmodel it must update.
Examples I've seen on using SignalR show it being used in one view, but that doesn't really work surely if you need it in multiple views (you can't just keep calling hub.start() can you)?
Sorry, if this still doesn't make sense I'll post some code or something.
If you use
$.connection.myHub.on("myMethod", function (/* ... */) { /* ... */ });
instead of
$.connection.myHub.client.myMethod = function (/* ... */) { /* ... */ };
you can add client-side hub methods after calling $.connection.hub.start();
i would like to create a facebook like one on one chat within an asp.net website, but i cant figure out the mechanism or how it would work.
so far i only have a database table for it designed like this:
id | user1 | user2 | datetime | message
how do i get started, thanks.
I'd consider utilising Signal R for this type of feature - see this guide on implementing a chat feature with signal r - should remove a lot of pain from the development process http://geekswithblogs.net/jeroenb/archive/2011/12/14/signalr-starter-application.aspx
take a look at this:
Simple Chat Application in ASP.NET
The most efficient method to build a chat in asp.net is to use a IHttpAsyncHandler and ajax requests.
Here is a completely working project that implements this, along with ajax.
An async request allows you to delay the response of a request till an external event occurs.
A user makes a call to this handler and waits till someone sends him a message.
Messages are delivered as soon as you send them to a user.
On receiving a message the client makes another request and waits for the next message.
This is a lot more efficient than polling the site to check if messages have arrived.
Using the async handler also ensures that no asp.net threads are wasted waiting while a user waits for messages to come.
This ensures that you chat can scale well even as the number of users of the site goes up.
I'd like to implement some kind of automatic "logging" in my ASP.NET MVC application when a page execution (incl. database calls etc.) takes longer than 3 seconds, and then gather some 'circumstantial evidence', e.g. which action was called, what the parameters were, session information etc. so I can then store that info for review/send it via email and so forth.
How could I do this, preferably on a global level without editing/adding code to each of my many controller actions?
BeginRequest and EndRequest in global.asax is the most basic way, record a start and end time then log from there. Another (more reusable) way may be to create your own custom provider such as demonstrated on MSDN
Start by looking at the global.asax methods that hook into the following events:
-- Application_BeginRequest
-- Application_EndRequest
Record the time in the fist, compare it to current time in the last - if it's too long log it. You can probably get the action etc from the HttpContext.Current.