public class ZeroMqProxy extends Object implements InitializingBean, SmartLifecycle, BeanNameAware, DisposableBean
The ZeroMqProxy.Type dictates which pair of ZeroMQ sockets to bind with this proxy
to implement any possible patterns for ZeroMQ intermediary. Defaults to @link ZeroMqProxy.Type.PULL_PUSH.
The control socket is exposed as a SocketType.PAIR with an inter-thread transport
on the "inproc://" + beanName + ".control" address; it can be obtained via getControlAddress().
Should be used with the same application from SocketType.PAIR socket to send
ZMQ.PROXY_TERMINATE, ZMQ.PROXY_PAUSE and/or ZMQ.PROXY_RESUME commands.
If the proxy cannot be started for some reason, an error message is logged and this component is left in the non-started state.
With an exposeCaptureSocket option, an additional capture data socket is bound to inter-thread transport
as a SocketType.PUB. There is no specific topic selection, so all the subscribers to this socket
must subscribe with plain ZMQ.SUBSCRIPTION_ALL.
The address for this socket is "inproc://" + beanName + ".capture".
ZMQ.proxy(ZMQ.Socket, ZMQ.Socket, ZMQ.Socket)| Modifier and Type | Class and Description |
|---|---|
static class |
ZeroMqProxy.Type |
DEFAULT_PHASE| Constructor and Description |
|---|
ZeroMqProxy(org.zeromq.ZContext context)
Create a
ZeroMqProxy instance based on the provided ZContext
and ZeroMqProxy.Type.PULL_PUSH as default mode. |
ZeroMqProxy(org.zeromq.ZContext context,
ZeroMqProxy.Type type)
|
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
void |
destroy() |
int |
getBackendPort()
Return the port a backend socket is bound or null if this proxy has not been started yet.
|
String |
getCaptureAddress()
Return the address an
inproc capture socket is bound or null if this proxy has not been started yet
or captureAddress is false. |
String |
getControlAddress()
Return the address an
inproc control socket is bound or null if this proxy has not been started yet. |
int |
getFrontendPort()
Return the port a frontend socket is bound or 0 if this proxy has not been started yet.
|
int |
getPhase() |
ZeroMqProxy.Type |
getType() |
boolean |
isAutoStartup() |
boolean |
isRunning() |
void |
setAutoStartup(boolean autoStartup) |
void |
setBackendPort(int backendPort)
Specify a fixed port for backend socket of the proxy.
|
void |
setBackendSocketConfigurer(java.util.function.Consumer<org.zeromq.ZMQ.Socket> backendSocketConfigurer)
Provide a
Consumer to configure a proxy backend socket with arbitrary options, like security. |
void |
setBeanName(String beanName) |
void |
setExposeCaptureSocket(boolean exposeCaptureSocket)
Whether to bind and expose a capture socket for the proxy data.
|
void |
setFrontendPort(int frontendPort)
Specify a fixed port for frontend socket of the proxy.
|
void |
setFrontendSocketConfigurer(java.util.function.Consumer<org.zeromq.ZMQ.Socket> frontendSocketConfigurer)
Provide a
Consumer to configure a proxy frontend socket with arbitrary options, like security. |
void |
setPhase(int phase) |
void |
setProxyExecutor(Executor proxyExecutor)
Configure an executor to perform a ZeroMQ proxy loop.
|
void |
start() |
void |
stop() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitstoppublic ZeroMqProxy(org.zeromq.ZContext context)
ZeroMqProxy instance based on the provided ZContext
and ZeroMqProxy.Type.PULL_PUSH as default mode.context - the ZContext to usepublic ZeroMqProxy(org.zeromq.ZContext context,
ZeroMqProxy.Type type)
context - the ZContext to usetype - the ZeroMqProxy.Type to use.public void setProxyExecutor(Executor proxyExecutor)
Executors.newSingleThreadExecutor() instance is used.proxyExecutor - the Executor to use for ZeroMQ proxy looppublic void setFrontendPort(int frontendPort)
frontendPort - the port to use; must be more than 0public void setBackendPort(int backendPort)
backendPort - the port to use; must be more than 0public void setFrontendSocketConfigurer(@Nullable java.util.function.Consumer<org.zeromq.ZMQ.Socket> frontendSocketConfigurer)
Consumer to configure a proxy frontend socket with arbitrary options, like security.frontendSocketConfigurer - the configurer for frontend socketpublic void setBackendSocketConfigurer(@Nullable java.util.function.Consumer<org.zeromq.ZMQ.Socket> backendSocketConfigurer)
Consumer to configure a proxy backend socket with arbitrary options, like security.backendSocketConfigurer - the configurer for backend socketpublic void setExposeCaptureSocket(boolean exposeCaptureSocket)
exposeCaptureSocket - true to bind capture socket for proxypublic void setBeanName(String beanName)
setBeanName in interface BeanNameAwarepublic void setAutoStartup(boolean autoStartup)
public void setPhase(int phase)
public ZeroMqProxy.Type getType()
public int getFrontendPort()
public int getBackendPort()
@Nullable public String getControlAddress()
inproc control socket is bound or null if this proxy has not been started yet.@Nullable public String getCaptureAddress()
inproc capture socket is bound or null if this proxy has not been started yet
or captureAddress is false.public boolean isAutoStartup()
isAutoStartup in interface SmartLifecyclepublic int getPhase()
getPhase in interface PhasedgetPhase in interface SmartLifecyclepublic void afterPropertiesSet()
afterPropertiesSet in interface InitializingBeanpublic void destroy()
destroy in interface DisposableBean