Skip to content
/ sendit Public

A CLI tool for sending messages to different brokers

License

Notifications You must be signed in to change notification settings

willdot/sendit

Repository files navigation

Sendit ✉️

A CLI tool for sending message(s) to different message brokers using bodies and headers from a file.

Use cases 🤔

  1. You want to send 100 messages to see how your services that consume the messages handle them. Perhaps you want to test idempotency or just see how your service handles the load.

  2. You want to see how your service handles a specific message body or header really quickly without having to find where you have tests written that you can copy / alter.

  3. You have a really complex microservice setup and you want to trigger some behaviour from a message, but don't want to go through the hassle of setting other things up to do it "the right way". (For example a cache is cleared somewhere when a message is consumed)

These are just examples of when I've wanted a tool that could do this.

Installation 🛠️

go install github.com/willdot/sendit@latest

Useage 🧭

Basic useage. See different broker sections for broker specific details.

sendit -body="body.json" -headers="headers.json" -url="localhost:1234" -repeat=3
  • body (required) - the path to a file containing the data you wish to send as the body of the message
  • headers(optional) - the path to a file containing the headers you wish to send with the message (each broker has it's own specification for how they should be provided)
  • url(optional) - the url of the server to send the message to (each broker has a default which is the default for using locally)
  • repeat(optional) - the number of time you wish to send the message (default is 1)

RabbitMQ

You can either send directly to a queue OR to an exchange. You will be asked to select which option when you run the tool.

sendit -body="body.json" -destination="test"
  • destination(required) - the name of the queue or exchange to send the message to.

Headers should be in JSON format in a key / value format. eg:

{
    "header1" : "value1",
    "header2" : "value2"
}

NATs

sendit -body="body.json" -subject="test"
  • subject(required) - the subject you wish to use for the message

Headers should be in JSON format in a key / array string format. eg:

{
    "header1" : ["value1", "value2"],
    "header2" : ["value3"]
}

Redis

sendit -body="body.json" -channel="test"
  • channel(required) - the channel you wish to publish the message to

Note: Redis does not support headers.

Google Pub/Sub

sendit -body="body.json" -topic="test-topic" -project_id="your-project-id" -disable_auth=true -url="localhost:8085"
  • topic(required) - the topic you wish to send the message to
  • project_id (required) - the ID of the project to use
  • disable_auth (optional) - use this if you are testing with a local emulator
  • url (optional) - use this to override the default for Google Cloud Services.

Headers should be in JSON format in a key / string format. eg:

{
    "header1" : "value1",
    "header2" : "value3"
}

Note: If you are using a local emulator, you will need to export the following:

PUBSUB_EMULATOR_HOST=localhost:8085

Contributing 🤝

Issues and PRs welcome.

To run the tests you will need to run docker-compose up to get the message broker servers running.

About

A CLI tool for sending messages to different brokers

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages