DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Design and Implementation of Cloud-Native Microservice Architectures for Scalable Insurance Analytics Platforms
  • Design and Implementation of Cloud-Native Microservice Architectures for Scalable Insurance Analytics Platforms
  • Top Load Balancing Algorithms: Choosing the Right Strategy
  • Stop Building Monolithic AI Brains, Build a Specialist Team Instead

Trending

  • The ORM Is Over: AI-Written SQL Is the New Data Access Layer
  • How to Test a PATCH API Request With REST-Assured Java
  • Smart Deployment Strategies for Modern Applications
  • S3 Vectors: How to Build a RAG Without a Vector Database
  1. DZone
  2. Data Engineering
  3. Data
  4. Microservices With Go Micro and NATS.io

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.

By 
Brian Flannery user avatar
Brian Flannery
·
Jun. 30, 16 · Opinion
Likes (2)
Comment
Save
Tweet
Share
9.5K Views

Join the DZone community and get the full member experience.

Join For Free

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

Links

  • Micro - tools for managing microservices
  • Go Micro - libraries for writing microservices
  • Git repo of this demo
  • Recorded presentation by Asim at the Go London User Group
  • Go kit - an alternative framework for managing microservices

--

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.

microservice

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

Opinions expressed by DZone contributors are their own.

Related

  • Design and Implementation of Cloud-Native Microservice Architectures for Scalable Insurance Analytics Platforms
  • Design and Implementation of Cloud-Native Microservice Architectures for Scalable Insurance Analytics Platforms
  • Top Load Balancing Algorithms: Choosing the Right Strategy
  • Stop Building Monolithic AI Brains, Build a Specialist Team Instead

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook