Go Back   Developer Program Forum > Sports API > Java

Java Discussions about Java. Java technology's versatility, efficiency, platform portability, and security make it the ideal technology for network computing. From laptops to datacenters, game consoles to scientific supercomputers, cell phones to the Internet, Java is everywhere!

Thread Closed
 
Thread Tools Display Modes
  #1  
Old 03-14-2012, 02:28 PM
birinhos birinhos is offline
Junior Member
 
Join Date: Aug 2010
Location: Porto Portugal
Posts: 25
Send a message via MSN to birinhos
Default "placeBets" in java can only process the maximum of two simultaneous calls. (?)

Hello,

I have several threads making bets. I notice that when the market is live if I have, for example, four (4) threads calling placebets() simultaneous the 4 bets are only processed after 16 seconds. 8s plus 8s.

I was seeing in detail and what happens is the following: it process 2 bets and only after we get the response of this two bets the others seconds two bets are processed.

in the line :

resp = getStub(exch).placeBets(msg).getResult();

in ExchangeAPI.placeBets, if I substitute this line for a delay of 8 seconds (just for debug of the problem) the 4 threads end a the same time(after 8s). But if I use the original placebts line the second two bets only start processing after the two previous bet have the response.

It seams like there is some kind of Semaphore inside getStub(exch) that only allows the maximum of 2 processes accessing placebets call at the same time.

I am using axis2 ... does anyone knows why it only process 2 calls at time ?

Thanks,
Rui

Last edited by birinhos; 03-14-2012 at 02:47 PM
  #2  
Old 03-19-2012, 03:15 PM
MarkL MarkL is offline
BDP Team
 
Join Date: Oct 2008
Posts: 346
Default

Quote:
Originally Posted by birinhos View Post
I am using axis2 ... does anyone knows why it only process 2 calls at time ?
Hi,

Axis2, by default, follows the HTTP spec recommendations to only use 2 connections at once. http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html

And here's some workaround for Axis2:
http://amilachinthaka.blogspot.co.uk...rt-client.html
  #3  
Old 03-28-2012, 04:28 PM
birinhos birinhos is offline
Junior Member
 
Join Date: Aug 2010
Location: Porto Portugal
Posts: 25
Send a message via MSN to birinhos
Default

Quote:
Originally Posted by MarkL View Post
Hi,

Axis2, by default, follows the HTTP spec recommendations to only use 2 connections at once. http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html

And here's some workaround for Axis2:
http://amilachinthaka.blogspot.co.uk...rt-client.html
Thanks once again MarkL
  #4  
Old 05-19-2012, 06:23 PM
birinhos birinhos is offline
Junior Member
 
Join Date: Aug 2010
Location: Porto Portugal
Posts: 25
Send a message via MSN to birinhos
Default

Hello,

I did not implement the work around yet. I was seeing now how simple it would be to do it .. but is not that simple. I dont know exactly where to apply the configurations in the BFGlobalServiceStub.java file ... Even if I find the part of the file to apply it I would not be secure if I wouldn’t have mess up with the global behavior of the API.

It would be possible to have this file online for downloading somewhere with this problem solved ?

If somebody is developing a console in java for betfair, the final user will only be able to put 2 bets at time ... I think this is a big limitation :-)

Best regards,
Rui
  #5  
Old 04-25-2013, 01:09 AM
birinhos. birinhos. is offline
Junior Member
 
Join Date: Aug 2012
Posts: 18
Default

hello,

I have solved this problem doing this :

Code:
public static BFExchangeServiceStub getStub(Exchange exch) throws Exception {
		switch (exch) {

			case UK: 
				// Lazy load the Exchange service stub generated by AXIS.
				if (stub_UK == null) {
					stub_UK = new BFExchangeServiceStub("https://api.betfair.com/exchange/v5/BFExchangeService");
			        
					ServiceContext context2 =stub_UK._getServiceClient().getServiceContext();
					MultiThreadedHttpConnectionManager connManager2 = (MultiThreadedHttpConnectionManager)context2.getProperty(HTTPConstants.MULTITHREAD_HTTP_CONNECTION_MANAGER);
					connManager2 = new MultiThreadedHttpConnectionManager();
					context2.setProperty(HTTPConstants.MULTITHREAD_HTTP_CONNECTION_MANAGER, connManager2);
					connManager2.getParams().setMaxTotalConnections(100);
					connManager2.getParams().setMaxConnectionsPerHost(HostConfiguration.ANY_HOST_CONFIGURATION, 100);
					
					// You may set up the connection parameters of the stub here if necessary
			        // For example: Wait 20 seconds for a response from the API
					stub_UK._getServiceClient().getOptions().setTimeOutInMilliSeconds(20 * 1000); 
					stub_UK._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.MC_ACCEPT_GZIP, "true");
					stub_UK._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.MC_GZIP_RESPONSE, "true");
					
				}
				return stub_UK;
			......
Now I can place has many bets has I want one after another and the API does not block for others requests ...
Thread Closed

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 06:05 PM.


BETFAIR® and the BETFAIR LOGO are registered trade marks of The Sporting Exchange Limited. Data on Betfair website(s) (including pricing data) is protected by © and database rights. It may not be used for any purpose without a licence. © The Sporting Exchange Limited. All rights reserved.