Freigeben über


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://apache.googlesource.com/qpid/+/c8d0fb167d8fc89fcb27823414454675b60a9dc1/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Sender.java

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.

clip_image001

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/

clip_image003

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

Comments

  • Anonymous
    April 10, 2015
    Just tried the sample code at azure.microsoft.com/.../service-bus-java-how-to-use-jms-api-amqp and even with not partitioned queues I'm getting the same exception:javax.jms.JMSException: Peer did not create remote endpoint for link, target: queue2
    at org.apache.qpid.amqp_1_0.jms.impl.MessageProducerImpl.&lt;init&gt;(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 com.microsoft.samples.jms.simple_amqp.SimpleSenderReceiver.&lt;init&gt;(SimpleSenderReceiver.java:48)at com.microsoft.samples.jms.simple_amqp.SimpleSenderReceiver.main(SimpleSenderReceiver.java:83)
    with servicebus.properties:servicebus.properties - sample JNDI configurationjava.naming.factory.initial = org.apache.qpid.jndi.PropertiesFileInitialContextFactoryRegister a ConnectionFactory in JNDI using the form:connectionfactory.[jndi_name] = [ConnectionURL]connectionfactory.SBCF = amqps://SimpleSend:[encodedKeyhere]@[myNamespace].servicebus.windows.netRegister some queues in JNDI using the formqueue.[jndi_name] = [physical_name]topic.[jndi_name] = [physical_name]queue.QUEUE = queue1
  • Anonymous
    April 10, 2015
    And when switching from 'qpid-amqp-1-0-client-jms' version 0.22 to 0.32 the exception on creating the producer changes to:javax.jms.JMSException: java.util.concurrent.TimeoutException
    at org.apache.qpid.amqp_1_0.jms.impl.MessageProducerImpl.&lt;init&gt;(MessageProducerImpl.java:98)at org.apache.qpid.amqp_1_0.jms.impl.SessionImpl.createProducer(SessionImpl.java:390)at org.apache.qpid.amqp_1_0.jms.impl.SessionImpl.createProducer(SessionImpl.java:59)at com.microsoft.samples.jms.simple_amqp.SimpleSenderReceiver.&lt;init&gt;(SimpleSenderReceiver.java:48)at com.microsoft.samples.jms.simple_amqp.SimpleSenderReceiver.main(SimpleSenderReceiver.java:83) 
  • Anonymous
    April 10, 2015
    The comment has been removed
  • Anonymous
    October 20, 2015
    The comment has been removed