简体   繁体   English

适用于Java的CRM Dynamics Online 2016 Azure SDK接收带有500错误代码的BrokeredMessages

[英]CRM Dynamics Online 2016 Azure SDK for Java receive BrokeredMessages with 500 error code

I have a problem with CRM Dynamics Online 2016 Azure SDK for Java. 我在使用CRM Dynamics Online 2016 Azure SDK for Java时遇到问题。 I can connect to Azure Service Bus, I can see queues and message count in queues, but cannot receive messages. 我可以连接到Azure Service Bus,可以看到队列和队列中的消息计数,但是无法接收消息。 Message Id is null and message body contain 500 error 邮件ID为空,邮件正文包含500个错误

500 The server was unable to process the request; 500服务器无法处理请求; please retry the operation. 请重试该操作。 If the problem persists, please contact your Service Bus administrator and provide the tracking id. 如果问题仍然存在,请联系您的Service Bus管理员并提供跟踪ID。 TrackingId:acf8a543-33c9-486d-b13b-443823e6c394_G9,TimeStamp:4/13/2016 7:26:22 AM. TrackingId:acf8a543-33c9-486d-b13b-443823e6c394_G9,TimeStamp:4/13/2016 7:26:22 AM。 If the problem persists, please contact your Service Bus administrator and provide the tracking id. 如果问题仍然存在,请联系您的Service Bus管理员并提供跟踪ID。 TrackingId:acf8a543-33 TrackingId:acf8a543-33

Is there any working sample on the Internet to solve the problem? 互联网上是否有任何可行的示例可以解决该问题?

Test code: 测试代码:

@Test
public void readAllExistedMessagesFromAllQueue() {
    try {
        ServiceBusContract serviceBusContract = ServiceBusConfiguration.configureWithConnectionString(null, Configuration.load(), ASB_CONNECTION_STRING).create(ServiceBusContract.class);

        ReceiveMessageOptions opts = ReceiveMessageOptions.DEFAULT;
        opts.setReceiveMode(ReceiveMode.PEEK_LOCK);

        ListQueuesResult result = serviceBusContract.listQueues();
        if (result != null && result.getItems().size() > 0) {
            for (QueueInfo queueInfo : result.getItems()) {
                logger.debug("queu: " + queueInfo.getPath() + " MessageCount: " + queueInfo.getMessageCount());

                for (int i = 0; i < result.getItems().size(); i++) {
                    BrokeredMessage message = serviceBusContract.receiveQueueMessage(queueInfo.getPath(),
                            opts).getValue();
                    if (message == null) {
                        continue;
                    }
                    System.out.print("__________________________________________");
                    System.out.println("MessageID: " + message.getMessageId());
                    System.out.print("From queue: ");
                    byte[] b = new byte[200];
                    String s = null;
                    int numRead = message.getBody().read(b);
                    while (-1 != numRead) {
                        s = new String(b);
                        s = s.trim();
                        System.out.print(s);
                        numRead = message.getBody().read(b);
                    }
                    System.out.println();
                }
            }
        }

    } catch (IOException e) {
        logger.error(e);
    } catch (ServiceException e) {
        logger.error(e);
    }
}

Per my experience, according to the source code and javadocs of Service Bus, the ServiceBusContract is a Java interface, that you can't directly create an instance of the interface ServiceBusContract . 根据我的经验,根据Service Bus的源代码javadocsServiceBusContract是一个Java接口,您无法直接创建ServiceBusContract接口的实例。

So please try to use the code below from the section Create a queue of the document "How to use Service Bus queues". 因此,请尝试使用Create a queue文档“如何使用服务总线队列” Create a queue部分中的以下代码。

Configuration config =
        ServiceBusConfiguration.configureWithSASAuthentication(
                "<your-servicebus-namespace>",
                "RootManageSharedAccessKey",
                "<SAS-key-value>",
                ".servicebus.windows.net"
                );

ServiceBusContract serviceBusContract = ServiceBusService.create(config);

Update 更新资料

You can find the SharedAccessKeyName & SharedAccessKey in the connection string via click the button below at the bottom of your service bus page. 通过单击服务总线页面底部下方的按钮,可以在连接字符串中找到SharedAccessKeyNameSharedAccessKey

在此处输入图片说明

Then, show the view below and copy the CONNECTION STRING . 然后,显示下面的视图并复制CONNECTION STRING 在此处输入图片说明

The connection string like this below. 连接字符串如下所示。

Endpoint=sb://<your-servicebus-namespace>.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=<SAS-key-value>

Please copy the correct part of connection string instead of the related part of the code. 请复制连接字符串的正确部分,而不是代码的相关部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用adal java 500内部服务器错误Ms动态CRM - 500 Internal Server error Ms dynamics CRM using adal java 如何通过 Java 连接在 Azure 云上运行的 Dynamics CRM 2016 实例? - How to connect Dynamics CRM 2016 instance running on Azure Cloud through Java? Java Dynamics CRM 2011在线Web服务 - Dynamics CRM 2011 Online WebServices from Java CRM Dynamics和Java集成错误 - CRM Dynamics and Java Integration error 从Java访问MS Dynamics CRM Online(2011)访问的未声明名称空间前缀“ wsx”错误 - Undeclared namespace prefix “wsx” error accessing MS Dynamics CRM Online (2011) access from Java 从JAVA在线调用Microsoft Dynamics CRM 2011 - Calling Microsoft Dynamics CRM 2011 online from JAVA 从 Java 到 Online Federated Dynamics CRM 2013 的 Web 服务身份验证 - Web Service Authentication to Online Federated Dynamics CRM 2013 from Java 如何为MS Dynamics CRM 2011服务生成Java代码 - How to generate Java code for MS Dynamics CRM 2011 Service How to Create Case in Microsoft Dynamics CRM 2016 (Version 8) using webservices or REST API in JAVA or C#? - How to Create Case in Microsoft Dynamics CRM 2016 (Version 8) using webservices or REST API in JAVA or C#? 将 java 连接到 Microsoft Dynamics crm - connecting java to microsoft dynamics crm
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM