Chapter 15. Remote Invoker

15.1. SwitchYard Remote Invoker

The RemoteInvoker serves as a remote invocation client for SwitchYard services. It allows non-SwitchYard applications to invoke any service in SwitchYard which uses a <> binding. It is also used by the internal clustering channel to facilitate intra-cluster communication between instances.

15.2. Use a RemoteInvoker

Procedure 15.1. Task

  • Include a RemoteInvoker and supporting classes in your application with the following Maven dependency:
       <version> <!-- SY version goes here (e.g. 1.0) --> </version>
Each instance of SwitchYard includes a special context path called switchyard-remote, which is bound to the default HTTP listener in Red Hat JBoss Fuse Service Works. The initial version of RemoteInvoker supports communication with this endpoint directly. Here is an example of invoking an in-out service in SwitchYard using the HttpInvoker:
public class MyClient {
    public static void main(String[] args) throws Exception {
        RemoteInvoker invoker = new HttpInvoker("http://localhost:8080/switchyard-remote");
        Offer offer = new Offer();
        RemoteMessage msg = invoker.invoke(new RemoteMessage()
            .setContext(new DefaultContext())
            .setService(new QName("urn:com.example.switchyard:remote", "Dealer"))
        Deal deal = (Deal)msg.getContent();
        System.out.println("It's a deal? " + deal.isAccepted());