Git Product home page Git Product logo

event-hubs-cli's Introduction

Introduction

Build

Event-Hubs-Cli

EVENTHUB_SEND_CONNSTR EVENTHUB_LISTEN_CONNSTR

to build it locally you can do:

make build-local-sender && make build-local-receiver

or just build by your own like:

#sender
go build -ldflags "-s -w" -o sender/bin/ehst sender/main.go

#receiver
go build -ldflags "-s -w" -o receiver/bin/erst receiver/main.go

Event Hub, event json structure

When you send a "message" to the event hub, you are sending an event and this event is a json like this:

{
    "Data": "my message comes here, can be a json{} or a byte array",
    "PartitionKey": null,
    "ID": "MyId",
    "SystemProperties": {
        "SequenceNumber": 1,
        "EnqueuedTime": "2020-02-13T12:54:57.642Z",
        "Offset": 21479629240,
        "PartitionID": null,
        "PartitionKey": null
    }
}

Properties is an optional field, and you can also add to enrich your event with metadata like this:

{
    "Data": "my message comes here, can be a json{} or a byte array",
    "PartitionKey": null,
    "Properties": {
        "property1": "15",
        "property2": "15",
        "property3": "15",
        ...
        ...
        ...
    },
    "ID": "MyId",
    "SystemProperties": {
        "SequenceNumber": 1,
        "EnqueuedTime": "2020-02-13T12:54:57.642Z",
        "Offset": 21479629240,
        "PartitionID": null,
        "PartitionKey": null
    }
}

You can use the sender (producer) command line to send messages (events) to the event hub with properties as well.

If you don't use Azure Events Hub yet, you can read more about it: Event Hubs About and Event Hubs Features.

Use cases

Sender (producer)

Receiver (consumer)

You can use this tool to start a listener (consumer) against Azure Event Hubs.

Straight to the point:

ehrt -c "<conn-string>" 

The command above uses the $Default consumer group. For development environment maybe will not be an issue. when the listener start, it will print the Data field from the event to the stdout.

In environments where you have many listeners, better if you use a specific consumer group to use this tool as debug to avoid disconnect others, you can use the command with -g flag to use your consumer group for debugging:

ehrt -g "debug-consumer" -c "<conn-string>" 

with a -v flag you can print out the whole Event struct (json)

ehrt -v -g "debug-consumer" -c "<conn-string>" 

If you desire to avoid print all incoming events, you can filter by the data field or properties field like this:

data filter:

ehrt -v -d "my message content filter" -g "debug-consumer" -c "<conn-string>"

property filter:

ehrt -v -p "property filter" -g "debug-consumer" -c "<conn-string>"

You can also provide more than one filter, just providing more than one -d or -p flag, like this:

ehrt -v -p "property filter1" -p "property filter2" -p "property filter3" -g "debug-consumer" -c "<conn-string>"

you can save all the output sending them to a file like this:

ehrt -v -g "<consumer-group>" -c "<conn-string>" > output.json

It will not generate a well formatted json, but each line of that file will be a valid json since you are using -v flag. With that file you can play alongside the sender (producer) to replay all the file content to an event hub you wish.

Write events to multiple json files using -s flag:

ehrt -v -s -f ${PWD}/ -p "<filter1>" -g "<consumer-group>" -c "<conn-string>"

The command above will generate a json file for each event arrived that match the property filter

event-hubs-cli's People

Contributors

fafg avatar the-mod avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

the-mod

event-hubs-cli's Issues

add tool to be used along side yaml files

setup sender and receiver into a unique command line which we could use yaml files to single execution, maybe is useful to integration tests on pipeline environment.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.