Skip to content
Browse files

Improve synchronous dialogue helper

  • Loading branch information...
1 parent 20c0b1d commit 0615a7cc7d18898c2111963388d704c638013d0e @sotty sotty committed Mar 30, 2012
View
19 drools-mas-generic-client/src/main/java/org/drools/mas/helpers/SyncDialogueHelper.java
@@ -27,7 +27,8 @@
private Encodings encode = Encodings.XML;
private URL endpointURL;
private QName qname;
- private int maximumWaitTime = 60000;
+ private long maximumWaitTime = 60000;
+ private long minWaitTime = 500;
private int maxRetries = 1;
private static Logger logger = LoggerFactory.getLogger( SyncDialogueHelper.class.getName() );
@@ -52,14 +53,22 @@ public SyncDialogueHelper(String url) {
}
- public int getMaximumWaitTime() {
+ public long getMaximumWaitTime() {
return maximumWaitTime;
}
- public void setMaximumWaitTime( int maximumWaitTime ) {
+ public void setMaximumWaitTime( long maximumWaitTime ) {
this.maximumWaitTime = maximumWaitTime;
}
+ public long getMinWaitTime() {
+ return minWaitTime;
+ }
+
+ public void setMinWaitTime( long minWaitTime ) {
+ this.minWaitTime = minWaitTime;
+ }
+
public int getMaxRetries() {
return maxRetries;
}
@@ -118,7 +127,7 @@ public String invokeRequest( String sender, String receiver, String methodName,
return req.getId();
}
- } while ( numTries++ < maxRetries );
+ } while ( ++numTries < maxRetries );
throw new IllegalStateException(" Request " + methodName + " with args "
+ args + " did not return in time" );
@@ -216,7 +225,7 @@ public String invokeDisconfirm(String sender, String receiver, Object propositio
private List<ACLMessage> waitForAnswers( AsyncDroolsAgentService asyncServicePort, String msgid, int numExpectedMessages, long maxTimeout, String msgRef ) {
List<ACLMessage> answers;
- int waitTime = 100;
+ long waitTime = minWaitTime;
do {
try {
logger.debug( " >>> Waiting for answers (" + waitTime + ") for: Message -> " + msgRef );

0 comments on commit 0615a7c

Please sign in to comment.
Something went wrong with that request. Please try again.