简体   繁体   中英

Connecting to Service Bus on Windows Server (1.1) using Java and AMQP 1.0

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.

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

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. 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.

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

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)

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. 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)

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

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

We were getting the exact same error and performed all the steps that you mentioned with similar results. We however were connecting to Azure Service Bus in the cloud. It turns out the error message is very misleading, behind the scene authentication never happened. You can validate by providing incorrect password and you will still go through all the steps until producer or consumer need to be created and then you will see the exception that you mentioned.

It turns out the issue was, if we create queue/topics using Azure Management Portal then AMQP client wasn't able to connect properly, we keep getting "Peer...." exception. However if we programatically create queue/topic using Microsoft Proprietary api's , see

http://azure.microsoft.com/en-us/documentation/articles/service-bus-java-how-to-use-queues/

then AMQP client was able to connect and send/receive messages properly.

Although it's not Service Bus on Windows Server but with Azure Service Bus, I am expecting the resolution may be the same. Let me know if it doesn't work for you.

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

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.

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

amqp:unauthorized-access Attempted to perform an unauthorized operation

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. ie username@domainname.com. And you will need to URL encode that as well)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM