我正在编写我的第一个应用程序来发送和接收来自EventHub。我跟随Azure doc中提供的示例。
我的servicebus.properties文件看起来像这样。
connectionfactory.SBCF = amqps://SendRule:BLAH..blah@mynamespace.servicebus.windows.net/?sync-publish=false
queue.EventHub = eventhub1
我的发件人代码如下所示
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, "servicebus.properties");
Context context = new InitialContext(env);
ConnectionFactory cf = (ConnectionFactory) context.lookup("SBCF");
Destination queue = (Destination) context.lookup("EventHub");
Connection connection = cf.createConnection();
Session sendSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer sender = sendSession.createProducer(queue);
我得到了例外
Exception in thread "main" javax.jms.JMSException: Peer did not create remote endpoint for link, target: eventhub1
at org.apache.qpid.amqp_1_0.jms.impl.MessageProducerImpl.<init>(MessageProducerImpl.java:69)
at org.apache.qpid.amqp_1_0.jms.impl.SessionImpl.createProducer(SessionImpl.java:293)
at org.apache.qpid.amqp_1_0.jms.impl.SessionImpl.createProducer(SessionImpl.java:57)
at com.commvault.azure.Sender.main(Sender.java:39)
当我搜索解决方案时,我获得ServiceBus队列的帮助,使用的连接字符串格式为[用户名]:[密码]:[命名空间]。在EventHub上找不到任何帮助。
有什么遗漏的建议吗?