scalaxb: ConnectException: Worker has already been shutdown
After updating my Scala SOAP client code to the most recent scalaxb (1.2.1) and switching to Features (instead of Eithers), I'm getting a ConnectException: Worker has already been shutdown
when making a simple SOAP request:
val service = (new aw.ServicesSOAPBindings with Soap11ClientsAsync with scalaxb.DispatchHttpClientsAsync {}).service
// list providers
service.listProviders(4) onComplete {
case Success(respond) =>
println(s"Respond: code ${respond.ErrorCode}, messsage: ${respond.ErrorMessage}, Providers: ${respond.Providers.size}")
if (!respond.Providers.isEmpty)
listKnownProviders(respond.Providers)
case Failure(failure) => println("Failure I : " + failure.printStackTrace())
}
Am I missing any Netty/Dispatch configuration steps?
Here is the stacktrace:
java.util.concurrent.ExecutionException: java.net.ConnectException: Worker has already been shutdown to https://service.xxxxxxx.com/wsdl/v4/ at com.ning.http.client.providers.netty.NettyResponseFuture.abort(NettyResponseFuture.java:342) at com.ning.http.client.providers.netty.NettyConnectListener.operationComplete(NettyConnectListener.java:107) at org.jboss.netty.channel.DefaultChannelFuture.notifyListener(DefaultChannelFuture.java:427) at org.jboss.netty.channel.DefaultChannelFuture.addListener(DefaultChannelFuture.java:145) at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.doConnect(NettyAsyncHttpProvider.java:1136) at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.execute(NettyAsyncHttpProvider.java:937) at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.nextRequest(NettyAsyncHttpProvider.java:1397) at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.nextRequest(NettyAsyncHttpProvider.java:1393) at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.remotelyClosed(NettyAsyncHttpProvider.java:1514) at com.ning.http.client.providers.netty.NettyConnectListener.operationComplete(NettyConnectListener.java:95) at org.jboss.netty.channel.DefaultChannelFuture.notifyListener(DefaultChannelFuture.java:427) at org.jboss.netty.channel.DefaultChannelFuture.notifyListeners(DefaultChannelFuture.java:418) at org.jboss.netty.channel.DefaultChannelFuture.setFailure(DefaultChannelFuture.java:380) at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$1.operationComplete(NioClientSocketPipelineSink.java:115) at org.jboss.netty.channel.DefaultChannelFuture.notifyListener(DefaultChannelFuture.java:427) at org.jboss.netty.channel.DefaultChannelFuture.notifyListeners(DefaultChannelFuture.java:413) at org.jboss.netty.channel.DefaultChannelFuture.setSuccess(DefaultChannelFuture.java:362) at org.jboss.netty.channel.AbstractChannel$ChannelCloseFuture.setClosed(AbstractChannel.java:355) at org.jboss.netty.channel.AbstractChannel.setClosed(AbstractChannel.java:185) at org.jboss.netty.channel.socket.nio.AbstractNioChannel.setClosed(AbstractNioChannel.java:197) at org.jboss.netty.channel.socket.nio.NioSocketChannel.setClosed(NioSocketChannel.java:84) at org.jboss.netty.channel.socket.nio.AbstractNioWorker.close(AbstractNioWorker.java:356) at org.jboss.netty.channel.socket.nio.NioClientBoss.close(NioClientBoss.java:167) at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:306) at org.jboss.netty.channel.socket.nio.NioClientBoss.run(NioClientBoss.java:42) at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108) at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) at java.lang.Thread.run(Thread.java:695)
Thanks in advance for any hints.
1 ответ
После изучения и игры в параллельном Scala я могу дать ответ на свой вопрос:
service.listProviders(4)
возвращается Future
, Основная проблема заключается в том, что программа завершается до того, как будет завершено будущее. onComplete
это просто классный способ зарегистрировать обратный вызов и ничего не блокировать. Чтобы сделать простой пример (как этот), я должен был блокировать завершение программы до завершения будущего. Некоторым нравится это:
val futureList = service.listProviders(4)
futureList onComplete {
...
}
Await.ready(futureList, 15 minutes)