Service
Purpose¶
List and perform request/response exchanges with deployed Platform 6 services.
Methods¶
Binding name: service
Common Message Maps
The Common Message is the single unit of exchange between Platform 6 service. The common message is represent by a Groovy Map when using the service DSL:
def cm = [ headers: [ hello: 'world", 'platform6.request.user': 'admin' ], attachments: [ [ headers: [ name: 'body", type: 'text/plain' ], bytes: 'This is the content of the attachment'.getBytes() ] ] ]
headers
Map and an attachments
List. The attachments List can contain a headers
Map and a bytes
content.
Both headers
and attachments
are optional.
Method: void post(String destination, Map cmMap)
Sends the provided common message to the named service destination endpoint. This method is fire and forget. I.e. It does not wait for a response.
Method: Map request(String destination, Map cmMap)
Sends the provided common message to the named service destination endpoint and waits indefinitely for a response which is returned as a Map.
Method: Map request(String destination, Map cmMap, long timeOut, TimeUnit tu)
Sends the provided common message to the named service destination endpoint and waiting for up to timeOut
time units for a response. Any response is returned as a Map.
Method: void request(String destination, Map cmMap, Closure cb)
Sends the provided common message to the named service destination endpoint and waits indefinitely for a response which is returned as a Map via the supplied asynchronous callback.
The Callback will receive one of two parameters in the following order (CommonMessageMap
, Exception
).
Method: List list()
Returns a List of all deployed Platform 6 services attached to the common message bus represented as destination names.
Examples¶
def lst = service.list() println lst
service.post("platform6.echo", cm)
def cmResponse = service.request("platform6.echo", cm) println cmResponse
import java.util.concurrent.TimeUnit def cmResponse = service.request("platform6.scripts", cm, 5, TimeUnit.SECONDS) println cmResponse
service.request("platform6.scripts", cm, { cmr, e -> println cmr if( null != e) throw e }) sleep 2000
For more information, please refer to the Common Message Bus API Guide.