使用Java和AMQP 1.0连接到Windows Server(1.1)上的Service Bus [英] Connecting to Service Bus on Windows Server (1.1) using Java and AMQP 1.0

查看:425
本文介绍了使用Java和AMQP 1.0连接到Windows Server(1.1)上的Service Bus的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要问的问题是这里。 David Ingham在回答此Microsoft文档时给出了答案。 Sentinel已经确认解决方案有效。

The question I am about to ask has been asked here before. An answer has been given by David Ingham reciting this Microsoft Document. A confirmation has been provided by Sentinel that the solution works.

然而,我遇到了同样的问题。我遵循Microsoft文档,但仍然有相同的问题。

Yet, I have the same problem. I follow the Microsoft document to the letter, however, still have the same issue.

存在冗余的风险,问题是当使用Qpid-JMS客户端库时(版本0.22或0.26)连接到Windows服务器上的服务总线(1.1) NOT Azure )并遵循Microsoft的所有指示,包括

At the risk of being redundant, the issue is that when using Qpid-JMS Client libraries(versions 0.22 or 0.26) to connect to the Service Bus (1.1) on Windows Server (NOT Azure) and following all directions from Microsoft which include


  1. 生成RootCA证书并将其应用于Java信任库

  2. 使用Windows登录用户/密码

  3. 使用amqps:// [user]:[pwd] @FQDN / [namespace]连接工厂字符串

  4. 使用[namespace] / [queuename]作为物理队列名称。

  1. Generating RootCA certificate and applying it to the Java truststore
  2. Using your Windows Login user/password
  3. Using the amqps://[user]:[pwd]@FQDN/[namespace] connection factory string
  4. Using the [namespace]/[queuename] as your physical queue name.

上下文查找,连接创建,会话创建都可以正常工作。但是当我需要创建MessageProducer或MessageConsumer时,我会收到错误。

Context lookups, connection creation, session creation all work fine. But when it is time to create a MessageProducer or MessageConsumer I get errors.

对于MessageProducer的创建(无论是针对队列还是主题)我总是得到

For MessageProducer creation (does not matter if it is for a queue or a topic) I always get

Caused by: org.apache.qpid.amqp_1_0.client.Sender$SenderCreationException:
Peer did not create remote endpoint for link, target: testns/testq1
at org.apache.qpid.amqp_1_0.client.Sender.<init>(Sender.java:171)

对于MessageConsumer的创建我得到了

For MessageConsumer creation I get

javax.jms.JMSException
at org.apache.qpid.amqp_1_0.jms.impl.MessageConsumerImpl.createClientReceiver(MessageConsumerImpl.java:164)
at org.apache.qpid.amqp_1_0.jms.impl.MessageConsumerImpl.<init>(MessageConsumerImpl.java:120)

以下是我尝试过的几件事。

Here are several things I have tried.


  1. 我的服务总线安装在Windows 2012 Server上。我的客户端正在从另一个Windows 2012 Server运行。但我也将客户端移动到运行Service Bus但没有解决方案的服务器上。 (所以这不是位置问题)

  2. 当我从证书库中取出证书时,我得到了一个适当的错误。当我插入它时,错误消失了。 (所以这不是证书问题)

  3. 当我故意拼错我的Windows用户名或密码时,我收到身份验证错误。否则错误就会消失。 (所以这不是用户/密码问题)

  4. 似乎我在连接字符串中明确键入端口号5671并不重要。无论哪种情况,连接创建都可以。 (所以它不是连接问题)

  5. 在连接字符串或队列定义中定义命名空间似乎并不重要。它在两种情况下都失败了。

  6. 我已经下载了Qpid-JMS-Client的源代码(0.22)并逐步完成了调试器。在创建连接时正确设置目标(要连接的队列的地址),但在离开同步块后立即将其重置为空,这会导致错误(在MessageProducer的情况下)

  1. My Service Bus is installed on a Windows 2012 Server. My Client is running from another Windows 2012 Server. But I have also moved the client to the server where Service Bus is running with no resolution. (So this is not a location issue)
  2. When I take the cert out of the truststore I get an appropriate error. When I insert it back error goes away. (So this is not a cert issue)
  3. When I intentionally misspell my Windows username or password I get Authentication error. Otherwise error goes away. (So this is not a user/pwd issue)
  4. It seems that it does not matter that I explicitly type the port number 5671 in the connection string. In either case connection creation works fine. (So it is not a connection issue)
  5. Defining the namespace in connection string or in queue definition does not seem to matter. It fails in both cases.
  6. I have downloaded the source code for Qpid-JMS-Client (0.22) and stepped through the debugger. The target (the address of the queue to be connected) is set correctly when connection is created but it gets reset to null right after leaving a synchronized block, which causes the error (In the case of MessageProducer)

我从原始Microsoft文档(由名为Sentinel的用户确认它有效)中遗漏了什么?

What did I miss from the original Microsoft documentation (which is confirmed by the user named Sentinel that it works)?

非常感谢任何帮助。
谢谢你,
-Dogan Atay

Any help would be greatly appreciated. Thank you, -Dogan Atay

推荐答案

更新和答案。
嗯,事实证明我们做的一切都很正确。(几乎)

UPDATE and ANSWER. Well it turned out that we were doing everything right.(almost)

使用服务管理控制台创建服务总线时,我添加了用户名作为Windows用户。在客户端,我在连接字符串中使用相同的用户名和密码。我会毫无问题地通过认证步骤。将创建连接。如果我将密码更改为错误密码,我将收到验证错误。当时我确信安全性不是问题所在。

When creating the service bus using the service management console I had added my username as a Windows user. On the client side I was using the same username and its password in the connection string. I would pass the authetication step without problem. The connection would be created. If I changed my password to a wrong password, I would get authetication error. I was convinced at that time that security is not the issue here.

但是如果使用正确的用户名和密码,我仍然无法创建消费者或生产者。

But with the right username and password I was still not able to create a consumer or producer.

然后,我启用了Qpid JMS包日志记录。日志显示

Then, I enabled the Qpid JMS package logging. The log showed

amqp:未授权访问尝试执行未经授权的操作

amqp:unauthorized-access Attempted to perform an unauthorized operation

为什么会这样?事实证明(通过反复试验)当您在连接字符串中使用您的用户名时,您应该使用服务管理控制台中显示的完全限定条件。即username@domainname.com。并且你还需要URL编码)

Why would that be? It turned out (by trial and error) when you are using your username in the connection string you are supposed to use fully qualified as it appears in the service management console. i.e. username@domainname.com. And you will need to URL encode that as well)

在答案中,Aurvoir说,如果他们以编程方式创建队列,那么事情就会成功。我还没试过这个解决方案。但是我可以看到,如果使用自己的凭据创建自己的队列,并使用连接上的相同凭据将消息放入同一队列,它将如何工作。

Below in the answers, Aurvoir, says if they create the queues programtically things work out. I have not tried this solution. But I can see how it would work if you create your own queue using your own credentials and put messages in the same queue using the same credentials on the connection.

这篇关于使用Java和AMQP 1.0连接到Windows Server(1.1)上的Service Bus的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