Java Magazine, Mar/Apr 2018
ORACLE COM JAVAMAGAZINE MARCH APRIL 2018 58 microservices and containers class MyStringCommand extends Command with Discoverable The Command is then ready to receive from other Services on which it must act With the setup complete you are clear to start sending messages to your new MyStringCommand The CommandHelper and its extension the DiscoverableCommandExecution from the Wookiee Zookeeper Component enable you to make calls to remote and local Commands respectively class MyStringCommandCaller extends Actor with DiscoverableCommandExecution executeCommand MyStringCommand bean executeRemoteCommand other service path MyStringCommand bean In addition Commands themselves are accessible through HTTP or WebSockets using one of the premade Components that support HTTP Colossus Akka HTTP Spray and Socko are currently supported Using supported premade Components is usually as easy as adding one more layer of inheritance onto your class and specifying the endpoint that the Command should match In the following example you would be able to reach the execute method of the MyHttpAccessibleGetCommand by sending an HTTP request to your Service on the endpoint to match over http path class MyHttpAccessibleGetCommand extends Command with AkkaHttpGet override def path String endpoint to match over http Using a Service with Commands is a great way to connect your microservices Commands take advantage of the flexibility of Akka Actors to route requests and messages cluster wide and they are usually the external point of entry for any processing on the Service
You must have JavaScript enabled to view digital editions.