Hi,
Sorry, this is a duplicate post but the subject got truncated on the last one and I
didn't know how to modify the subject.
I have been trying to manage timeout on a stateless session bean. I have a client that is
running in eclipse outside of jboss calling in to a running jboss server. The server then
makes another call to a local service. I did this double hop because I wanted to test the
timeout behavior for both remote and local calls.
The code looks something like this (a combination of pseudo code and real code used
throughout):
client:
record start time
stub = (MyInterface)JBossUtil.find(IP, "MyInterface/remote");
stub.ping("123);
log elapsed time
server:
public String ping(String value) {
try {
return
((EzRezBusinessServiceInterface) JBossUtil.find("localhost",
"MyInterface/local")).ping2(value);
} catch (Exception e) {
e.printStackTrace();
return "error";
}
}
public String ping2(String value) {
for (int i = 0; i < 10; i++) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
return value;
}
The find routine that both teh client and server use does the following:
Properties properties = new Properties();
//
properties.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
properties.put(javax.naming.Context.URL_PKG_PREFIXES,
"org.jboss.naming:org.jnp.interfaces");
properties.put(javax.naming.Context.PROVIDER_URL, providerUrl);
properties.put("jnp.disableDiscovery", (disableDiscovery == true) ?
"true" : "false");
properties.put("jnp.timeout", "250"); // connection timeout in
milliseconds
properties.put("jnp.sotimeout", "500"); // socket read timeout in
milliseconds
//
return new InitialContext(properties).lookup(interfaceName);
The behavior is that the client always return in 10 seconds, as determined by the time
taken to execute ping2.
I am trying to figure out how to change the timeout so that I can control this. I.e., I
would like to be able to set something so that the client gets a timeout exception if the
call takes more than 5 seconds.
I have tried setting the socket timeout in jboss-service.xml, and the transaction timeout
in jta-service.xml. In the latter case, I can see some logs warning about transaction
timeouts, but the client still takes 10 seconds to execute and seems to simply return the
ping value rather than any timeout indications.
Can you help me know what configurations I should change to control the response time from
a service call?
It would be ideal if I could control on individual calls in an interface. (I.e., ping1
must respond in 5 seconds but ping2 may take 10 seconds), but I won't be greedy right
now. :-)
Thanks,
Harold Williams
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4012469#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...