博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
记一个OfficeException
阅读量:6172 次
发布时间:2019-06-21

本文共 5135 字,大约阅读时间需要 17 分钟。

  hot3.png

##序 在使用jodconverter进行pdf转换的时候,按默认的配置,请求量一上来就报错"org.jodconverter.office.OfficeException: No office manager available."

##异常

2017-06-27 17:39:03.136  INFO 8 --- [ProcessThread-0] o.j.office.ManagedOfficeProcess          : process forcibly terminated with code 812017-06-27 17:52:55.067  INFO 8 --- [ustom-tomcat-27] o.j.office.ManagedOfficeProcess          : Executing task 'Restart After Timeout'...2017-06-27 17:52:55.067  INFO 8 --- [ProcessThread-0] org.jodconverter.office.OfficeProcess    : Trying to forcibly terminate process: 'host=127.0.0.1,port=2002,tcpNoDelay=1' (pid -2)2017-06-27 17:52:55.069 ERROR 8 --- [ustom-tomcat-27] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.jodconverter.office.OfficeException: task did not complete within timeout] with root causejava.util.concurrent.TimeoutException: null	at java.util.concurrent.FutureTask.get(FutureTask.java:205) ~[na:1.8.0_131]	at org.jodconverter.office.PooledOfficeManager.execute(PooledOfficeManager.java:161) ~[jodconverter-core-4.0.0-RELEASE.jar!/:4.0.0-RELEASE]	at org.jodconverter.office.ProcessPoolOfficeManager.execute(ProcessPoolOfficeManager.java:117) ~[jodconverter-core-4.0.0-RELEASE.jar!/:4.0.0-RELEASE]	at org.jodconverter.OfficeDocumentConverter.convert(OfficeDocumentConverter.java:130) ~[jodconverter-core-4.0.0-RELEASE.jar!/:4.0.0-RELEASE]	at org.jodconverter.OfficeDocumentConverter.convert(OfficeDocumentConverter.java:103) ~[jodconverter-core-4.0.0-RELEASE.jar!/:4.0.0-RELEASE]	at org.jodconverter.OfficeDocumentConverter.convert(OfficeDocumentConverter.java:84) ~[jodconverter-core-4.0.0-RELEASE.jar!/:4.0.0-RELEASE]	2017-06-27 17:52:55.072  INFO 8 --- [ProcessThread-0] o.j.office.ManagedOfficeProcess          : process forcibly terminated with code 812017-06-27 18:05:53.759 ERROR 8 --- [ustom-tomcat-25] c.g.b.pdf.controller.ConvertController   : failed conversion:  [15563b] to pdf; org.jodconverter.office.OfficeException: No office manager available.; input file: file4579207008092030803.2017-06-27 18:05:53.762 ERROR 8 --- [ustom-tomcat-25] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [conversion failed] with root causeorg.jodconverter.office.OfficeException: No office manager available.	at org.jodconverter.office.ProcessPoolOfficeManager.execute(ProcessPoolOfficeManager.java:115) ~[jodconverter-core-4.0.0-RELEASE.jar!/:4.0.0-RELEASE]	at org.jodconverter.OfficeDocumentConverter.convert(OfficeDocumentConverter.java:130) ~[jodconverter-core-4.0.0-RELEASE.jar!/:4.0.0-RELEASE]	at org.jodconverter.OfficeDocumentConverter.convert(OfficeDocumentConverter.java:103) ~[jodconverter-core-4.0.0-RELEASE.jar!/:4.0.0-RELEASE]	at org.jodconverter.OfficeDocumentConverter.convert(OfficeDocumentConverter.java:84) ~[jodconverter-core-4.0.0-RELEASE.jar!/:4.0.0-RELEASE]

##源码 ###参数 jodconverter-core-4.0.0-RELEASE-sources.jar!/org/jodconverter/office/DefaultOfficeManagerBuilder.java

final int numInstances =        connectionProtocol == OfficeConnectionProtocol.PIPE ? pipeNames.length : portNumbers.length;    final UnoUrl[] unoUrls = new UnoUrl[numInstances];    for (int i = 0; i < numInstances; i++) {      unoUrls[i] =          (connectionProtocol == OfficeConnectionProtocol.PIPE)              ? UnoUrlUtils.pipe(pipeNames[i])              : UnoUrlUtils.socket(portNumbers[i]);    }

###构造器

/** Constructs a new instance of the class with the specified settings. */  public ProcessPoolOfficeManager(      final UnoUrl[] unoUrls,      final File officeHome,      final File workingDir,      final ProcessManager processManager,      final String[] runAsArgs,      final File templateProfileDir,      final long retryTimeout,      final long retryInterval,      final boolean killExistingProcess,      final long taskQueueTimeout,      final long taskExecutionTimeout,      final int maxTasksPerProcess) {    this.taskQueueTimeout = taskQueueTimeout;    pool = new ArrayBlockingQueue<>(unoUrls.length);    pooledManagers = new PooledOfficeManager[unoUrls.length];    for (int i = 0; i < unoUrls.length; i++) {      final PooledOfficeManagerSettings settings =          new PooledOfficeManagerSettings(unoUrls[i], officeHome, workingDir, processManager);      settings.setRunAsArgs(runAsArgs);      settings.setTemplateProfileDir(templateProfileDir);      settings.setRetryTimeout(retryTimeout);      settings.setRetryInterval(retryInterval);      settings.setKillExistingProcess(killExistingProcess);      settings.setTaskExecutionTimeout(taskExecutionTimeout);      settings.setMaxTasksPerProcess(maxTasksPerProcess);      pooledManagers[i] = new PooledOfficeManager(settings);    }    logger.debug(        "ProcessManager implementation is '{}'", processManager.getClass().getSimpleName());  }

##解决

jodconverter:  enabled: true  portNumbers: 2002,2003,2004,2005,2006  maxTasksPerProcess: 1000  taskQueueTimeout: 30

通过设置多个port,可以启动多个office 通过设置maxTasksPerProcess,可以增加队列容量

转载于:https://my.oschina.net/go4it/blog/1036972

你可能感兴趣的文章
React Native Cannot read property 'bindings' of null (null)) 解决!
查看>>
同样的神经网络引擎,苹果A11芯片比华为麒麟970牛在哪?
查看>>
ucar-weex
查看>>
vuex 理解与应用
查看>>
ES6(3)-各种类型的扩展(数组、对象)
查看>>
mysql 分组
查看>>
Android JNI入门第三篇——jni头文件分析
查看>>
ubuntu server 10.4下NFS服务的配置
查看>>
nginx+php-FastCGI+mysql性能测试
查看>>
Openstack架构及基本概念理解
查看>>
默认路由
查看>>
CYQ.Data 轻量数据层之路 框架开源系列 索引
查看>>
zabbix(2)使用自带模板完成基本监控
查看>>
安装rrdtool出现的错误
查看>>
木马隐藏地点全搜查
查看>>
Subversion版本控制
查看>>
奇怪的打印纸盘故障
查看>>
hyperledger v1.0.5 区块链运维入门(一)
查看>>
Mybatis-mapper-xml-基础
查看>>
5. GC 调优(基础篇) - GC参考手册
查看>>