UDP Transport - 6.3

Talend ESB Service Developer Guide

EnrichVersion
6.3
EnrichProdName
Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
task
Design and Development
Installation and Upgrade
EnrichPlatform
Talend ESB

CXF provides a transport plugin to support transporting small (under about 60K) message payloads over UDP. It supports both unicast and multicast packet transfers. To use the UDP transport, you just need to include the cxf-rt-transports-udp module on the classpath and use a "udp://host:port" style URL for the address:

JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
factory.setBus(getStaticBus());
factory.setAddress("udp://localhost:8888");
factory.setServiceBean(new GreeterImpl());
server = factory.create();

That will start the server on localhost UDP port 8888. You can also omit the hostname (udp://:8888) to bind to all the addresses or use one of the multicast addresses (example: udp://239.255.255.250:3702) to respond to the appropriate broadcasts.

For client configuration, similar to the server side, you just need to use the appropriate UDP url in order for the client to use UDP. If the hostname is specified in the URL, the Datagram will be sent directly to the host:port. If the hostname is not specified, the Datagram will be sent as a broadcast to the specific port. If the hostname is a multicast address, the Datagram will be sent Multicast to the given port.

UDP is different than the other CXF transports in that it allows multiple responses to be received for a single request. For example, if you send out a request via a multicast or broadcast, several servers could respond to that request. The basic JAX-WS generated interfaces only allow a single response to be returned to the application. However, if you use the JAX-WS Asynchronous methods, you can have CXF call the AsyncHandler for each response. To enable this, set the request property "udp.multi.response.timeout" to a timeout value greater than 0. CXF will wait that long for responses to come in before returning back to the application.

// wait 3 seconds for responses
((BindingProvider)proxy).getRequestContext().put(
   "udp.multi.response.timeout", 3000);
proxy.greetMeAsync("World", new AsyncHandler<String>() {
   public void handleResponse(Response<Object> res) {
      System.out.println(res.get());
   }
});

The CXF SOAP binding supports the use of the SOAP over UDP specification URL's for transporting SOAP messages over UDP. Just using "soap.udp" as the scheme part of the UDP URL (instead of just "udp") will enable the SOAP over UDP support. The main difference between using the pure UDP CXF transport and the SOAP over UDP support is that SOAP over UDP requires the use of WS-Addressing headers whereas the pure CXF UDP transport does not. The WS-Addressing header can add significant size to the SOAP messages. With UDP limiting the size of the packets to under 64K, that can be significant.