Alfresco发生奇怪的超时问题

时间:2016-09-07 21:56:32

标签: .net asp.net-mvc-4 alfresco dotcms dotcmis

在我从5个文档中提取任意两个文档后,DotCMIS调用停止响应。

我检查了Alfresco服务器上的日志,并且没有任何与失败的呼叫相关的信息。

我已经调试以识别超时。

//定义已在露天下可用的CMIS可用路径 参数[DotCMIS.SessionParameter.AtomPubUrl] =“https://localhost:8080/alfresco/service/cmis”;

// alfresco门户网站管理员用户名 参数[DotCMIS.SessionParameter.User] =“admin”;

// alfresco门户网站管理员密码 参数[DotCMIS.SessionParameter.Password] =“w4rth0g!”;

//定义会话工厂 SessionFactory factory = SessionFactory.NewInstance();

//使用会话工厂获取默认存储库,在此存储库中我们将执行操作&在此存储库上创建会话 ISession session = factory.GetRepositories(parameters)[0] .CreateSession();

public ContentStream GetContentByDocumentId(string docId)         {             ISession会议;             IObjectId id;             IDocument doc;             IContentStream contentStream;             ContentStream contentStreamModel = new ContentStream();

        try
        {
            session = GetSession();
            id = session.CreateObjectId(docId);
            doc = session.GetObject(id) as IDocument;

            // Content
            contentStream = doc.GetContentStream();

            contentStreamModel.FileName = contentStream.FileName;
            contentStreamModel.Length = contentStream.Length;
            contentStreamModel.MimeType = contentStream.MimeType;
            contentStreamModel.Stream = contentStream.Stream;

            contentStreamModel.Stream.Close();
        }
        catch (Exception ex)
        {
            throw new ApplicationException(ex.Message);
        }
        finally
        {

            session = null;
            id = null;
          //  session.Delete(id, true);
           // session.Clear();
            doc = null;
            contentStream = null;
            //contentStream.Stream.Close();
            //contentStreamModel.Stream.Close();

        }

        return contentStreamModel;
    }

这里我关闭了contenet流。稍后在下面的方法中,我试图遍历

public static void CreateMergedPdf(string targetPdfLocation,IEnumerable docStreams)         {             尝试             {                 using(FileStream stream = new FileStream(targetPdfLocation,FileMode.Create))                 {                     var pdfDoc = new Document(PageSize.A4);                     PdfCopy pdf = new PdfCopy(pdfDoc,stream);                     pdfDoc.Open();

                foreach (var doc in docStreams)
                {
                    pdf.AddDocument(new PdfReader(doc));
                }

                pdfDoc.Close();
            }
        }
        catch (Exception ex)
        {
            throw new ApplicationException(ex.Message);
        }
    }

我已将结束连接移至我在这里消费的方法。

//按orderNo字段的顺序合并文档。             var docStreams = new List();             // var docStreams2 = new List();

        **foreach (string docId in orderedDocIds)
        {
            // Retreive doc from Alfresco.
            var doc = GetContentByDocumentId(docId);
            docStreams.Add(doc.Stream);
            doc.Stream.Close();
        }**

       // docStreams.CopyTo(docStreams2.ToArray());



        // Created a merged pdf and drops in a temp folder.
        FileHelper.CreateMergedPdf(mergedPdfFileLocation, docStreams2);

        return mergedPdfFileLocation;

在这里我将无法访问封闭的流。有什么方法可以重新打开吗?

第三次调用createsession()时,会给出超时错误。

1 个答案:

答案 0 :(得分:1)

您是否已使用并关闭了文档内容流? .Net每个服务器只允许两个并发连接。如果你不关闭流,那么两个连接用完了.Net阻塞直到它们关闭。

另请参阅:https://issues.apache.org/jira/browse/CMIS-559