Skip to content

A starter project for using Go with RabbitMQ, which can publish and subscribe to and read from queues over HTTP using JSON.

Notifications You must be signed in to change notification settings

abrunner94/go-rabbitmq-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RabbitMQ Messaging using HTTP

Instructions

In order to run the messaging service, make sure you have Docker installed. This is required for our RabbitMQ instance, which is used by the messaging service.

In the root directory of the project, run the following:

rabbit-messaging $   export GO111MODULE=on
rabbit-messaging $   make

This command builds Go executables for Mac, Linux and Windows environments. Build the RabbitMQ Docker image:

rabbit-messaging $   docker build -t rabbit_rabbit .

Run the Docker container:

rabbit-messaging $   docker run -it -h guest -e RABBITMQ_DEFAULT_USER=guest -e RABBITMQ_DEFAULT_PASS=guest -p 15672:15672 -p 5671:5671 -p 5672:5672 -p 15671:15671 -p 25672:25672 -p 1883:1883  -v /tmp/rabbitmq:/var/lib/rabbitmq rabbit_rabbit

Run the Go executable:

rabbit-messaging $  ./rabbit_msg_v1.0.0-mac

Test the server:

rabbit-messaging  $ curl -XPOST -d '{"username": "alex", "message": "an example message"}' http://localhost:12312/hello-channel1/messages

{"id":"2019-08-18T15:07:14.716023-07:00"}
rabbit-messaging  $ curl -GET http://localhost:12312/hello-channel1/messages

{
    "messages":
    [
        {"username":"test1","message":"test1 message","id":"2019-08-18T14:53:46.127964-07:00"},

        ...

        {"username":"alex","message":"an example message","id":"2019-08-18T15:07:14.716023-07:00"}
    ]
}
rabbit-messaging  $ curl -GET http://localhost:12312/hello-channel1/messages?last_id=2019-08-18T14:55:53.859255-07:00

{
    "messages":
    [
        {"username":"regex5","message":"regex test5","id":"2019-08-18T14:55:53.859255-07:00"},

        {"username":"alex","message":"an example message","id":"2019-08-18T15:07:14.716023-07:00"}
    ]
}

Technologies

  • Go 1.12
  • Docker
  • RabbitMQ

About

A starter project for using Go with RabbitMQ, which can publish and subscribe to and read from queues over HTTP using JSON.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published