Hacker News new | ask | show | jobs
by stickfigure 1544 days ago
You could make a new guice module for the message broker, but you don't have to. If you want to use a message broker, just bind the service object as an eager singleton in your application module.

The main reason to make a separate guice module for the message broker is if setup requires a lot of boilerplate. You can put it all in a common jar artifact and include that in different services. But that's overkill if you just have one service, or if the broker has a fairly friendly interface to start with.

Guice is just a little bit of structure to bind together Normal Java Code. You don't need to wrap services or do things eg "the spring way". Just use the service; if you find yourself repeating code, consider abstracting it into a separate module.