SwiftMQ AMQP 1.0 Client with Windows Azure Service Bus

Introduction

This document explains how to use the SwiftMQ AMQP 1.0 Java Client with Windows Azure Service Bus. It uses the AMQP 1.0 samples contained in the SwiftMQ Client distribution.

AMQP 1.0 Limitations of Windows Azure Service Bus

As far as we know at the time of the writing of this How To document (September 2013), the Service Bus has the following AMQP 1.0 limitations:

  • Transactions are not supported.
  • Request/Reply with temporary queues are not supported.
  • Multiple links on a single session are not allowed.

Service Bus only supports SSL connections on port 5671. The SwiftMQ sample programs automatically switch to SSL if port 5671 is specified.

Anonymous cipher suites are not supported so the "starter" scripts of the AMQP samples have the corresponding property disabled:

      -Dswiftmq.jsse.anoncipher.enabled=false

Create Service Bus Resources

You should have an account on Windows Azure. Please perform the following steps:

  • In "Service Bus" create a name space "swiftmq".
  • Under name space "swiftmq" create a queue "testqueue".
  • Under name space "swiftmq" create a topic "testtopic".
  • Under topic "testtopic" create a subscription "sub1".

At the bottom of the page of the "swiftmq" name space click on "Connction Information". A window appears that shows the access parameters. Note the following to use it with the SwiftMQ samples:

  • In the "connection string" the hostname "swiftmq.servicebus.windows.net".
  • The "default issues" is the user name "owner".
  • The "default key" is the password.

Prepare the SwiftMQ AMQP 1.0 Client

Download and unpack the SwiftMQ Client distribution. Go to "samples" and open a shell window there.

Send to a Queue, Receive from a Queue

Send 10 messages to the queue "testqueue". Parameters see previous section, the port is 5671 because Service Bus uses SSL:

      ./starter SenderNonTransacted swiftmq.servicebus.windows.net 5671
                 testqueue 10 EXACTLY_ONCE false owner "<password>"

Output:

      Host        : swiftmq.servicebus.windows.net
      Port        : 5671
      Target      : testqueue
      Number Msgs : 10
      QoS         : EXACTLY_ONCE
      Auth as Anon: false
      User        : owner
      Password    : <password>

      Using SSL on port 5671
      Sending Message #1
      Sending Message #2
      Sending Message #3
      Sending Message #4
      Sending Message #5
      Sending Message #6
      Sending Message #7
      Sending Message #8
      Sending Message #9
      Sending Message #10

You may now want to check in the Windows Azure console that these 10 messages have arrived in the queue "testqueue".

To receive these 10 messages call:

      ./starter ReceiverNonTransacted swiftmq.servicebus.windows.net 5671
                 testqueue 10 EXACTLY_ONCE false owner "<password>"

Output:

      Host        : swiftmq.servicebus.windows.net
      Port        : 5671
      Target      : testqueue
      Number Msgs : 10
      QoS         : EXACTLY_ONCE
      Auth as Anon: false
      User        : owner
      Password    : <password>

      Using SSL on port 5671
      Received: Message #1
      Received: Message #2
      Received: Message #3
      Received: Message #4
      Received: Message #5
      Received: Message #6
      Received: Message #7
      Received: Message #8
      Received: Message #9
      Received: Message #10

Queue "testqueue" on Service Bus should now be empty.

Send to a Topic, Receive from a Subscription

Send 10 messages to the topic "testtopic". This is actually the same as sending to a queue:

      ./starter SenderNonTransacted swiftmq.servicebus.windows.net 5671
                 testtopic 10 EXACTLY_ONCE false owner "<password>"

Output:

      Host        : swiftmq.servicebus.windows.net
      Port        : 5671
      Target      : testtopic
      Number Msgs : 10
      QoS         : EXACTLY_ONCE
      Auth as Anon: false
      User        : owner
      Password    : <password>

      Using SSL on port 5671
      Sending Message #1
      Sending Message #2
      Sending Message #3
      Sending Message #4
      Sending Message #5
      Sending Message #6
      Sending Message #7
      Sending Message #8
      Sending Message #9
      Sending Message #10

You may now want to check in the Windows Azure console that these 10 messages have arrived in subscription "sub1" of topic "testtopic".

To receive these 10 messages from the subscription "sub1" use "testtopic/subscriptions/sub1" as the destination name:

      ./starter ReceiverNonTransacted swiftmq.servicebus.windows.net 5671
                 testtopic/subscriptions/sub1 10 EXACTLY_ONCE false owner "<password>"

Output:

      Host        : swiftmq.servicebus.windows.net
      Port        : 5671
      Target      : testtopic/subscriptions/sub1
      Number Msgs : 10
      QoS         : EXACTLY_ONCE
      Auth as Anon: false
      User        : owner
      Password    : <password>

      Using SSL on port 5671
      Received: Message #1
      Received: Message #2
      Received: Message #3
      Received: Message #4
      Received: Message #5
      Received: Message #6
      Received: Message #7
      Received: Message #8
      Received: Message #9
      Received: Message #10

Subscription "sub1" on Service Bus should now be empty.