How to use time delay in MobileFirst adapters - timer

Has anyone tried introducing Delay/timer into the MobileFirst Platform Foundation adapters?
is there anyway to introduce specific amount of delay?
I tried setTimeout() but that doesn't work because of window object will not available in Adapter.js

You can't do this in the adapter logic, but you can do this in the client logic...
Add the required delay implementation in the adapter procedure request's success callback function so that it won't get processed right away, if that's what you really want to do (which would be strange, but...).

Related

PostgreSQL - C function to call webservice

I have installed PostgreSQL 8.4. What I want to do is call a web service through a C function, enabled by an insert/update trigger and pass the NEW values in this webservice. How can I do that, I searched the web and couldn't find an example.
Thanks in advance.
Please don't do this. If you do you will have wonderful questions like how you handle the web service being down. Also you will have to address what happens when your application rolls back. You can't uncall the web service. Also if the connection times out, your procedure will hang for quite a bit of time (retaining all locks etc) while waiting for the response which never comes.
A better approach is to use a queuing solution like pgq or pg_message_queue and queue up the data at trigger time, only to run it against the web service asynchronously.

Consuming a per session WCF service in a WPF application

I'm not really sure how to handle the scenario I have in a good code manner.
The basic of the criteria of my work is this:
A WPF application that consumes a WCF service
The service uses per session instancing
The session starts soon after application is started and should live through the application lifetime (with small exceptions)
Some method calls in a session must precede and be finished before others are called
This means I will have to be able to have one instance of a proxy client throughout the whole application. I will also have to be able to handle async calls, so the client won't hang up, but at the same time ensure they are finished.
My technical understanding go WCF is limiting enough to not know if certain scenarios would work as intended. So I'm going to list my uncertainties:
When does a session start and when does it end. Is it based on the creation of clients or could a separate client instance access the same session if the first would go faulted.
What is the best way to handle exceptions through a WCF service
Is ChannelFactory something I should look at to help me put here.
So what I did in the first iteration to try to solve some of these problems.
I used dependency injection to inject the client instance throughout the classes of my WPF application (I'm using MVVM) to ensure the same instance is everywhere.
I made the service reference using the asynchronous generation method to get the Begin and End versions of all methods to ensure the calls would be async
I used the Coroutine (IResult interface) feature of the Caliburn.Micro framework to ensure one async action is finished before the other begins (have no idea if this is a proper usage or if it is a smart move at all).
Problems I still have is of course how to handle a faulted state of the client. I'm assuming right now that I could reinstance the client and either rescue the session or I could actually just set it up again as it was. I now need to reinstance it everyplace I injected it in with the same new instance.
So I though perhaps it would be best to create a ClientManager class that would wrap the Client. That way I could inject this ClientManager and reinstance inside of him if needed. I guess I should expose him outwards to be able to make method calls but it would be great if I could error handle inside him in somehow. I'm just having a hard time testing my methods and I'm never certain it will work properly in integration because I don't understand all of the inner workings of WCF, coroutines and threading.
Is there anyone out there with more experience then me in these matters that could give me a few pointers or at least tell me how WCF works in these situations ( per session ) and what I'm doing wrong and what right.
WCF supports sessions out-of-box, so I would recommend starting with this MSDN article.
At a very high level, first you set SessionMode=SessionMode.Required in your ServiceContract. And then, set the IsInitiating=True and IsTerminating=True properties on your OperationContract's to mark the start and end of each session.
However, note that WCF limits concurrent sessions by default to 16 to prevent DOS attacks, but you can always up the value. Also, you would have realized that the session is valid as long as its host (IIS / Windows Service / other) is not recycled.
On a related note, I have used WCF Durable Services earlier - which are meant to persist the state of your WCF service in a data-store (default is SQL Server). Ofcourse, there is a performance hit here. Suggest reading further to see if this is the right choice for you.
Hope this helps.

OpenLDAP Bind Timeout

I'm trying to understand how to properly implement a timeout for an OpenLDAP bind request to an LDAP server. From what I've found, there seems to be two ways to do this, with LDAP_OPT_TIMELIMIT and LDAP_OPT_TIMEOUT. My main confusion comes from trying to figure out what the difference is between these.
So far as I understand it, TIMELIMIT is an LDAP standard that sets the time limit for the request/response cycle for any ldap search. And in Windows at least, the default is 120 seconds.
On the other hand TIMEOUT is OpenLDAP specific and used purely client-side for timing out LDAP bind requests. This actually sounds closest to what I want to implement. I know from discussions that using an ldap_set_opt for TIMEOUT was not fully implemented until 2.4. From How can I cause ldap_simple_bind_s to timeout? I know that the work around for earlier versions is to use an asynchronous bind, followed by an ldap_result with the timeout and an ldap_abandon_ext in the case of timeout to drop the request. That makes sense, though looking through the source code for synchronous bind in version 2.4, it doesn't ever seem to handle a timeout in this way. This makes me wonder what the importance of calling ldap_abandon_ext is.
Any answers or insight would be appreciated.
If anyone is looking for OpenLDAP bind timeout yet, you should use method from Aki's answer here.
It is also working in ldapcpp library, when using LDAPAsynConnection for bind. Before bind you must just enable it using getSessionHandle() method.

under what circumstances (if any) can I continue to run "out of date" GWT clients when I update my GAEJ version?

following on from this question:
GWT detect GAE version changes and reload
I would like to further clarify some things.
I have an enterprise app (GWT 2.4 & GAEJ 1.6.4 - using GWT-RPC) that my users typically run all day in their browsers, indeed some don't bother refreshing the browser from day to day. I make new releases on a pretty regular basis, so am trying to streamline the process for minimal impact to my users. - Not all releases concern all users, so I'd like to minimize the number of restarts.
I was hoping it might be possible to do the following. Categorize my releases as follows:
1) releases that will cause an IncompatibleRemoteServiceException to be thrown
and 2) those that don't : i.e. only affect the server, or client but not the RPC interface.
Then I could make lots of changes to the client and server without affecting the interface between the two. As long as I don't make a modification to the RPC interface, presumably I can change server code and or client code and the exception won't be thrown? Right? or will any redeployment of GAE cause an old client to get an IncompatibleRemoteServiceException ?
If I was able to do that I could batch up interface busting changes into fairly infrequent releases and notify my users a restart will be required.
many thanks for any help.
I needed an answer pretty quick so I thought I'd just do some good old fashioned testing to see what's possible. Hopefully this will be useful for others with production systems using GWT-RPC.
Goal is to be able to release updates / fixes without requiring all connected browsers to refresh. Turns out there is quite a lot you can do.
So, after my testing, here's what you can and can't do:
no problem
add a new call to a RemoteService
just update some code on the server e.g. simple bug fix, redeploy
just update some client (GWT) code and redeploy (of course anyone wanting new client functionality will have to refresh browser, but others are unaffected)
limited problems
add a parameter to an existing RemoteService method - this one is interesting, that particular call will throw "IncompatibleRemoteServiceException" (of course) but all others calls to the same Remote Service or other Remote Services (Impl's) are unaffected.
Add a new type (as a parameter) to any method within a RemoteService - this is the most interesting one, and is what led me to do this testing. It will render that whole RemoteService out of date for existing clients with IncompatibleRemoteServiceException. However you can still use other RemoteServices. - I need to do some more testing here to fully understand or perhaps someone else knows more?
so if you know what you're doing you can do quite a lot without having to bother your users with refreshes or release announcements.

Setting Internet Explorer / Windows to use a Socks5 proxy in C#

This is driving me nuts.
I'm making a SSH Tunnelling application, and need to be able to automatically force the system to use HTTP & Socks5 proxies, and have the changes take effect instantly.
HTTP proxies are now taken care of perfectly by the PoshHTTP class , but I can't figure out how to do the same with SOCKS5.
I've already tried forcing the changes in the registry, but they don't take effect instantly and it's just not reliable. In most cases I had to open internet options > lan settings before the settings would take effect, so the user may as well have set the proxy up manually by this point.
Is there a way to do this that I'm missing ? It would be amazing if I could just modify poshHTTP to do this, but I don't have high hopes.
Please help.. I did search like mad for days before posting but I'm running out of ideas and this app needs to be launched ASAP. Thanks!
I'm willing to Pay $50USD for a workable c# solution, that takes effect immediately (Paid via PayPal only)
That really dependes on what kind of socks5 authentication type it's required
have youtried this? http://code.msdn.microsoft.com/windowsdesktop/CSWebBrowserWithProxy-c8535715#content
Other places you could look at are http://www.codeproject.com/Articles/336/SOCKS-Proxy-SSL-Tunnel and http://www.codeproject.com/Articles/5954/C-class-for-connecting-via-a-SOCKS5-Proxy-Server

Resources