Author: richard.opalka(a)jboss.com
Date: 2007-12-05 14:57:58 -0500 (Wed, 05 Dec 2007)
New Revision: 5197
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMChannelManagerImpl.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMChannelTask.java
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/wsrm/emulator/EndpointEmulator.java
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/wsrm/reqres/RMAbstractReqResTest.java
Log:
implementing resending functionality - second iteration
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMChannelManagerImpl.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMChannelManagerImpl.java 2007-12-05
18:16:22 UTC (rev 5196)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMChannelManagerImpl.java 2007-12-05
19:57:58 UTC (rev 5197)
@@ -21,6 +21,7 @@
*/
package org.jboss.ws.extensions.wsrm.transport;
+import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
@@ -45,8 +46,8 @@
private static final Logger logger = Logger.getLogger(RMChannelManagerImpl.class);
private static RMChannelManager instance = new RMChannelManagerImpl();
private static final ExecutorService rmChannelPool = Executors.newFixedThreadPool(5,
new RMThreadFactory());
- private static final int countOfAttempts = 10;
- private static final int timeToWait = 2;
+ private static final int countOfAttempts = 100;
+ private static final int timeToWait = 3;
private static final class RMThreadFactory implements ThreadFactory
{
@@ -102,39 +103,49 @@
public final RMMessage send(RMMessage request) throws Throwable
{
- // submit new task to channel
- // if response has no fault - delete saved request and return response to the
client
- // if response has fault - try to detect it's type
-
RMChannelResponse result = null;
long startTime = 0L;
long endTime = 0L;
+ int attemptNumber = 1;
for (int i = 0; i < countOfAttempts; i++)
{
+ logger.debug("Sending RM request - attempt no. " + attemptNumber++);
Future<RMChannelResponse> futureResult = rmChannelPool.submit(new
RMChannelTask(request));
try
{
startTime = System.currentTimeMillis();
result = futureResult.get(timeToWait, TimeUnit.SECONDS);
- endTime = System.currentTimeMillis();
- logger.debug("Response message received in " + (endTime -
startTime) + " miliseconds");
- break;
+ if (result != null)
+ {
+ Throwable t = result.getFault();
+ if (t != null)
+ {
+ logger.warn(result.getFault().getClass().getName(),
result.getFault());
+ Thread.sleep(timeToWait * 1000);
+ }
+ else
+ {
+ endTime = System.currentTimeMillis();
+ logger.debug("Response message received in " + (endTime -
startTime) + " miliseconds");
+ break;
+ }
+ }
}
catch (TimeoutException te)
{
endTime = System.currentTimeMillis();
- logger.warn("Response message not received in " + (endTime -
startTime) + " miliseconds");
+ logger.warn("Timeout - response message not received in " +
(endTime - startTime) + " miliseconds");
}
}
if (result == null)
- throw new RMException("Unable to deliver message with addressing id: "
+ RMTransportHelper.getMessageId(request));
+ throw new RMException("Unable to deliver message with addressing id: "
+ RMTransportHelper.getMessageId(request) + ". Count of attempts to deliver the
message was: " + countOfAttempts);
Throwable fault = result.getFault();
if (fault != null)
{
- throw fault;
+ throw new RMException("Unable to deliver message with addressing id: "
+ RMTransportHelper.getMessageId(request) + ". Count of attempts to deliver the
message was: " + countOfAttempts, fault);
}
else
{
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMChannelTask.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMChannelTask.java 2007-12-05
18:16:22 UTC (rev 5196)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMChannelTask.java 2007-12-05
19:57:58 UTC (rev 5197)
@@ -23,6 +23,7 @@
import static org.jboss.ws.extensions.wsrm.RMConstant.*;
+import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.util.Map;
@@ -112,7 +113,7 @@
{
String msg = retVal.getClass().getName() + ": '" + retVal +
"'";
logger.warn(msg);
- throw new RuntimeException(msg);
+ throw new IOException(msg);
}
rmResponse = (RMMessage)retVal;
}
Modified:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/wsrm/emulator/EndpointEmulator.java
===================================================================
---
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/wsrm/emulator/EndpointEmulator.java 2007-12-05
18:16:22 UTC (rev 5196)
+++
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/wsrm/emulator/EndpointEmulator.java 2007-12-05
19:57:58 UTC (rev 5197)
@@ -58,7 +58,7 @@
private String configFile;
private ServletContext ctx;
private List<View> views;
- private Map<String, Integer> delayedMessages;
+ private Map<String, Integer> delayedMessages = new HashMap<String,
Integer>();
@Override
public void init(ServletConfig config) throws ServletException
Modified:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/wsrm/reqres/RMAbstractReqResTest.java
===================================================================
---
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/wsrm/reqres/RMAbstractReqResTest.java 2007-12-05
18:16:22 UTC (rev 5196)
+++
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/wsrm/reqres/RMAbstractReqResTest.java 2007-12-05
19:57:58 UTC (rev 5197)
@@ -62,7 +62,7 @@
private boolean asyncHandlerCalled;
private ReqResServiceIface proxy;
private static final TimeUnit testTimeUnit = TimeUnit.SECONDS;
- private static final long testWaitPeriod = 180L;
+ private static final long testWaitPeriod = 300L;
private static final Executor testExecutor = new ThreadPoolExecutor(
0, 5, testWaitPeriod, testTimeUnit, new SynchronousQueue<Runnable>()
);
Show replies by date