In this route i wanna execute direct:second endpoint for every interval time after completion of direct:first and direct:first should execute only once that's why i have written from() method with timer repeatcount=1, so could anyone please help me how to resolve this issue
from("timer:repeatcount=1").
.to("direct:first").
to("direct:second").
.setBody(simple("Hello from timer at ${header.firedTime}"))
.to("stream:out");
Use loop and delay to simulate timer work
from("timer:repeatcount=1")
.to("direct:first")
.to("direct:second");
from("direct:second")
.loopDoWhile(true) // never ending loop, check loop component for more control
.setBody(simple("Hello from timer at ${header.firedTime}"))
.to("stream:out")
.delay(1000) // delay 1s, check delay component for more control
.end(); // end loop
Use controlBus to start an inactive route of timer
Related
Is there a way to wait for the useEffect clean-up function to finish ?
useEffect(() => {
return async () => {
dialog({show: true, title: 'Cleaning up the mess. Please wait.'});
// Start a series of long running tasks
await system.killProcess();
await pollUntilProcessDoesNotExist(); // Do not go anywhere until this is done
dialog({show: false, title: undefined });
};
}, [selectedSequenceId]);
My question comes as the result of handling state when BE tasks take long time.
In my example, we have a system that does long time operations. When performing a long time operation it cannot do any other one. Trying to make system do other stuff will come as 409 errors.
Because of this, I would like to know if we can wait until a clean-up function is done. If it is not possible, I would use a transitional route to wait in there until system is free.
More ideas are very welcome.
In general you don't want to block unmounting of UI, which tells me that unmount is the incorrect dependency for the effect that you've described. What is it that causes the unmount? A back button press or something like that? That button should instead kick off the long running task and then do the navigation.
$rootScope.$on('$stateChangeStart', function(event, toState) {
pubnub.unsubscribe({
channel : ["examplechannel1", "examplechannel2"]
});
});
When I navigate to another page, $stateChangeStart detects it and runs pubnub.unsubscribe, a synchronous XHR function (I think). This causes a delay of anywhere from 0.5s to 3s depending on network congestion. How can I eliminate this delay by changing the state immediately and running the unsubscribe function asynchronously?
I always ask too soon before exhausting the Google resource
Answer: https://www.pubnub.com/community/discussion/660/missing-pubnub-message-with-angular-js
Set noleave to true in Pubnub init function
I've got a winform application, which has a database operation. Instead of the default UI blocking effect, I hope to display a special form like
System is processing. please wait
to tell users that the system is working. So basically I'm not looking for a real responsive UI. I still want to block the UI. I've achieved this goal with the backgroundworker component. Hookup the completed callback, then call the RunWorkerAsync in button click event handler, showdialog the processing form. Then in the completed callback, close the processing form.
I wonder if this scenario can be implemented with the new async/await mechanism. I doubt it.
What you call blocking the UI is not blocking the UI. Blocking the UI thread means to stall message processing so that the UI cannot change and react to input. The window usually is ghosted by Windows if this is detected.
You want to show a modal dialog. You can do that with BackgroundWorker or in a more modern way with async and await. For example:
void MyClickHandler(...) {
var form = new MyForm();
Task myAsyncOperation = StartOperationAsync(form);
form.ShowDialog();
await myAsyncOperation;
}
async Task StartOperationAsync(Form formToClose) {
await DoSomething();
formToClose.Close();
}
All of this code is multiplexed on the UI thread. Thread-safety is not a concern.
I have testing code that looks like this:
pageLogin(userName: string, password: string) {
element(by.id('loginUserName')).clear();
element(by.id('loginPassword')).clear();
element(by.id('loginUserName')).sendKeys(userName);
element(by.id('loginPassword')).sendKeys(password);
element(by.id('loginButton')).click();
expect(element(by.id('ngApp')).isPresent()).toBe(true);
}
Can someone explain to me. Do I need to wait for promises to be returned from the first five rows of my function before the expect? Are the lines inside this function executed async?
Protractor uses a method called control flows to let you write tests in a way that looks synchronous. What actually happens is that call of the calls you make inside your function queue up and only start executing when the function returns.
So when your function finishes running, protractor looks at the queue and executes the first item, which is the element(by.id('loginUserName')).clear() statement. When the browser has finished clearing the loginUserName textbox, it signals protractor, and protractor goes to execute the next item in queue.
In your example, element(by.id('ngApp')).isPresent() would be the last item in queue. This calls also returns a promise that will be resolved after this item will have been removed from queue, executed and returned a value.
Jasmine's expect() function was adapted so instead of checking the value synchronously, it notices that you passed in a promise, so it waits for that promise to resolve before checking the expectation.
Finally, once all of the items in the queue have been executed, protractor finishes running the text and moves on to the next one.
Controller in my default route gets executed after I logout. For loginG out I am just calling a server route using $http.post. As the thing is async, execution continues to go to my default route '\' but I don't want controller of my default route to execute until logout is complete. How can I create a link between logout and my controller? I know I can use promise to wait for Logout but this would be only in the function where I am calling logout. How can I wait in my controller for logout to finish?
Will appreciate any help.
Thanks.
Promises let you add a handler to their completion that's chainable:
// inside your controller action causing the log out:
$http.post("/logout").done(function(result){
// here you're logged out, the promise has its value
$location.href = "/"; // change route
});
Note: you can also wait in your router, but I assume from your question you'd like to avoid that.
Note2: I'd extract membership into a service.