Fabric3 supports low-latency, high performance communications between clients and services and producers and consumers (Pub/Sub) via a binding built on the ZeroMQ Library. The following messaging patterns are supported:
- Non-blocking (asynchronous) queue-based messaging
- Non-blocking (asynchronous) queue-based messaging with callbacks
- Request-reply messaging
It is generally recommended to use non-blocking message patterns for better performance.
Configuring a Service and Reference Binding
Wiring a reference to a service using the ZeroMQ is done as follows:
<component name="TestServiceClient"> <f3:junit class="org.fabric3.binding.zeromq.test.service.TestServiceClient"/> <reference name="testService"> <f3:binding.zeromq target="TestService"/> </reference> </component> <component name="TestService"> <implementation.java class="org.fabric3.binding.zeromq.test.service.TestServiceImpl"/> <service name="TestService"> <f3:binding.zeromq/> </service> </component>
In the above example, if TestService
uses non-blocking operations (i.e. uses operations annotated with @OneWay
), a ZeroMQ PUSH/PULL socket will be established between the reference and service. If the operations are blocking, XREQ/XREP will be used instead.
Cluster Operation
Note that the binding configuration in the previous figure did not specify an IP address and port combination to connect/bind to. If one is not specified, Fabric3 will allocate a port from the block reserved for each runtime. Addressing information will then be propagated by Fabric3 to required runtimes in the domain. For example, if TestServiceClient
is hosted on a different machine than TestService
, Fabric3 will transparently propagate the latter's address so that TestServiceClient
can connect to the service.
Further, if TestService
is deployed to a clustered zone, all endpoint addresses will be propagated to TestServiceClient
, which in turn will round-robin requests to cluster instances.
Add Comment