0

I have created 2 Java Demo applications which connects to an already configured Azure Service Bus using the following guides:

  • How to use the Java Message Service (JMS) API with Service Bus and AMQP 1.0 - azure.microsoft.com/nl-nl/documentation/articles/service-bus-java-how-to-use-jms-api-amqp
  • Qpid JMS 0.11.1 documentation - qpid.apache.org/releases/qpid-jms-0.11.1/docs/index.html

The Sender.java app can successfully place a message in a queue on the preconfigured Azure Service Bus. The SimpleReceiver.java app is setup to receive a message from a queue on Azure ServiceBus.

Currently the SimpleReceiver.java can successfully receive a message that was originally sent from the Sender.java app to the Service Bus. But fails to receive messasges that where sent by a .Net(C#) Sender.cs app.

How Can I implement/setup the SimpleReceiver.java to receive all messages from the Azure Service Bus Queue? (using Qpid JMS 0.11.1)

Side note: I am able to achieve this using the older library Qpid JMS 0.32. But version 0.11.1 is a necessity.

To sum up what i have so far:

  • [works] Sender.java -> Azure Service Bus -> SimpleReceiver.java
  • [works] Sender.java -> Azure Service Bus -> (.Net) Receiver.cs
  • [works] (.Net) Sender.cs -> Azure Service Bus -> (.Net) Receiver.cs
  • [fails] (.Net) Sender.cs -> Azure Service Bus -> SimpleReceiver.java

When I try to receive messages sent by .Net with the SimpleReceiver.java i get the following traces/log:

2016-11-07 09:44:18,778 [ntLoopGroup-2-1] - TRACE NettyTcpTransport              - SSL Handshake has completed: [id: 0xe1a2112b, L:/10.70.1.160:57828 - R:demo-sandbox-open-bus.servicebus.windows.net/13.69.253.135:5671]
2016-11-07 09:44:18,778 [ntLoopGroup-2-1] - TRACE NettyTcpTransport              - Channel has become active! Channel is [id: 0xe1a2112b, L:/10.70.1.160:57828 - R:demo-sandbox-open-bus.servicebus.windows.net/13.69.253.135:5671]
2016-11-07 09:44:18,778 [ntLoopGroup-2-1] - DEBUG SslHandler                     - [id: 0xe1a2112b, L:/10.70.1.160:57828 - R:demo-sandbox-open-bus.servicebus.windows.net/13.69.253.135:5671] HANDSHAKEN: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
connection :org.apache.qpid.jms.JmsConnection@c1c084f
2016-11-07 09:44:18,813 [us.windows.net]] - TRACE MetaDataSupport                - Problem generating primary version details
java.lang.NullPointerException
    at java.util.regex.Matcher.getTextLength(Matcher.java:1234)
    at java.util.regex.Matcher.reset(Matcher.java:308)
    at java.util.regex.Matcher.<init>(Matcher.java:228)
    at java.util.regex.Pattern.matcher(Pattern.java:1088)
    at org.apache.qpid.jms.util.MetaDataSupport.<clinit>(MetaDataSupport.java:47)
    at org.apache.qpid.jms.provider.amqp.builders.AmqpConnectionBuilder.createEndpoint(AmqpConnectionBuilder.java:108)
    at org.apache.qpid.jms.provider.amqp.builders.AmqpConnectionBuilder.createEndpoint(AmqpConnectionBuilder.java:41)
    at org.apache.qpid.jms.provider.amqp.builders.AmqpResourceBuilder.buildResource(AmqpResourceBuilder.java:72)
    at org.apache.qpid.jms.provider.amqp.builders.AmqpConnectionBuilder.buildResource(AmqpConnectionBuilder.java:94)
    at org.apache.qpid.jms.provider.amqp.AmqpProvider$4$1.processConnectionInfo(AmqpProvider.java:323)
    at org.apache.qpid.jms.meta.JmsConnectionInfo.visit(JmsConnectionInfo.java:373)
    at org.apache.qpid.jms.provider.amqp.AmqpProvider$4.run(AmqpProvider.java:252)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
