How to write data to Event Hub via JMS and read via Storm on Azure

autor: One Code
Ostatnia aktualizacja: 2017-01-23
Edytuj w witrynie GitHub


An example of how to write data to Event Hub via JMS and read using Apache Storm topology (written in Java) on Azure.


Azure EventHubs

Azure subscription with one event hub created under service bus namespace.


Java development environment, such as Eclipse and Maven, with JDK 8.

  • JDK 8:

  • Eclipse:

  • Maven:

Required information

An Azure Event Hub with two shared access policies; one that has listen permissions, and one that has write permissions. I will refer to these as "reader" and "writer", which is what I named mine

  • The policy keys for the "reader" and "writer" policies

  • The name of your Event Hub

  • The Service Bus namespace that your Event Hub was created in

  • The number of partitions available with your Event Hub configuration

For information on creating and using EventHubs, see the Create an Event Hub section of Get Started with EventHubs.

Building the Sample

In Eclipse, install Azure Toolkit for Eclipse plugin

Import the two projects into Eclipse

SenderViaJMS is a Java project. ReciverViaStorm is a Maven project.

Configure SenderViaJMS

Add library “Apache Qpid Client Libraries for JMS” into this project’s Java Build Path. The library will be automatically installed when installing Azure Toolkit for Eclipse.

open file and change below content to your actual value.

  • SASPolicyName: previous created “writer” policy name

  • SASPolicyKey: previous created “writer” policy key with URL encoded. URL encode tool:

  • Eventhub name: previous created event hub name

Configure ReceiverViaStorm

Open file and change below content to your actual value:

  • eventhubspout.username={eventhub sas policy name}

  • eventhubspout.password={eventhub sas policy key}

  • eventhubspout.namespace={service bus namespace that eventhub was created in}

  • eventhubspout.entitypath={eventhub name}

  • eventhubspout.partitions.count={eventhub partitions count}

Running the Sample

In Eclipse, run LogTopology class of ReceiverViaStorm to get it start for all partitions.

Run SenderViaJMS to send messages, then you will see events appear on receiver window.