Contact Us 1-800-596-4880

UDP Transport Reference

Universal Datagram Protocol, or UDP, is a stateless protocol for sending or receiving large numbers of messages (datagrams) quickly. The UDP transport in Mule allow sending messages to or receiving messages with Mule using UDP sockets.

Transport Info

Transport Doc Inbound Outbound Request Transactions Streaming Retries MEPs Default MEP Maven Artifact

UDP

JavaDoc
SchemaDoc

check

check

check

error

check

error

one-way, request-response

request-response

org.mule.transport:mule-transport-udp

Namespace and Syntax

XML namespace:

XML Schema location:

Connector syntax:

Endpoint syntax:
You can define your endpoints 2 different ways:

  1. Prefixed endpoint:

  2. Non-prefixed URI:

See the sections below for more information.

Considerations

UDP is one of the standard communication protocols used on the Internet, and supports communication both across the internet and within a local area network. The Mule UDP module uses native Java socket support, adding no communication overhead to the classes in java.net, while allowing many of the advanced features of UDP programming to be specified in the Mule configuration rather than coded in Java.

Use this transport when communicating using low-level UDP datagrams. UDP is designed to maximize speed and scale over reliability, ordering or data integrity. UDP datagrams are not guaranteed to arrive with any particular speed, or at all, and they may arrive in a different order than they are sent in. If any of these guarantees are important to your application, use a different transport, such as TCP.

Note, UDP provides no error checking, so you may want to perform additional validation or error handling in your application, if it is important.

As shown in the examples below, use the UDP transport to:

  • Send messages to a UDP socket

  • Read messages from a UDP socket

Features

The UDP module allows a Mule application both to send and receive UDP datagrams, and to declaratively customize the following features of UDP (with the standard name for each feature, where applicable):

  • The timeout for sending or receiving messages (SO_TIMEOUT).

  • Whether to allow sending broadcast messages (SO_BROADCAST).

  • Whether to close a socket after sending a message.

  • The maximum size of messages that can be received.

Use UDP endpoints to:

  • Receive a UDP datagram and create an inbound UDP endpoint.

  • Send a UDP datagram and create an outbound UDP endpoint.

Usage

To use UDP endpoints:

  1. Add the MULE UDP namespace to your configuration:

    • Define the udp prefix using xmlns:udp="http://www.mulesoft.org/schema/mule/udp"

    • Define the schema location with http://www.mulesoft.org/schema/mule/udp

      http://www.mulesoft.org/schema/mule/udp/3.4/mule-udp.xsd

  2. Define one or more connectors for UDP endpoints.

    • Create a UDP connector:

  3. Create UDP endpoints.

    • Datagrams are received on inbound endpoints. The bytes in the datagram become the message payload.

    • Datagrams are sent to outbound endpoints. The bytes in the message payload become the datagram.

    • Both kinds of endpoints are identified by a host name and a port.

Note: UDP endpoints are always one-way.

Example Configurations

Copy datagrams from one port to another

The connector at ❶ uses all default properties. The inbound endpoint at ❷ receives datagrams and copies them to the outbound endpoint at ❸.

Configuration Options

UDP Connector attributes

Name Description Default

broadcast

Set to true to allow sending to broadcast ports.

false

keepSendSocketOpen

Whether to keep the the socket open after sending a message.

false

receiveBufferSize

This is the size of the largest (in bytes) datagram that can be received.

16 Kbytes

sendBufferSize

The size of the network send buffer.

16 Kbytes

timeout

The timeout for both sending and receiving.

system default

Configuration Reference

Element Listing

UDP Transport

The UDP transport enables events to be sent and received as Datagram packets.

Connector

Attributes of <connector…​>

Name Type Required Default Description

receiveBufferSize

integer

no

The size of the receiving buffer for the socket.

timeout

long

no

The amount of time after which a Send or Receive call will time out.

sendBufferSize

integer

no

The size of the sending buffer for the socket.

