Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
class SocketThreadLocal extends ThreadLocal<ZMQ.Socket>
static final Logger log = Logger.getLogger(SocketThreadLocal.class);
private ZMQ.Context ctx;
private MQConfig config;
SocketThreadLocal(ZMQ.Context ctx, MQConfig config)
this.ctx = ctx;
this.config = config;
protected ZMQ.Socket initialValue() {
ZMQ.Socket socket = config.applyToSocket(ctx.socket(ZMQ.PUSH));
for (String host : config.hosts.split(",")) {
return socket;
public class MQCache implements MessageCache
static final Logger log = Logger.getLogger(MQCache.class);
private SocketThreadLocal local;
private Boolean block;
public MQCache(ZMQ.Context ctx, MQConfig config)
this.local = new SocketThreadLocal(ctx, config);
this.block = config.sendBlocking;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.