Skip to content

Latest commit

 

History

History
51 lines (34 loc) · 1.85 KB

contexts.md

File metadata and controls

51 lines (34 loc) · 1.85 KB

Contexts

You may have noticed that there are several different types of "context" classes in JeroMQ.

tl;dr: Which one do I use?

Use ZContext. It is the current state of the art for JeroMQ.

zmq.Ctx

Ctx, part of the zmq package, contains low-level implementation details of a ZeroMQ context.

It should not be used directly in code that uses the JeroMQ library.

org.zeromq.ZMQ.Context

ZMQ.Context was the first cut at a higher-level API for a ZeroMQ context.

Before destroying a ZMQ.Context, care must be taken to close any sockets and pollers that may have been created via the context. ZContext, by comparison, does this for you.

org.zeromq.ZContext

ZContext is an improvement over ZMQ.Context, lending itself to more concise, convenient, and safe usage.

ZContext implements the java.io.Closable interface, which makes it convenient to use in a try-with-resources statement. When a ZContext is closed, resources such as sockets and pollers are cleaned up automatically.

See also