【问题标题】:Axis2 temp fileAxis2 临时文件
【发布时间】:2012-01-17 12:26:45
【问题描述】:

我使用的是 Axis2 1.6。在每个请求客户端都生成临时文件,从而导致磁盘空间问题。

我可以请人帮我看一些如何解决这个问题的文章吗?

问候, 琥珀色

【问题讨论】:

  • 据我所知,axis2 库不会创建临时文件。您了解这些文件的来源吗?
  • 文件来自被提取使用的 Axis2 模块 (.mar) 文件。

标签: axis2


【解决方案1】:

我在使用 Axis2 1.6.3 时遇到了这个问题。我正在使用Addressing 模块 (org.apache.axis2:addressing:1.6.3:jar:classpath-module)。

我的整个阴影 JAR 都被复制到临时目录中,并且在 Java 进程崩溃时不会被删除,因此磁盘使用量增长未得到控制。

我解决这个问题的方法是手动向 Axis2 注册模块,而不是让它自动注册,因此它会跳过将临时 JAR 写入磁盘。

我使用了 Axis2 的 ModuleDeployer.deploy()DeploymentEngine.addNewModule() 的逻辑。

创建临时文件的旧代码

ConfigurationContext context = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);

MyExampleStub myExampleStub = new MyExampleStub(context, mySoapUri);
myExampleStub._getServiceClient().engageModule("addressing");

不创建临时文件的新代码

ConfigurationContext context = ConfigurationContextFactory.createDefaultConfigurationContext();
AxisConfiguration axisConfiguration = context.getAxisConfiguration();

AxisModule addressing = new AxisModule("addressing");
addressing.setParent(axisConfiguration);
addressing.setModuleClassLoader(getClass().getClassLoader());
InputStream moduleXmlInputStream = getClass().getResourceAsStream("META-INF/module.xml");
new ModuleBuilder(moduleXmlInputStream, addressing, axisConfiguration).populateModule();
DeploymentEngine.addNewModule(addressing, axisConfiguration);

MyExampleStub myExampleStub = new MyExampleStub(context, mySoapUri);
myExampleStub._getServiceClient().engageModule("addressing");

现在我仍然在我的传出请求<Header> 中看到预期的<wsa:To><wsa:MessageID><wsa:Action> 元素,但我的临时目录不包含任何axis2-tmp-6160203768737879650.tmp 目录或axis2-tmp-6160203768737879650.tmp.lck 文件。

【讨论】:

    【解决方案2】:

    这个接缝是 1.7.0 版修复的 bug

    【讨论】:

    • 1.7.0 尚未发布,希望在 1.5.4 上对此进行修复,或者在代码中为此提供任何解决方法,除了删除临时文件夹内容。
    猜你喜欢
    • 2015-08-28
    • 2013-02-02
    • 2010-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-30
    • 1970-01-01
    • 2021-09-16
    相关资源
    最近更新 更多