1

在我们开始将 UniObjects.NET 与多线程产品 BizTalk 一起使用之前,我们一直在使用 UniObjects.NET。问题是下面的错误。此错误仅发生在第二个线程(可能还有第三个、第四个等线程)。第一个线程连接并能够很好地从 UniData 检索数据。错误并没有说太多,搜索只返回一个不涉及我们特定问题的结果。有没有人有答案或可以指出我正确的方向?此错误没有打开连接池,我们没有使用连接池,因为这会引发其他错误。

另一件需要注意的是,在调试过程中,我们编写了一些代码,每个线程都会将一些调试信息写入单独的文件。只是将调试信息写入文件的行为使两个线程都能正常工作。我不认为这是连接时间问题(即同时打开 UniSession),因为它仅在同时访问 UniData 文件时失败(假设同时)。

我们正在使用的 UniObjects.NET 的 2.2.3.7377(2010 年 5 月)文件版本的UniObjects.NET 文档。UniData 版本是 7.2。

更新:还尝试使用 UniObjects.NET 版本 2.2.5.7463,它仍然抛出相同的异常。

内部异常:GetX - 文件“MYFILEX”出错。[IBM U2][UODOTNET - UNIRPC][ErrorCode=81004] 从 RPC 请求的参数类型无效

异常类型:异常
来源:MyBusinessObjects
目标站点:System.Collections.Generic.List`1[MyBusinessObjects.XResponse] GetX(System.Collections.Generic.List`1[MyBusinessObjects.Lookup])
以下是标识异常发生位置的堆栈跟踪
  在 MyBusinessObjects.Lookups.GetX(列表`1 查找)
  在 MyBusinessObjects.Integration.GetXResponses(XmlDocument xml,字符串标头,字符串 gheader)
  在 Orchestrations.XProcess.segment1(StopConditions stopOn)
  在 Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s、StopConditions stopCond、Exception& exp)

更新:处理阅读列表的相同错误。

内部异常:[IBM U2][UODOTNET - UNIRPC][ErrorCode=81004] 从 RPC 请求的参数类型无效

异常类型:UniRPCPacketException
资源:
UniRPCPacket 类
目标站点:Byte[] ReadByteArray(Int32)
以下是标识异常发生位置的堆栈跟踪

   在 IBMU2.UODOTNET.UniRPCPMessage.ReadByteArray(Int32 anIndex)
   在 IBMU2.UODOTNET.UniSelectList.ReadList()
   在 IBMU2.UODOTNET.UniSelectList.ReadListAsStringArray()
   在 MyBusinessObjects.Lookups.GetY()
   在 MyBusinessObjects.Integration.GetResponses(XmlDocument xml,字符串标头,字符串 gsheader)
   在 Orchestrations.Process.segment1(StopConditions stopOn)
   在 Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s、StopConditions stopCond、Exception& exp)
4

1 回答 1

0

此问题已解决。现在您可以使用最新的 UO.NET,我希望这个问题得到解决。您还可以使用名为“U2 Toolkit for .NET”的新 Rocket 软件产品。这是一个包含 ADO.NET、UO.NET 和 LINQ to Entity 功能的集成解决方案。要测试多线程,您可以使用以下代码(而不是 BiZtalk Server)。我们使用了 PLINQ 和 U2 Toolkit for .NET。

class Program
{
    static int NumberofThreads = 20;
    const string uniFileName = "PRODUCTS";
    static UniFile file = null;
    static UniSession session = GetUniSession();
    // setup ok/error counters
    static int ok = 0;
    static int error = 0;
    static void Main(string[] args)
    {
        // connect with no locks
        session.BlockingStrategy = UniObjectsTokens.UVT_WAIT_LOCKED;
        session.LockStrategy = UniObjectsTokens.UVT_NO_LOCKS;
        session.ReleaseStrategy = UniObjectsTokens.UVT_WRITE_RELEASE;
        Stopwatch watch = new Stopwatch();
        watch.Start();
        // take only 20 distinct record ids
        List<string> recordIds = new List<string>(RecordIds());
        // run as parallel
        Parallel.ForEach(recordIds, x =>
        {
            try
            {
                // connect to UniData CM file
                var file2 = session.CreateUniFile(uniFileName);
                // read individual record id
                file2.Read(x);
                file2.Close();
                Interlocked.Increment(ref ok);
                Console.WriteLine("rec id:" + x);
            }
            catch (Exception ex)
            {
                Interlocked.Increment(ref error);
                Console.WriteLine("Claim: {0}. Error: {1}", x, ex.Message);
            }
        });
        // set count & setup threads
        int count = 0;
        watch.Stop();
        // write error
        Console.WriteLine("Time: {2}, Count: {3}, OK: {0}, Error: {1}", ok, error, watch.Elapsed, count);
        Console.WriteLine("Press any key to exit.");
        Console.ReadKey();
    }
    static UniSession GetUniSession()
    {
        U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder();
        conn_str.UserID = "user";
        conn_str.Password = "pass";
        conn_str.Server = "localhost";
        conn_str.Database = "XDEMO";
        conn_str.ServerType = "UNIDATA";
        conn_str.AccessMode = "Native";   // FOR UO
        conn_str.RpcServiceType = "udcs"; // FOR UO
        conn_str.Pooling = false;
        string s = conn_str.ToString();
        U2Connection con = new U2Connection();
        con.ConnectionString = s;
        con.Open();
        Console.WriteLine("Connected.........................");
        U2.Data.Client.UO.UniSession us1 = con.UniSession;
        if (file == null)
        {
            file = us1.CreateUniFile(uniFileName);
        }
        return us1;
    }

    public static List<string> RecordIds()
    {
        List<string> lRECIDList = new List<string>();
        UniSelectList sl = session.CreateUniSelectList(2);

        // Select UniFile
        UniFile fl = session.CreateUniFile("PRODUCTS");
        sl.Select(fl);

        bool lLastRecord = sl.LastRecordRead;
        int lIndex = 0;
        while (!lLastRecord)
        {
            string s4 = sl.Next();
            lRECIDList.Add(s4);
            //Console.WriteLine("Record ID:" + s4);
            lLastRecord = sl.LastRecordRead;
            lIndex++;
            if (lIndex >= NumberofThreads)
            {
                break;
            }
        }
        return lRECIDList;

    }
}
于 2012-05-24T22:26:19.087 回答