2016-11-07 09:44:18,819 [us.windows.net]] - TRACE NettyTcpTransport              - Attempted write of: 8 bytes
2016-11-07 09:44:18,845 [ntLoopGroup-2-1] - TRACE NettyTcpTransport              - New data read: 8 bytes incoming: UnpooledUnsafeHeapByteBuf(ridx: 0, widx: 8, cap: 37)
2016-11-07 09:44:18,846 [us.windows.net]] - TRACE AmqpProvider                   - New Proton Event: CONNECTION_INIT
2016-11-07 09:44:18,847 [us.windows.net]] - TRACE AmqpProvider                   - New Proton Event: CONNECTION_LOCAL_OPEN
2016-11-07 09:44:18,926 [ntLoopGroup-2-1] - TRACE NettyTcpTransport              - New data read: 63 bytes incoming: UnpooledUnsafeHeapByteBuf(ridx: 0, widx: 63, cap: 101)
2016-11-07 09:44:18,928 [us.windows.net]] - DEBUG SaslMechanismFinder            - Unknown SASL mechanism: [MSSBCBS]
2016-11-07 09:44:18,931 [us.windows.net]] - DEBUG SaslMechanismFinder            - Skipping SASL-EXTERNAL mechanism because the available credentials are not sufficient
2016-11-07 09:44:18,931 [us.windows.net]] - INFO  SaslMechanismFinder            - Best match for SASL auth was: SASL-PLAIN
2016-11-07 09:44:18,933 [us.windows.net]] - TRACE NettyTcpTransport              - Attempted write of: 125 bytes
2016-11-07 09:44:18,958 [ntLoopGroup-2-1] - TRACE NettyTcpTransport              - New data read: 26 bytes incoming: UnpooledUnsafeHeapByteBuf(ridx: 0, widx: 26, cap: 53)
[395414939:0] -> Open{ containerId='ID:9669bcc7-59c0-43eb-9908-00605f8153dd:1', hostname='demo-sandbox-open-bus.servicebus.windows.net', maxFrameSize=1048576, channelMax=32767, idleTimeOut=75000, outgoingLocales=null, incomingLocales=null, offeredCapabilities=null, desiredCapabilities=[sole-connection-for-container], properties={product=QpidJMS, version=0.11.1, platform=JVM: 1.7.0_75, 24.75-b04, Oracle Corporation, OS: Windows 8.1, 6.3, amd64}}
2016-11-07 09:44:18,961 [us.windows.net]] - TRACE FRAMES                         - SENT: Open{ containerId='ID:9669bcc7-59c0-43eb-9908-00605f8153dd:1', hostname='demo-sandbox-open-bus.servicebus.windows.net', maxFrameSize=1048576, channelMax=32767, idleTimeOut=75000, outgoingLocales=null, incomingLocales=null, offeredCapabilities=null, desiredCapabilities=[sole-connection-for-container], properties={product=QpidJMS, version=0.11.1, platform=JVM: 1.7.0_75, 24.75-b04, Oracle Corporation, OS: Windows 8.1, 6.3, amd64}}
2016-11-07 09:44:18,961 [us.windows.net]] - TRACE NettyTcpTransport              - Attempted write of: 290 bytes
2016-11-07 09:44:18,985 [ntLoopGroup-2-1] - TRACE NettyTcpTransport              - New data read: 8 bytes incoming: UnpooledUnsafeHeapByteBuf(ridx: 0, widx: 8, cap: 37)
2016-11-07 09:44:19,061 [ntLoopGroup-2-1] - TRACE NettyTcpTransport              - New data read: 70 bytes incoming: UnpooledUnsafeHeapByteBuf(ridx: 0, widx: 70, cap: 101)
[395414939:0] <- Open{ containerId='d3a14a268d4c45b1a5f6acabc01c1bdd_G43', hostname='null', maxFrameSize=65536, channelMax=4999, idleTimeOut=240000, outgoingLocales=null, incomingLocales=null, offeredCapabilities=null, desiredCapabilities=null, properties=null}
2016-11-07 09:44:19,061 [us.windows.net]] - TRACE FRAMES                         - RECV: Open{ containerId='d3a14a268d4c45b1a5f6acabc01c1bdd_G43', hostname='null', maxFrameSize=65536, channelMax=4999, idleTimeOut=240000, outgoingLocales=null, incomingLocales=null, offeredCapabilities=null, desiredCapabilities=null, properties=null}
2016-11-07 09:44:19,061 [us.windows.net]] - TRACE AmqpProvider                   - New Proton Event: CONNECTION_REMOTE_OPEN
2016-11-07 09:44:19,064 [us.windows.net]] - TRACE AmqpProvider                   - New Proton Event: SESSION_INIT
2016-11-07 09:44:19,064 [us.windows.net]] - TRACE AmqpProvider                   - New Proton Event: SESSION_LOCAL_OPEN
[395414939:0] -> Begin{remoteChannel=null, nextOutgoingId=1, incomingWindow=2047, outgoingWindow=2147483647, handleMax=65535, offeredCapabilities=null, desiredCapabilities=null, properties=null}
2016-11-07 09:44:19,066 [us.windows.net]] - TRACE FRAMES                         - SENT: Begin{remoteChannel=null, nextOutgoingId=1, incomingWindow=2047, outgoingWindow=2147483647, handleMax=65535, offeredCapabilities=null, desiredCapabilities=null, properties=null}
2016-11-07 09:44:19,066 [us.windows.net]] - TRACE NettyTcpTransport              - Attempted write of: 32 bytes
2016-11-07 09:44:19,091 [ntLoopGroup-2-1] - TRACE NettyTcpTransport              - New data read: 34 bytes incoming: UnpooledUnsafeHeapByteBuf(ridx: 0, widx: 34, cap: 69)
[395414939:0] <- Begin{remoteChannel=0, nextOutgoingId=1, incomingWindow=5000, outgoingWindow=2047, handleMax=255, offeredCapabilities=null, desiredCapabilities=null, properties=null}
2016-11-07 09:44:19,091 [us.windows.net]] - TRACE FRAMES                         - RECV: Begin{remoteChannel=0, nextOutgoingId=1, incomingWindow=5000, outgoingWindow=2047, handleMax=255, offeredCapabilities=null, desiredCapabilities=null, properties=null}
2016-11-07 09:44:19,091 [us.windows.net]] - TRACE AmqpProvider                   - New Proton Event: SESSION_REMOTE_OPEN
2016-11-07 09:44:19,091 [us.windows.net]] - DEBUG AmqpConnectionBuilder          - AmqpConnection { ID:13845de8-37ce-42de-8d5d-2e4d9de7352f:1 } is now open: 
2016-11-07 09:44:19,091 [us.windows.net]] - TRACE AmqpProvider                   - IdleTimeoutCheck being initiated, initial delay: 120000
2016-11-07 09:44:19,092 [us.windows.net]] - INFO  JmsConnection                  - Connection ID:13845de8-37ce-42de-8d5d-2e4d9de7352f:1 connected to remote Broker: amqps://demo-sandbox-open-bus.servicebus.windows.net
[395414939:1] -> Begin{remoteChannel=null, nextOutgoingId=1, incomingWindow=2047, outgoingWindow=2147483647, handleMax=65535, offeredCapabilities=null, desiredCapabilities=null, properties=null}
2016-11-07 09:44:19,102 [us.windows.net]] - TRACE FRAMES                         - SENT: Begin{remoteChannel=null, nextOutgoingId=1, incomingWindow=2047, outgoingWindow=2147483647, handleMax=65535, offeredCapabilities=null, desiredCapabilities=null, properties=null}
2016-11-07 09:44:19,102 [us.windows.net]] - TRACE NettyTcpTransport              - Attempted write of: 32 bytes
2016-11-07 09:44:19,126 [ntLoopGroup-2-1] - TRACE NettyTcpTransport              - New data read: 34 bytes incoming: UnpooledUnsafeHeapByteBuf(ridx: 0, widx: 34, cap: 69)
[395414939:1] <- Begin{remoteChannel=1, nextOutgoingId=1, incomingWindow=5000, outgoingWindow=2047, handleMax=255, offeredCapabilities=null, desiredCapabilities=null, properties=null}
2016-11-07 09:44:19,126 [us.windows.net]] - TRACE FRAMES                         - RECV: Begin{remoteChannel=1, nextOutgoingId=1, incomingWindow=5000, outgoingWindow=2047, handleMax=255, offeredCapabilities=null, desiredCapabilities=null, properties=null}
2016-11-07 09:44:19,126 [us.windows.net]] - TRACE AmqpProvider                   - New Proton Event: SESSION_INIT
2016-11-07 09:44:19,126 [us.windows.net]] - TRACE AmqpProvider                   - New Proton Event: SESSION_LOCAL_OPEN
2016-11-07 09:44:19,126 [us.windows.net]] - TRACE AmqpProvider                   - New Proton Event: SESSION_REMOTE_OPEN
[395414939:1] -> Attach{name='qpid-jms:receiver:ID:13845de8-37ce-42de-8d5d-2e4d9de7352f:1:1:1:a_receiver/verwerker/klant', handle=0, role=RECEIVER, sndSettleMode=UNSETTLED, rcvSettleMode=FIRST, source=Source{address='a_receiver/verwerker/klant', durable=NONE, expiryPolicy=LINK_DETACH, timeout=0, dynamic=false, dynamicNodeProperties=null, distributionMode=null, filter=null, defaultOutcome=Modified{deliveryFailed=true, undeliverableHere=null, messageAnnotations=null}, outcomes=[amqp:accepted:list, amqp:rejected:list, amqp:released:list, amqp:modified:list], capabilities=[queue]}, target=Target{address='null', durable=NONE, expiryPolicy=SESSION_END, timeout=0, dynamic=false, dynamicNodeProperties=null, capabilities=null}, unsettled=null, incompleteUnsettled=false, initialDeliveryCount=null, maxMessageSize=null, offeredCapabilities=null, desiredCapabilities=null, properties=null}
2016-11-07 09:44:19,138 [us.windows.net]] - TRACE FRAMES                         - SENT: Attach{name='qpid-jms:receiver:ID:13845de8-37ce-42de-8d5d-2e4d9de7352f:1:1:1:a_receiver/verwerker/klant', handle=0, role=RECEIVER, sndSettleMode=UNSETTLED, rcvSettleMode=FIRST, source=Source{address='a_receiver/verwerker/klant', durable=NONE, expiryPolicy=LINK_DETACH, timeout=0, dynamic=false, dynamicNodeProperties=null, distributionMode=null, filter=null, defaultOutcome=Modified{deliveryFailed=true, undeliverableHere=null, messageAnnotations=null}, outcomes=[amqp:accepted:list, amqp:rejected:list, amqp:released:list, amqp:modified:list], capabilities=[queue]}, target=Target{address='null', durable=NONE, expiryPolicy=SESSION_END, timeout=0, dynamic=false, dynamicNodeProperties=null, capabilities=null}, unsettled=null, incompleteUnsettled=false, initialDeliveryCount=null, maxMessageSize=null, offeredCapabilities=null, desiredCapabilities=null, properties=null}
2016-11-07 09:44:19,138 [us.windows.net]] - TRACE NettyTcpTransport              - Attempted write of: 276 bytes
2016-11-07 09:44:19,164 [ntLoopGroup-2-1] - TRACE NettyTcpTransport              - New data read: 310 bytes incoming: UnpooledUnsafeHeapByteBuf(ridx: 0, widx: 310, cap: 341)
[395414939:1] <- Attach{name='qpid-jms:receiver:ID:13845de8-37ce-42de-8d5d-2e4d9de7352f:1:1:1:a_receiver/verwerker/klant', handle=0, role=SENDER, sndSettleMode=MIXED, rcvSettleMode=SECOND, source=Source{address='a_receiver/verwerker/klant', durable=NONE, expiryPolicy=LINK_DETACH, timeout=0, dynamic=false, dynamicNodeProperties=null, distributionMode=null, filter=null, defaultOutcome=Modified{deliveryFailed=true, undeliverableHere=null, messageAnnotations=null}, outcomes=[amqp:accepted:list, amqp:rejected:list, amqp:released:list, amqp:modified:list], capabilities=[queue]}, target=Target{address='null', durable=NONE, expiryPolicy=SESSION_END, timeout=0, dynamic=false, dynamicNodeProperties=null, capabilities=null}, unsettled=null, incompleteUnsettled=false, initialDeliveryCount=0, maxMessageSize=266240, offeredCapabilities=null, desiredCapabilities=null, properties=null}
2016-11-07 09:44:19,164 [us.windows.net]] - TRACE FRAMES                         - RECV: Attach{name='qpid-jms:receiver:ID:13845de8-37ce-42de-8d5d-2e4d9de7352f:1:1:1:a_receiver/verwerker/klant', handle=0, role=SENDER, sndSettleMode=MIXED, rcvSettleMode=SECOND, source=Source{address='a_receiver/verwerker/klant', durable=NONE, expiryPolicy=LINK_DETACH, timeout=0, dynamic=false, dynamicNodeProperties=null, distributionMode=null, filter=null, defaultOutcome=Modified{deliveryFailed=true, undeliverableHere=null, messageAnnotations=null}, outcomes=[amqp:accepted:list, amqp:rejected:list, amqp:released:list, amqp:modified:list], capabilities=[queue]}, target=Target{address='null', durable=NONE, expiryPolicy=SESSION_END, timeout=0, dynamic=false, dynamicNodeProperties=null, capabilities=null}, unsettled=null, incompleteUnsettled=false, initialDeliveryCount=0, maxMessageSize=266240, offeredCapabilities=null, desiredCapabilities=null, properties=null}
2016-11-07 09:44:19,165 [us.windows.net]] - TRACE AmqpProvider                   - New Proton Event: LINK_INIT
2016-11-07 09:44:19,165 [us.windows.net]] - TRACE AmqpProvider                   - New Proton Event: LINK_LOCAL_OPEN
2016-11-07 09:44:19,165 [us.windows.net]] - TRACE AmqpProvider                   - New Proton Event: LINK_REMOTE_OPEN
2016-11-07 09:44:19,166 [us.windows.net]] - TRACE AmqpConsumer                   - Consumer ID:13845de8-37ce-42de-8d5d-2e4d9de7352f:1:1:1 granting additional credit: 1000
receiver.getMessageSelector(): is null
[395414939:1] -> Flow{nextIncomingId=1, incomingWindow=2047, nextOutgoingId=1, outgoingWindow=2147483647, handle=0, deliveryCount=0, linkCredit=1000, available=null, drain=false, echo=false, properties=null}
2016-11-07 09:44:19,167 [us.windows.net]] - TRACE FRAMES                         - SENT: Flow{nextIncomingId=1, incomingWindow=2047, nextOutgoingId=1, outgoingWindow=2147483647, handle=0, deliveryCount=0, linkCredit=1000, available=null, drain=false, echo=false, properties=null}
2016-11-07 09:44:19,167 [us.windows.net]] - TRACE NettyTcpTransport              - Attempted write of: 35 bytes
Type 'exit' + [enter] to quit.
2016-11-07 09:44:19,194 [ntLoopGroup-2-1] - TRACE NettyTcpTransport              - New data read: 548 bytes incoming: UnpooledUnsafeHeapByteBuf(ridx: 0, widx: 548, cap: 581)
[395414939:1] <- Transfer{handle=0, deliveryId=0, deliveryTag=~\x00\x5c#\xa0j\xd6A\x92N\x82\x91\x1a\x09\xd3\x12, messageFormat=0, settled=null, more=false, rcvSettleMode=null, state=null, resume=false, aborted=false, batchable=true} (506) "\x00Sp\xc0\x0a\x05@@p\x0er\xbb\x00@C\x00Sr\xc1\x5c\x06\xa3\x13x-opt-enqueued-time\x83\x00\x00\x01X=\xf5\x108\xa3\x15x-opt-sequence-number\x81\x00\x00\x00\x00\x00\x00\x01\xca\xa3\x12x-opt-locked-until\x83\x00\x00\x01X=\xf6\x96\xcf\x00Ss\xc0=\x0d\xa1\x1dtestsender2016-11-07T09:43:38@@@@@\xa3\x10application/json@@@@@@\x00St\xc1\xb5\x0e\xa1\x0bMessageType\xa1\x0fDocumentMessage\xa1\x0cSourceSystem\xa1\x0asis_sender\xa1\x0dEnterpriseKey\xa1\x18sis_sender-klant-bericht\xa1\x08TenantId\xa1\x05klant\xa1\x09EventType\xa1\x07bericht\xa1\x10EventTypeVersion\xa1\x031.0\xa1\x0dOperationType\xa1\x06Create\x00Su\xa0\x89@\x06string\x083http://schemas.microsoft.com/2003/10/Serialization/\x99J{"id": 1,"name": "A .net door","price": 12.50,"tags": ["home", "C# .Net"]}"
2016-11-07 09:44:19,201 [us.windows.net]] - TRACE FRAMES                         - RECV: Transfer{handle=0, deliveryId=0, deliveryTag=~\x00\x5c#\xa0j\xd6A\x92N\x82\x91\x1a\x09\xd3\x12, messageFormat=0, settled=null, more=false, rcvSettleMode=null, state=null, resume=false, aborted=false, batchable=true}
2016-11-07 09:44:19,203 [us.windows.net]] - TRACE AmqpProvider                   - New Proton Event: DELIVERY
2016-11-07 09:44:19,203 [us.windows.net]] - TRACE AmqpConsumer                   - AmqpConsumer { ID:13845de8-37ce-42de-8d5d-2e4d9de7352f:1:1:1 } has incoming Message(s).
2016-11-07 09:44:19,210 [us.windows.net]] - DEBUG AmqpConsumer                   - Dispatching received message: JmsInboundMessageDispatch {sequence = 1, messageId = testsender2016-11-07T09:43:38, consumerId = ID:13845de8-37ce-42de-8d5d-2e4d9de7352f:1:1:1}
2016-11-07 09:44:19,211 [1:1] dispatcher] - TRACE JmsMessageConsumer             - checking envelope with 0 redeliveries
2016-11-07 09:44:19,212 [us.windows.net]] - DEBUG AmqpConsumer                   - Delivered Ack of message: JmsInboundMessageDispatch {sequence = 1, messageId = testsender2016-11-07T09:43:38, consumerId = ID:13845de8-37ce-42de-8d5d-2e4d9de7352f:1:1:1}

