JasperFx 0.5.0


Next

Local Loopback Transport

Previous

Durable Messaging

TCP Transport Edit on GitHub


Note! This transport works by sending traffic directly via sockets and may not be acceptable in your IT department policies. We are pursuing the usage of JWT's to secure the traffic between applications using the socket based transports, see the GitHub issue

Lightweight, fire and forget

The TCP transport without durability is meant for scenarios where message delivery speed and throughput is important and guaranteed delivery is not required. We originally conceived this option as a .Net equivalent to ZeroMQ.

To set up a Jasper application to listen for incoming and outgoing messages through the TCP transport in the lightweight mode, see this example:


public class LightweightTransportApp : JasperRegistry
{
    public LightweightTransportApp()
    {
        // Set up a listener (this is optional)
        Transports.LightweightListenerAt(4000);

        // Or do the exact same thing by supplying a Uri
        Transports.ListenForMessagesFrom("tcp://localhost:4000");


        // Registering a subscription to Message1 that should be
        // delivered to a load balancer Uri at port 2200 and the "important"
        // queue
        Subscribe.To<Message1>().At("tcp://loadbalancer:2200/important");

        // Publish the message Message2 to the DNS entry "remoteserver"
        Publish.Message<Message2>().To("tcp://remoteserver:2201");
    }
}

In the case of a failure to send a message, the lightweight transport will retry to send the message a few times (3 is the default), but the message will be permanently discarded in about 10 seconds if it is unsuccessful. The lightweight transport is useful for control messages or messages that have a very limited value in terms of time. My shop uses this transport for frequent status update messages that are very quickly obsolete.

Durable TCP Messaging

First, see Durable Messaging about how message durability is enabled and functions within Jasper.

The TCP transport can be used durably as both listener or sender. To configure a durable TCP listener, use one of these options:


public class DurableTransportApp : JasperRegistry
{
    public DurableTransportApp()
    {
        // Set up a listener (this is optional)
        Transports.DurableListenerAt(2200);

        // Or, alternatively set up durable listening by Uri
        Transports.ListenForMessagesFrom("tcp://localhost:2200/durable");

        // Or, alternatively set up durable listening by Uri
        Transports.ListenForMessagesFrom("durable://localhost:2200");
    }
}

Note here that the Uri's durable://server:port and tcp://server:port/durable are considered as equivalents by Jasper.