在 Dynamics CRM 插件中使用 RabbitMQ

问题描述 投票:0回答:1

我正试图创建一个概念验证应用程序,以了解我们是否可以在 Dynamics CRM 插件(未使用沙箱)中使用 RabbitMQ。

  • Dynamics CRM(内部)是 1612 版本(8.2.5.4)。
  • RabbitMQ服务器是3.8.1版本,Erlang 22.1。
  • .NET 4.5.2 (Dynamics CRM需要)

我正在使用NuGetPackages for Dynamics 365 SDK核心程序集(8.2.0.2)、Dynamics 365 SDK核心工具(8.2.0.5)和RabbitMQ.Client(5.1.2)以及ILMerge将这些程序集合并为一个DLL。

这是没有插件其他功能的(简化)代码。我使用Rabbit MQ的基本C#.NET示例来启动。

ConnectionFactory factory = new ConnectionFactory() { HostName = "rabbitmq01", UserName = "user", Password = "password", RequestedHeartbeat = 60, Port = 5672 };

using (IConnection connection = factory.CreateConnection())
{
    using (IModel channel = connection.CreateModel())
    {
        channel.QueueDeclare(queue: "hello",
            durable: false,
            exclusive: false,
            autoDelete: false,
            arguments: null);

            string message = "Hello World!";
            var body = Encoding.UTF8.GetBytes(message);

            channel.BasicPublish(exchange: "",
                routingKey: "hello",
                basicProperties: null,
                body: body);
    }
}

插件本身(没有RabbitMQ)工作并被触发,但我在创建ConnectionFactory时得到一个错误。

(粗略翻译)

System.TypeInitializationException: The typeinitializer for "RabbitMQ.Client.Framing.Impl.Connection" caused an exception. ---> System.NullReferenceException: The object reference not set to an instance.
   bei RabbitMQ.Client.Framing.Impl.Connection..cctor()
   --- End of inner exception stack trace  ---
   bei RabbitMQ.Client.Framing.Impl.Connection.DefaultClientProperties()
   bei RabbitMQ.Client.ConnectionFactory..ctor()

我在CRM或RabbitMQ服务器上找不到任何记录(eventlog,applicationlogs),除了上面的消息。

在Dynamics-Server上的cmd-application中使用相同的代码可以工作,但我似乎找不到错误。或者说,是否不可能在插件中使用RabbitMQ(中间没有webservice)?

rabbitmq dynamics-crm microsoft-dynamics
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.