Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Wiring a reference to a service using the ZeroMQ is done as follows in Java:

Code Block
languagejava
public class Client ...{
 
	@ZeroMQ(target="ZMQService")
	protected Service service;
 
	public void invoke(){
		service.invoke("message");
	}
}

@ZeroMQ(service="ZMQService")
public class ServiceImpl implements Service {

	public void invoke(String message){
		//....
	}
}

Or in XML as follows:

Code Block
languagejava
<component name="TestServiceClientClient">
   <f3:junit<implementation.java class="org.fabric3.binding.zeromq.testclient.service.TestServiceClientClient"/>
   <reference name="testServiceservice">
       <f3:binding.zeromq target="TestServiceZMQService"/>
   </reference>
</component>

 
<component name="TestServiceZMQService">
   <implementation.java class="org.fabric3.binding.zeromq.test.service.TestServiceImplServiceImpl"/>
   <service name="TestServiceZMQService">
      <f3:binding.zeromq/>
   </service>
</component>

In the above example, if TestService Service 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.

...

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 Client is hosted on a different machine than TestService Service, Fabric3 will transparently propagate the latter's address so that TestServiceClient Client can connect to the service.

...

Further, if TestService is deployed to a clustered zone, all endpoint addresses will be propagated to TestServiceClient Client, which in turn will round-robin requests to cluster instances.

...