【问题标题】:WSO2 ESB blocking vfs possible?WSO2 ESB 阻塞 vfs 可能吗?
【发布时间】:2014-02-14 15:28:11
【问题描述】:

我正在构建 WSO2 ESB 4.8.1 来接收传入的二进制消息并使用 VFS 将其存储到磁盘。我可以使用发送调解器将消息存储到文件中,但由于这是非阻塞调解器,其余序列将同时继续。这会导致存储文件需要更多时间的大文件出现问题。

问题:是否可以使用 Callout mediator 或其他阻塞机制存储文件,以便 ESB 在 VFS 完全存储文件后继续处理序列?我试过 callout mediator 但它不支持 vfs 端点 url 例如“vfs:file:///tmp”

感谢任何提示。

【问题讨论】:

    标签: wso2esb


    【解决方案1】:

    通过创建一个自定义类中介来解决这个问题,该中介接收数据并将其流式传输到文件。班级调解员完成工作后,将继续进行排序。

    这里是类中介代码:

    public class FileSaveMediator extends AbstractMediator {
    
        boolean traceOn = false;
        boolean traceOrDebugOn = false;
    
    
        public boolean mediate(MessageContext context) {
    
            traceOn = isTraceOn(context);
            traceOrDebugOn = isTraceOrDebugOn(traceOn);
    
            traceOrDebug(traceOn, "Start : FileSaveMediator");
    
            // Get property "fileuri" from synapse context
            String fileuri = (String)context.getProperty("fileuri");
    
            SOAPBody body = context.getEnvelope().getBody();
    
               OMText binaryNode = (OMText) (body.getFirstElement()).getFirstOMChild();
               DataHandler actualDH;
               actualDH = (DataHandler) binaryNode.getDataHandler();
    
               FileOutputStream fos = null;
               try {
                   fos = new FileOutputStream(fileuri);
                   actualDH.writeTo(fos);          
    
               } catch (Exception e)
               {
                   e.printStackTrace();
               }
    
               // Clear Body after saving file by setting dummy tags.
    
               try {
                body.setFirstChild(AXIOMUtil.stringToOM("<p></p>"));
            } catch (XMLStreamException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } finally {
    
                // Finally make sure that fileoutstream is closed
                if (fos!=null)
                    try {
                        fos.close();
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
            }
    
            traceOrDebug(traceOn, "End : FileSaveMediator");
    
            return true;
    
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-30
      • 1970-01-01
      • 2013-03-24
      • 1970-01-01
      • 1970-01-01
      • 2011-12-13
      相关资源
      最近更新 更多