broadcast

boolean

no

Whether to enable the socket to send broadcast data.

keepSendSocketOpen

boolean

no

Whether to keep the Sending socket open.

Child Elements of <connector…​>

Name Cardinality Description

Inbound endpoint

Attributes of <inbound-endpoint…​>

Name Type Required Default Description

host

string

no

port

port number

no

Child Elements of <inbound-endpoint…​>

Name Cardinality Description

Outbound endpoint

Attributes of <outbound-endpoint…​>

Name Type Required Default Description

host

string

no

port

port number

no

Child Elements of <outbound-endpoint…​>

Name Cardinality Description

Endpoint

Attributes of <endpoint…​>

Name Type Required Default Description

host

string

no

port

port number

no

Child Elements of <endpoint…​>

Name Cardinality Description

Schema

Namespace "http://www.mulesoft.org/schema/mule/udp"

Targeting Schemas (1):

Targeting Components:

4 global elements, 4 Complex Type Summary, 1 attribute group

Schema Summary

The UDP transport enables events to be sent and received as Datagram packets.

Target Namespace:

http://www.mulesoft.org/schema/mule/udp

Defined Components:

Default Namespace-Qualified Form:

Local Elements: qualified; Local Attributes: unqualified

Schema Location:

+http://www.mulesoft.org/schema/mule/udp/3.3/mule-udp.xsd

Imports Schemas (3):

Imported by Schemas (2):

_mule-all-included.xsd, mule-multicast.xsd

All Element Summary

Type:

Content:

complex, 9 attributes, attr. wildcard, 6 elements

Subst.Gr:

may substitute for element mule:abstract-connector

Defined:

globally in mule-udp.xsd; see XML source

Used:

never

Type:

Content:

complex, 13 attributes, attr. wildcard, 16 elements

Subst.Gr:

may substitute for element mule:abstract-global-endpoint

Defined:

globally in mule-udp.xsd; see XML source

Used:

never

Type:

Content:

complex, 13 attributes, attr. wildcard, 16 elements

Subst.Gr:

may substitute for element mule:abstract-inbound-endpoint

Defined:

globally in mule-udp.xsd; see XML source

Used:

never

Type:

Content:

complex, 13 attributes, attr. wildcard, 16 elements

Subst.Gr:

may substitute for element mule:abstract-outbound-endpoint

Defined:

globally in mule-udp.xsd; see XML source

Used:

never

Complex Type Summary

Content:

complex, 13 attributes, attr. wildcard, 16 elements

Defined:

globally in mule-udp.xsd; see XML source

Used:

at 1 location

Content:

complex, 13 attributes, attr. wildcard, 16 elements

Defined:

globally in mule-udp.xsd; see XML source

Used:

at 1 location

Content:

complex, 13 attributes, attr. wildcard, 16 elements

Defined:

globally in mule-udp.xsd; see XML source

Used:

at 1 location

Content:

complex, 9 attributes, attr. wildcard, 6 elements

Defined:

globally in mule-udp.xsd; see XML source

Includes:

definitions of 5 attributes

Used:

at 2 locations

Attribute Group Summary

Content:

Defined:

globally in mule-udp.xsd; see XML source

Includes:

definitions of 2 attributes

Used:

at 3 locations


XML schema documentation generated with DocFlex/XML RE 1.8.5 using DocFlex/XML XSDDoc 2.5.0 template set. All content model diagrams generated by Altova XMLSpy via DocFlex/XML XMLSpy Integration.

Javadoc API Reference

The Javadoc for this module can be found here:

UDP

Maven

The UDP Module can be included with the following dependency:

<dependency>
  <groupId>org.mule.transports</groupId>
  <artifactId>mule-transport-udp</artifactId>
  <version>3.4.1</version>
</dependency>

Notes

Before Mule 3.1.1, there were two different attributes for setting timeout on UDP connectors, sendTimeout and receiveTimeout. It was necessary to set them to the same value.