Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Microservices With Go Micro and NATS.io

DZone's Guide to

Microservices With Go Micro and NATS.io

Oren Golan published an excellent piece on his blog this past weekend sharing an example of how Micro and NATS are providing microservices for financial modeling and Bitcoin visualization.

· Integration Zone
Free Resource

Modernize your application architectures with microservices and APIs with best practices from this free virtual summit series. Brought to you in partnership with CA Technologies.

Readers of DZone may already be quite familiar with NATS. Many excellent articles from developers using NATS for everything ranging from microservices messaging to IoT and cloud-native deployments have been published on Dzone. 

Specific examples are very helpful, and Oren Golan published an excellent piece on his blog this past weekend sharing an example of how Micro and NATS are providing microservices for financial modeling and Bitcoin visualization in a project John Nguyen is working on. You can read Oren's post below -- I've also added a few useful links on Micro at the end:

--

Image title

Micro is a set of utilities and libraries that makes it easier to write and manage microservices. It was written and maintained by Asim Aslam, a developer from London who is getting help from an enthusiastic community.

A microservice written for Micro can be written in any language, but it's easier to write it in Go (until ports of Micro will be available in other languages). For non-Go microservices, there exists the Sidecar (an HTTP proxy into the microservice) to handle this situation.

Microservices often typically communicate with JSON but micro uses protobuf encoding by default. Protobufs offer solid serialization capabilities, static types, and can be used to also declare the API of a specific microservice.

By default, the messages are sent over HTTP, but a message broker (RabbitMQ, Kafka, NSQ, etc.) can allow improvements on top of this such as persistence, scalability, or reliability. In this case, we use NATS since it's very simple, fast, and lean. It also has enough functionality to act as transport, broker and registry (the latter due to its broadcast queries). More information can be found at Asim's blogpost.

John Nguyen, an Australian developer, uses Micro to collect and visualize financial instruments (Bitcoin and foreign exchange). I asked him to demo his setup and we recorded it in a 30-minute video:


Agenda

  • 0:00 Overview of Micro and NATS
  • 8:00 Demo
  • 16:17 Publishing a message to NATS
  • 23:50 Code of a publisher and a subscriber
  • 27:44 protobuf
  • 29:03 Python subscriber
  • 31:31 Persistance with project STAN

--

Additional links:

  • Micro on NATS: Microservices with Messaging - from a talk at NATS.io meetup by Micro creator Asim Aslam.

  • Micro on NATS: Blog post by Asim Aslam detailing how/why Micro uses NATS.

The Integration Zone is proudly sponsored by CA Technologies. Learn from expert microservices and API presentations at the Modernizing Application Architectures Virtual Summit Series.

Topics:
golang ,nats ,micro ,bitcoin ,microservices ,messaging protocol ,messaging queue ,messaging middleware

Published at DZone with permission of Brian Flannery. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}