I also have a comparison of a message sent by Java vs one sent by .net(C#) (messages exported from Service Bus Explorer). I have a feeling it has something to do with the contentType/ type of message sent.

Below are traces/logs of a successfull message sent by Java and a Unsucceful message sent by .Net:

[2138532527:1] <- Transfer{handle=0, deliveryId=0, deliveryTag=Z\x80\x91\x15\xa3v{D\x96`\x04\x1ad\xb8;V, messageFormat=0, settled=null, more=false, rcvSettleMode=null, state=null, resume=false, aborted=false, batchable=true} (529) "\x00Sp\xc0\x0a\x05B@p\x0er\xbb\x00@C\x00Sr\xc1\x84\x0a\xa3\x12x-opt-jms-msg-typeQ\x05\xa3\x0ex-opt-jms-destQ\x00\xa3\x13x-opt-enqueued-time\x83\x00\x00\x01X*i\x17!\xa3\x15x-opt-sequence-number\x81\x00\x00\x00\x00\x00\x00\x01\xa9\xa3\x12x-opt-locked-until\x83\x00\x00\x01X*j\x01\x91\x00Ss\xc0t\x0d\xa1/ID:e076122e-f27d-4cdd-9b13-33e75716d70a:1:1:1-1@\xa1\x1csis_receiver/verwerker/klant\xa1\x10application/json@@@@@\x83\x00\x00\x01X*i\x12h@@@\x00St\xc1\xb5\x0e\xa1\x08TenantId\xa1\x05klant\xa1\x0dEnterpriseKey\xa1\x18sis_sender-klant-bericht\xa1\x09EventType\xa1\x07bericht\xa1\x10EventTypeVersion\xa1\x031.0\xa1\x0bMessageType\xa1\x0fDocumentMessage\xa1\x0dOperationType\xa1\x06Create\xa1\x0cSourceSystem\xa1\x0asis_sender\x00Sw\xa1A{"logged":false,"userID":"0","bericht Marvin Java":"test body2"} "
Received message with JMSMessageID = ID:e076122e-f27d-4cdd-9b13-33e75716d70a:1:1:1-1
[2138532527:1] -> Disposition{role=RECEIVER, first=0, last=0, settled=true, state=Accepted{}, batchable=false}
[2138532527:1] <- Transfer{handle=0, deliveryId=1, deliveryTag=\xd7\xbb\x1b\xcb>\x91\x14O\xa2\x83q\x9e\xc9|N\x09, messageFormat=0, settled=null, more=false, rcvSettleMode=null, state=null, resume=false, aborted=false, batchable=true} (504) "\x00Sp\xc0\x0a\x05@@p\x0er\xbb\x00@C\x00Sr\xc1\x5c\x06\xa3\x13x-opt-enqueued-time\x83\x00\x00\x01X*i\x5c\x10\xa3\x15x-opt-sequence-number\x81\x00\x00\x00\x00\x00\x00\x01\xaa\xa3\x12x-opt-locked-until\x83\x00\x00\x01X*jFp\x00Ss\xc0=\x0d\xa1\x1dtestsender2016-11-03T14:38:15@@@@@\xa3\x10application/json@@@@@@\x00St\xc1\xb5\x0e\xa1\x0bMessageType\xa1\x0fDocumentMessage\xa1\x0cSourceSystem\xa1\x0asis_sender\xa1\x0dEnterpriseKey\xa1\x18sis_sender-klant-bericht\xa1\x08TenantId\xa1\x05klant\xa1\x09EventType\xa1\x07bericht\xa1\x10EventTypeVersion\xa1\x031.0\xa1\x0dOperationType\xa1\x06Create\x00Su\xa0\x87@\x06string\x083http://schemas.microsoft.com/2003/10/Serialization/\x99H{"id": 1,"name": "A .net door","price": 12.50,"tags": ["home", "green"]}"

I have the follwing properties file servicebus.properties:

# Set the InitialContextFactory class to use
java.naming.factory.initial = org.apache.qpid.jms.jndi.JmsInitialContextFactory

# Define the required ConnectionFactory instances
# connectionfactory.<JNDI-lookup-name> = <URI>
connectionfactory.myFactoryLookup = amqps://demo-sandbox-open-bus.servicebus.windows.net?amqp.idleTimeout=150000&amqp.traceFrames=true&jms.username=somePolicy&jms.password=aM1k3PaXY5jdIkmGKm7G%2FcH%2BUFQaFAgHIYc3dSsuiLI%3D

# Register some queues in JNDI using the form
# queue.[jndi_name] = [physical_name]
# topic.[jndi_name] = [physical_name]
queue.myQueueLookup = queue1

I have the following class SimpleReceiver.java:

package com.demo.AzureTest;

import javax.jms.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Hashtable;
import java.util.Random;

public class SimpleReceiver implements MessageListener {

    private Connection connection;
    private Session receiveSession;
    private MessageConsumer receiver;
    private static Random randomGenerator = new Random(); 

    public SimpleReceiver() throws Exception {

        Context context = new InitialContext();

        ConnectionFactory cf = (ConnectionFactory) context.lookup("myFactoryLookup");
        Destination queue = (Destination) context.lookup("myQueueLookup");

        // Create Connection
        connection = cf.createConnection();
        System.out.println("connection :"+connection);

        // Create receiver-side Session, MessageConsumer,and MessageListener
        receiveSession = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
        receiver = receiveSession.createConsumer(queue);
        if (receiver.getMessageSelector() != null){
            System.out.println("receiver.getMessageSelector(): " + receiver.getMessageSelector());
        }
        else {
            System.out.println("receiver.getMessageSelector(): is null" );
        }
        receiver.setMessageListener(this);

        connection.start();

    }

    public static void main(String[] args) {
        try {

            SimpleReceiver simpleSenderReceiver = new SimpleReceiver();
            System.out.println("Type 'exit' + [enter] to quit.");
            BufferedReader commandLine = new java.io.BufferedReader(new InputStreamReader(System.in));

            while (true) {
                String s = commandLine.readLine();
                if (s.equalsIgnoreCase("exit")) {
                    simpleSenderReceiver.close();
                    System.exit(0);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void close() throws JMSException {
        connection.close();
    }

    public void onMessage(Message message) {
        try {
            System.out.println("Received message with JMSMessageID = " + message.getJMSMessageID());
            TextMessage txtmessage = (TextMessage) message;
            System.out.println("Received message with Text = " + txtmessage.getText());
            message.acknowledge();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}  

I have the following class Sender.java:

package com.demo.QpidTest;

import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.DeliveryMode;
import javax.jms.Destination;
import javax.jms.ExceptionListener;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;

public class Sender {
    private static final int DEFAULT_COUNT = 1;
    private static final int DELIVERY_MODE = DeliveryMode.NON_PERSISTENT;
    private static Random randomGenerator = new Random();

    public static void main(String[] args) throws Exception { 
        int count = DEFAULT_COUNT;
        if (args.length == 0) {
            System.out.println("Sending up to " + count + " messages.");
        } else {
            count = Integer.parseInt(args[0]);
            System.out.println("Sending up to " + count + " messages.");
        }

        try {
            // The configuration for the Qpid InitialContextFactory has been supplied in
            // a jndi.properties file in the classpath, which results in it being picked
            // up automatically by the InitialContext constructor.
            Context context = new InitialContext();

            ConnectionFactory factory = (ConnectionFactory) context.lookup("myFactoryLookup");
            Destination queue = (Destination) context.lookup("myQueueLookup");

            Connection connection = factory.createConnection();
            connection.setExceptionListener(new MyExceptionListener());
            connection.start();

            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

            MessageProducer messageProducer = session.createProducer(queue);

            long start = System.currentTimeMillis();
            for (int i = 1; i <= count; i++) {
//                TextMessage message = session.createTextMessage("Text!");
                TextMessage message = session.createTextMessage("{\"id\": 1,\"name\": \"A .net door\",\"price\": 12.50,\"tags\": [\"home\", \"green\"]}");
                long randomMessageID = randomGenerator.nextLong() >>>1;
                message.setStringProperty("TenantId", "klant");
                message.setStringProperty("EventType", "bericht");
                message.setStringProperty("EventTypeVersion", "1.0");
                message.setStringProperty("MessageType", "DocumentMessage");
                message.setStringProperty("OperationType", "Create");
                message.setStringProperty("SourceSystem", "sis_sender");
                message.setStringProperty("EnterpriseKey", "sender-lant-bericht");
                message.setJMSMessageID("ID:" + randomMessageID);



                messageProducer.send(message, DELIVERY_MODE, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);

                if (i % 100 == 0) {
                    System.out.println("Sent message " + i);
                }
            }

            long finish = System.currentTimeMillis();
            long taken = finish - start;
            System.out.println("Sent " + count + " messages in " + taken + "ms");

            connection.close();
        } catch (Exception exp) {
            System.out.println("Caught exception, exiting.");
            exp.printStackTrace(System.out);
            System.exit(1);
        }
    }

    private static class MyExceptionListener implements ExceptionListener {
        @Override
        public void onException(JMSException exception) {
            System.out.println("Connection ExceptionListener fired, exiting.");
            exception.printStackTrace(System.out);
            System.exit(1);
        }
    }
}
Storage
  • 83
  • 1
  • 9
  • turn up the logging on the JMS client in the log4j.properties file or whichever logger impl you are using to capture what the client says about the incoming messages. – Tim Bish Nov 03 '16 at 16:53
  • @Tim Bish I already have turend up de logging/tracing if i am not mistaken. See traces/log in the above post. – Storage Nov 04 '16 at 09:14
  • You've turned on frame tracing but not client loggers so hard to say what the client does with the transfer – Tim Bish Nov 04 '16 at 13:03
  • @TimBish , Thanks I will look into it. – Storage Nov 04 '16 at 16:47
  • @Tim Bish - I now been able to turn up de logging/tracing – Storage Nov 07 '16 at 09:01
  • The logs show a message received and dispatched, I'd check your client code and see what's happening there. – Tim Bish Nov 07 '16 at 14:19
  • I also added a connection.setExceptionListener(new MyExceptionListener()); and also now get the following error: Connection ExceptionListener fired, exiting. javax.jms.JMSException: Cannot decode String in UTF-8 at org.apache.qpid.jms.exceptions.JmsExceptionSupport.create(JmsExceptionSupport.java:66) at org.apache.qpid.jms.provider.amqp.message.AmqpJmsTextMessageFacade.getText(AmqpJmsTextMessageFacade.java:111) at org.apache.qpid.jms.provider.amqp.message.AmqpJmsTextMessageFacade.copy(AmqpJmsTextMessageFacade.java:89) – Storage Nov 07 '16 at 15:03
  • 1
    It looks like Microsoft adds something to the body: @\x06string\x083http://schemas.microsoft.com/2003/10/Serialization/\x9 also saw this post -> http://stackoverflow.com/questions/33542509/interoperability-azure-service-bus-message-queue-messages – Storage Nov 07 '16 at 15:04
  • Looks like you found the problem then. – Tim Bish Nov 07 '16 at 16:21

0 Answers0