use of org.nustaq.fastcast.api.FCPublisher in project fast-cast by RuedigerMoeller.
the class ProgrammaticConfiguredPublisher method main.
public static void main(String[] arg) {
// 5 chars MAX !!
FastCast.getFastCast().setNodeId("PUB");
configureFastCast();
FCPublisher pub = FastCast.getFastCast().onTransport("default").publish(// unique-per-transport topic id
new PublisherConf(1).numPacketHistory(// how long packets are kept for retransmission requests
40_000).pps(// packets per second rate limit. So max traffic for topic = 5000*2500 = 12.5 MB/second
5000));
// could directly send raw on publisher
// while( ! pub.offer(..) ) { /* spin */ }
// or use a helper for fast-serialized messages
ObjectPublisher opub = new ObjectPublisher(pub);
RateMeasure measure = new RateMeasure("msg/s");
while (true) {
measure.count();
opub.sendObject(// all listeners should receive (by specifying a nodeId, a specific subscriber can be targeted)
null, // serializable object
"Hello " + System.currentTimeMillis(), // allow for 'batching' several messages into one (will create slight latency)
false);
}
}
Aggregations