通过Java客户端连接的Azure服务总线 [英] Connection Azure service bus via Java client
问题描述
我想的Azure服务总线从Java客户端AMQP协议
连接
I am trying to connect Azure service bus from Java client with AMQP protocol
我按照以下链接指令:
<一href=\"http://azure.microsoft.com/en-us/documentation/articles/service-bus-java-how-to-use-jms-api-amqp/\" rel=\"nofollow\">http://azure.microsoft.com/en-us/documentation/articles/service-bus-java-how-to-use-jms-api-amqp/
I follow the instruction in the following link:
http://azure.microsoft.com/en-us/documentation/articles/service-bus-java-how-to-use-jms-api-amqp/
1)创建的服务总线Azure的门户网站的名称空间 availo 和一个名为队列1
队列
2)服务总线连接信息,我有以下几点:
SharedAccessKeyName = RootManageSharedAccessKey
SharedAccessKey = {}键
1) created service bus in Azure portal with the name space 'availo' and a queue named 'queue1'
2) from service bus connection information I've got the following:
SharedAccessKeyName=RootManageSharedAccessKey
SharedAccessKey={key}
3)创建servicebus.properties文件JNDI查找
3) created "servicebus.properties" file for the JNDI lookup
connectionfactory.SBCF = amqps://RootManageSharedAccessKey:encoded(key)@availo.servicebus.windows.net
queue.QUEUE = queue1
4)下面是在类路径中的所有需要的jar(qpid)我简单的Java主要应用。
4) below is my simple java main application with all the required jars (qpid) in the class path.
public static void main(String[] args) {
try {
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.qpid.amqp_1_0.jms.jndi.PropertiesFileInitialContextFactory");
env.put(Context.PROVIDER_URL,
"C:\\Users\\Assaf-PC\\Documents\\GitHub\\availo\\rest-api\\src\\main\\resources\\servicebus.properties");
Context context = new InitialContext(env);
// Lookup ConnectionFactory and Queue
ConnectionFactory cf = (ConnectionFactory) context.lookup("SBCF");
Destination queue = (Destination) context.lookup("QUEUE");
// Create Connection
Connection connection = cf.createConnection();
// Create sender-side Session and MessageProducer
Session sendSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = sendSession.createProducer(queue);
} catch (Exception e) {
e.getLocalizedMessage();
}
}
当我跑我得到下面的异常在code线方案:
When I run the program I am getting the exception below in the code line:
MessageProducer producer = sendSession.createProducer(queue);
例外:
Exception in thread "main" javax.jms.JMSException: Peer did not create remote endpoint for link, target: queue1
at org.apache.qpid.amqp_1_0.jms.impl.MessageProducerImpl.<init>(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 availo.rest.services.ServiceBus.main(ServiceBus.java:43)
Caused by: org.apache.qpid.amqp_1_0.client.Sender$SenderCreationException: Peer did not create remote endpoint for link, target: queue1
at org.apache.qpid.amqp_1_0.client.Sender.<init>(Sender.java:191)
at org.apache.qpid.amqp_1_0.client.Sender.<init>(Sender.java:119)
at org.apache.qpid.amqp_1_0.client.Sender.<init>(Sender.java:112)
at org.apache.qpid.amqp_1_0.client.Sender.<init>(Sender.java:98)
at org.apache.qpid.amqp_1_0.client.Sender.<init>(Sender.java:84)
at org.apache.qpid.amqp_1_0.client.Sender.<init>(Sender.java:78)
at org.apache.qpid.amqp_1_0.client.Session$1.<init>(Session.java:90)
at org.apache.qpid.amqp_1_0.client.Session.createSender(Session.java:89)
at org.apache.qpid.amqp_1_0.jms.impl.MessageProducerImpl.<init>(MessageProducerImpl.java:86)
... 3 more
浪费很多时间来了解我在做什么错都没有成功任何人都可以帮忙吗?
你的答案是非常AP preciated。
Wasted many hours to understand what am I doing wrong without success can anyone help?
your answer is highly appreciated.
推荐答案
确认未启用队列划分。 ServiceBus不分区队列支持AMQP,但队列与默认启用的分区创建的。
Make sure your queue does not have partitioning enabled. ServiceBus does not support AMQP with partitioned queues, however queues are created with partitioning enabled by default.
我有这个确切的同样的错误,并重新创建队列中启用分区未解决了我。
I had this exact same error, and re-creating the queue with "Enable Partitioning" unchecked solved it for me.
看到分区实体限制部分在本文的底部:的 https://msdn.microsoft.com/en-us/library/azure/dn520246.aspx
See the Partitioned Entities Limitations section at the bottom of this article: https://msdn.microsoft.com/en-us/library/azure/dn520246.aspx
分区队列和主题只能通过SBMP或HTTP / HTTPS可用。 AMQP的支持将在未来加入。
Partitioned queues and topics are only available via SBMP or HTTP/HTTPS. AMQP support will be added in the future.
这篇关于通过Java客户端连接的Azure服务总线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!