Direct Publishers and Subscribers
Direct publishers and subscribers use direct memory access to achieve the fastest data transfer and lowest latency.
A publishing application writes data directly into memory that is accessible to subscribing applications. Subscribing applications read data directly from memory written by the publishing application.
The implementation minimizes or eliminates sources of latency.
The following table summarizes the differences between regular and direct publishers and subscribers. Subsequent topics contain greater detail.
Aspect | TIBCO FTL Publishers and Subscribers | Direct Publishers and Subscribers |
---|---|---|
Messages | Applications exchange message objects. | Applications exchange data in buffers. |
Structuring Data | Applications structure message objects using fields that contain typed data. | Applications structure data within buffers using an array of sizes. |
Copying Data | The library copies message data as needed. | The library eliminates copying data wherever possible. The sending application populates a data buffer, and receiving applications have direct access to that same data buffer. |
Memory Management | Applications can create and destroy publisher and subscriber objects.
The library and application programs can both create and destroy message objects. |
Applications create direct publisher and subscriber objects, but cannot reclaim their memory.
Application programs neither allocate data buffers, nor free them. |
Subscribers and Threads | Subscribers are thread-safe. | Applications must not use a direct subscriber in more than one thread. Instead, applications can create a separate direct subscriber for each thread. |
Delivery | The library distributes inbound messages through event queues. | Applications dispatch inbound data buffers directly to callback methods. |
Content Matchers | Applications can use content matchers to select a sub-stream of messages. | Applications receive the entire data stream. Selectivity based on data content is not available. |
API Language Support | The API supports multiple programming languages. | The API supports only the C language. |
Protection | The implementation protects against many common types of programming errors. | The implementation protects against fewer types of errors. For example, programmers must be careful to not overrun the length of data buffers, because the library does not guard against this error. |
Publishers | Many publishers can send through an endpoint. | A direct shared memory bus supports only one direct publisher object. |
Transport | Choose from a variety of transport types. | Only a direct shared memory transport can implement a direct publisher or subscriber endpoint. |
Persistence | Available. | The persistence feature does not support direct publishers and subscribers. |
- Use Cases for Direct Publishers and Subscribers
Direct publishers and subscribers are appropriate only in very specialized use cases in which a few nanoseconds of latency can make a critical difference. - Programming with Direct Publishers
Create a direct publisher object. Code a reserve-fill-send loop. Close the direct publisher and exit. - Programming with Direct Subscribers
Create a direct subscriber object. Code a callback method. Code a dispatch loop. Close the direct subscriber. - Multithreading with Direct Publishers and Subscribers
On hardware with multiple processor cores, multithreading can boost performance of applications that communicate using direct publishers and direct subscribers. You can use multithreading to implement a variety of communicating sub-applications within a single process, and to decrease context-switching latency as they communicate.
Copyright © Cloud Software Group, Inc. All rights reserved.