将我的Scala SOAP客户端代码更新为最新的 scalaxb (1.2.1)并切换到功能(而不是Eithers)后,我得到ConnectException: Worker has already been shutdown
时制作一个简单的SOAP请求:
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())
}
我是否缺少任何Netty / Dispatch配置步骤?
这是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)
提前感谢任何提示。
答案 0 :(得分:1)
在学习并使用Scala并发更多内容后,我能够回答我自己的问题:
service.listProviders(4)
返回Future
。这里的根本问题是程序在未来完成之前终止。 onComplete
只是注册回调的一种很酷的方式,并且不会阻止任何内容。为了使一个简单的例子(就像这个)工作,我应该阻止程序终止,直到将来完成。有些人喜欢这样:
val futureList = service.listProviders(4)
futureList onComplete {
...
}
Await.ready(futureList, 15 minutes)