# Binary

The DataSource Binary data type is the recommended way to deliver Binary data to front end applications.

## Requirements

To use the Binary data type, your Caplin components and libraries must be at least as recent as the versions listed in the table below:

**Product versions supporting the Binary data type**

| Product | Minimum Version |
| --- | --- |
| C DataSource API | 8.0.12 |
| Java DataSource API | 8.0.11 |
| .NET DataSource API | 8.0.12 |
| Liberator | 8.0.15 |
| Transformer | 8.0.8 |
| StreamLink Java | 8.0.7 |
| StreamLink JS | 8.0.7 |
| StreamLink .NET | 8.0.7 |

## Overview

With the introduction of the Binary data type, the Caplin Platform now provides first class support for transporting Binary data.

* The Caplin Platform uses the [open-vcdiff](https://github.com/google/open-vcdiff) library to describe an update in terms of a Binary patch.
* The .NET and Java DSDK caching publishers can send binary messages published by the application as either image or patch packets to subscribing peers.
* Liberator and Transformer can receive and apply a Binary patch to a cached Binary object.
* StreamLink clients can receive Binary patches and apply them to a native object.

## Features

The Binary data type has the following advantages over transporting Binary in a record field:

* [DataSource: Optimal choice of Binary message type between peers](#datasource-optimal-choice-of-binary-message-type-between-peers)
* [Liberator: Chunked streaming of large Binary messages over RTTP](#liberator-chunked-streaming-of-large-binary-messages-over-rttp)

### DataSource: Optimal choice of Binary message type between peers

For Binary messages, the .NET DataSource API’s [`ICachingPublisher`](https://docs.caplin.com/developer/api/datasource_dotnet/latest/interfaceCaplin_1_1DataSource_1_1Publisher_1_1ICachingPublisher.html) and the Java DataSource API’s [`CachingPublisher`](https://docs.caplin.com/developer/api/datasource_java/latest/com/caplin/datasource/publisher/CachingPublisher.html) work out the difference between the new cache contents and the current cache contents ( i.e. the patch ) and send a packet with smaller of the 2, i.e. either an image packet with the current cache contents or an update packet with the patch.

### Liberator: Chunked streaming of large Binary messages over RTTP

Liberator streams a Binary message to a client in chunks, which prevents a large Binary message from delaying the delivery of smaller, high-frequency messages such as price updates.

The rate at which Liberator adds a Binary message’s chunks to an outbound queue is bandwidth adaptive. Adding chunks to an outbound queue faster than the queue is moving would be counter-productive and provide fewer opportunities for other messages to be queued between the chunks. Liberator queues a chunk only if at least a chunk-sized amount of data has been sent to the client since the previous chunk was queued.

The size of the chunks delivered can be configured by using the [`binary-yield-size`](../liberator/liberator-tuning-configuration.md#binary-yield-size) configuration item to tune your Liberator’s performance.

## StreamLink API support

The StreamLink API provides the following interfaces to support the Binary data type:

* [BinaryEvent](https://docs.caplin.com/developer/api/streamlinkjs/latest/classes/BinaryEvent.html) interface

For example code, see [Subscribing to a Binary subject](../streamlink/streamlink-subscribing-to-binary.md).

## Java DataSource API support

The Java DataSource API provides the following interfaces and methods to support the Binary data type:

* [`CachingPublisher`](https://docs.caplin.com/developer/api/datasource_java/latest/com/caplin/datasource/publisher/CachingPublisher.html) interface
* [`BinaryMessage`](https://docs.caplin.com/developer/api/datasource_java/latest/com/caplin/datasource/messaging/binary/BinaryMessage.html) interface

For example code, see [Publishing a Binary subject from a Java Adapter](datasource-publishing-binary-subject.md).

## .NET DataSource API support

The .NET DataSource API provides the following interfaces and methods to support the Binary data type:

* [`ICachingPublisher`](https://docs.caplin.com/developer/api/datasource_dotnet/latest/interfaceCaplin_1_1DataSource_1_1Publisher_1_1ICachingPublisher.html) interface
* [`IBinaryMessage`](https://docs.caplin.com/developer/api/datasource_dotnet/latest/interfaceCaplin_1_1DataSource_1_1Messaging_1_1Binary_1_1IBinaryMessage.html) interface

For example code, see [Publishing a Binary subject from a .NET Adapter](datasource-dotnet-publishing-binary-subject.md).

---

**See also**:

* [Publishing a Binary subject from a Java Adapter](datasource-publishing-binary-subject.md)
* [Publishing a Binary subject from a .NET Adapter](datasource-dotnet-publishing-binary-subject.md)
* [Subscribing to a Binary subject](../streamlink/streamlink-subscribing-to-binary.md)
