2
votes

I'm stuck on how to proceed. I'm trying to use the play 1.2.5 framework with a 3rd party API (Interactive Brokers).

I know someone answered a similar question for Grails Java : How to achieve socket programming functionality with 3rd party API

basically, IB API uses asynchronous communication for requests and replies. i.e. when i call getData(), the API knows to use the callback function dataResults() when it is ready to send them. In order for dataResults() to be callable, the broker object I created still needs to be around to receive the reply. Inside a controller function, if i create a broker object and call getData(), when the request finishes, the broker object obviously also disappears. So I'll never be able to receive the reply.

any ideals on how to do this in Play? any help would be much appreciated.

thanks

1
I'm working on a similar project. I have to create a web application (using play 20) that will fetch data from IB API. But from what I've read IB API requires either TWS or IB Gateway to be running. These executables are the problem as I can't run TWS or IB Gateway on Heroku if I decide to deploy over there. How did you use IB API with Play framework?jsf
sorry can't help. i have tws running. if you figure it out, that would be great info to share.sleepykid

1 Answers

1
votes

Have you considered using the play's built-in support for asynchronous work? http://www.playframework.org/documentation/1.2.5/asynchronous

or if you are considering version 2 of the framework, you may see the differences at: http://playframework.org/documentation/2.0.3/JavaAsync

This may help to solve your issue but of course there is always the statics route if you need to persist the object for a longer period of time.