Azure Service Bus AMQP Using Java SDK : Peer did not create remote endpoint for link, target: amqp_queue
While setting up an Azure Service Bus AMQP Java project in Eclipse by following the code from How to Use JMS with AMQP 1.0 in Azure with Eclipse I continuously got the following error
javax.jms.JMSException: Peer did not create remote endpoint for link, target: amqp_queue_portal at org.apache.qpid.amqp_1_0.jms.impl.MessageProducerImpl.<init>(MessageProducerImpl.java:77) at org.apache.qpid.amqp_1_0.jms.impl.SessionImpl.createProducer(SessionImpl.java:348) at org.apache.qpid.amqp_1_0.jms.impl.SessionImpl.createProducer(SessionImpl.java:63) at SimpleSenderReceiver.<init>(SimpleSenderReceiver.java:41) at SimpleSenderReceiver.main(SimpleSenderReceiver.java:59)
Caused by: org.apache.qpid.amqp_1_0.client.Sender$SenderCreationException: Peer did not create remote endpoint for link, target: testqueue at org.apache.qpid.amqp_1_0.client.Sender.<init>(Sender.java:171) at org.apache.qpid.amqp_1_0.client.Sender.<init>(Sender.java:104) at org.apache.qpid.amqp_1_0.client.Sender.<init>(Sender.java:97) at org.apache.qpid.amqp_1_0.client.Sender.<init>(Sender.java:83) at org.apache.qpid.amqp_1_0.client.Sender.<init>(Sender.java:69) at org.apache.qpid.amqp_1_0.client.Sender.<init>(Sender.java:63) at org.apache.qpid.amqp_1_0.client.Session.createSender(Session.java:74) at org.apache.qpid.amqp_1_0.client.Session.createSender(Session.java:66) at org.apache.qpid.amqp_1_0.jms.impl.MessageProducerImpl.<init>(MessageProducerImpl.java:72)
The Queue in this case was created from the Azure Management Portal. A search on internet pointed to a lot of hits on stackoverflow but none of them seemed to provide a conclusive answer. So I debugged the Java code and read through some of the AMQP documentation at
https://msdn.microsoft.com/en-us/library/azure/hh780773.aspx
Later I created a Queue using code instead of the Management Portal and with this new queue the Java code worked fine.
connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
var namespaceManager =
NamespaceManager.CreateFromConnectionString(connectionString);
if (!namespaceManager.QueueExists("amqp_queue_code"))
{
namespaceManager.CreateQueue("amqp_queue_code");
}
So I used Service Bus Explorer to find the property difference of the queues amqp_queue_portal & amqp_queue_code. Found that it fails if the Queue is “Partitioned”. AMQP seems to need message ordering. If I create a queue from portal by quick create it will create a ”Partitioned“ queue by default. So when you create a queue from portal Select > Custom Create > Un-check the ”Enable Partitioning“. It should look as below.
I am able to get the messages now using the Java AMQP code published at https://azure.microsoft.com/en-us/documentation/articles/service-bus-java-how-to-use-jms-api-amqp/
Hope this blog helps you overcome the javax.jms.JMSException: Peer did not create remote endpoint for link, target: amqp_queue_portal error.
Angshuman Nayak
Cloud Integration Engineering