Hot questions for Using Azure in amqp

Question:

I'm trying to execute this example program, but I am getting the following class not found exception:

javax.naming.NoInitialContextException: Cannot instantiate class: org.apache.qpid.amqp_1_0.jms.jndi.PropertiesFileInitialContextFactory [Root exception is java.lang.ClassNotFoundException: org.apache.qpid.amqp_1_0.jms.jndi.PropertiesFileInitialContextFactory]
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.init(Unknown Source)
    at javax.naming.InitialContext.<init>(Unknown Source)
    at filternet.SimpleSenderReceiver.<init>(SimpleSenderReceiver.java:30)
    at filternet.SimpleSenderReceiver.main(SimpleSenderReceiver.java:60)
Caused by: java.lang.ClassNotFoundException: org.apache.qpid.amqp_1_0.jms.jndi.PropertiesFileInitialContextFactory*

I have included the following dependency in my pom file:

 <dependency> <groupId>org.apache.qpid</groupId>
 <artifactId>qpid-jms-client</artifactId> </dependency>

But I can't find PropertiesFileInitialContextFactory class file nor any jndi directories in the local maven repository.


Answer:

Solved by downloading the jars separately and installing them into the Maven repository according to this document:

How to add local jar files in maven project?

Then adding the pom definitions from the jar installs into the project's pom.xml file.

Question:

I am trying to send messages to Service bus using AMQP QPID java library

I am getting this error:

"SessionId needs to be set for all brokered messages to a Partitioned Topic that supports Ordering"

My topic has "Enforce Message ordering" turned on (this is way i get this error i guess)

When using the Azure Service bus java library (and not AMQP) i have this function :

this.entity.setSessionId(...);

When using the AMQP library i do not see an option to set the session ID on the message i want to send

Note that if i un-check the option "Enforce Message ordering" the message will be sent successfully

This is my code

private boolean sendServiceBusMsg(MessageProducer sender,Session sendSession) {

        try {
            // generate message

            BytesMessage createBytesMessage = (BytesMessage)sendSession.createBytesMessage();

            createBytesMessage.setStringProperty(CAMPAIGN_ID, campaignKey);             
            createBytesMessage.setJMSMessageID("ID:" + bm.getMessageId());                                                    
      createBytesMessage.setContentType(Symbol.getSymbol("application/octet-stream"));

            /*message is the actual data i send / not seen here*/
            createBytesMessage.writeBytes(message.toByteArray());

            sender.send(createBytesMessage);

        } catch (JMSException e) {
    }

Answer:

The SessionId property is mapped to AMQP message properties.group-id. The Qpid JMS client should map it to JMSXGroupID property, so try the following, createBytesMessage.setStringProperty("JMSXGroupID", "session-1");

Question:

I have already working application based on Azure EventHub. Now I need write java receiver that connects to the existing infrastructure. Existing configuration:

Event Hub > SomeName > Consumer Group > SomeGroupName

In the administrative console I cannot see any QUEUE or TOPIC definitions. Analyzing working c# code I can see that hub-name + group-name is enough to connect.

I have reconstructed url that allows me to connect over java (and connection works so far).

amqps://SomeName.servicebus.windows.net

So my questions:

1) When instead of queue /topic I specify group-name then I get exception The messaging entity 'sb://SomeName.servicebus.windows.net/SomeGroupName' could not be found. What is the model used there instead of queue/topic?

2) How to work with such infrastructure from Apache-qpid?


Answer:

Are you using the Event Hub created in the old portal or one created using the new portal?

EventHub is not a Message Bus, so there are no Queues or Topics, that is correct.

The consumer group is not a part of the address. The address is build using the namespace and the name of the eventhub in that namespace.

So the address becomes:

sb://SomeNameSpaceName.servicebus.windows.net/SomeEventHubName 

Can you post the c# code you've analyzed? Since you have an already working application maybe we can workout the differences that prevents it from working now.

Question:

I'm getting the below exception thrown at AmqpProviderFactory.createProvider in qpid-jms-client-0.40.0.jar

java.lang.NoClassDefFoundError: org/apache/qpid/proton/engine/Collector
    at org.apache.qpid.jms.provider.amqp.AmqpProviderFactory.createProvider(AmqpProviderFactory.java:69) ~[qpid-jms-client-0.40.0.jar:?]
    at org.apache.qpid.jms.provider.amqp.AmqpProviderFactory.createProvider(AmqpProviderFactory.java:31) ~[qpid-jms-client-0.40.0.jar:?]
    at org.apache.qpid.jms.provider.ProviderFactory.create(ProviderFactory.java:103) ~[qpid-jms-client-0.40.0.jar:?]
    at org.apache.qpid.jms.provider.ProviderFactory.create(ProviderFactory.java:82) ~[qpid-jms-client-0.40.0.jar:?]
    at org.apache.qpid.jms.JmsConnectionFactory.createProvider(JmsConnectionFactory.java:332) ~[qpid-jms-client-0.40.0.jar:?]
    at org.apache.qpid.jms.JmsConnectionFactory.createConnection(JmsConnectionFactory.java:203) ~[qpid-jms-client-0.40.0.jar:?]
    at org.apache.qpid.jms.JmsConnectionFactory.createConnection(JmsConnectionFactory.java:194) ~[qpid-jms-client-0.40.0.jar:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_131]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131]
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333) ~[spring-aop-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) ~[spring-aop-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at com.sun.proxy.$Proxy715.createConnection(Unknown Source) ~[?:?]
    at org.springframework.jms.connection.SingleConnectionFactory.doCreateConnection(SingleConnectionFactory.java:365) ~[spring-jms-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.jms.connection.SingleConnectionFactory.initConnection(SingleConnectionFactory.java:305) ~[spring-jms-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.jms.connection.SingleConnectionFactory.getConnection(SingleConnectionFactory.java:283) ~[spring-jms-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.jms.connection.SingleConnectionFactory.createConnection(SingleConnectionFactory.java:224) ~[spring-jms-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:180) ~[spring-jms-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer.refreshConnectionUntilSuccessful(DefaultMessageListenerContainer.java:928) ~[spring-jms-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer.recoverAfterListenerSetupFailure(DefaultMessageListenerContainer.java:899) ~[spring-jms-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1077) ~[spring-jms-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_131]

Some of the dependencies I have in the classpath are

  • qpid-jms-client:0.40.0
  • proton-j:0.31.0
  • azure-eventhubs:2.2.0

Is there any other dependency that I should add to this to make it work?


Answer:

The proton event collector class is a pretty basic bit of the proton-j library that has been in there for years so my guess is that you don't have the libraries on your classpath that you think you do. The failure indicates it cannot be found and the only reason for that should be that the library simply isn't there.