Class ZeroMqMessageHandler
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.handler.MessageHandlerSupport
org.springframework.integration.handler.AbstractReactiveMessageHandler
org.springframework.integration.zeromq.outbound.ZeroMqMessageHandler
- All Implemented Interfaces:
- Aware,- BeanFactoryAware,- BeanNameAware,- DisposableBean,- InitializingBean,- ApplicationContextAware,- Lifecycle,- Ordered,- ExpressionCapable,- Orderable,- IntegrationPattern,- NamedComponent,- IntegrationManagement,- ManageableLifecycle,- TrackableComponent,- ReactiveMessageHandler
public class ZeroMqMessageHandler
extends AbstractReactiveMessageHandler
implements ManageableLifecycle
The 
AbstractReactiveMessageHandler implementation for publishing messages over ZeroMq socket.
 Only SocketType.PAIR, SocketType.PUB and SocketType.PUSH are supported.
 This component is only connecting (no Binding) to another side, e.g. ZeroMq proxy.
 
 When the SocketType.PUB is used, the topicExpression is evaluated against a
 request message to inject a topic frame into a ZeroMq message if it is not null.
 The subscriber side must receive the topic frame first before parsing the actual data.
 
 When the payload of the request message is a ZMsg, no any conversion and topic extraction happen:
 the ZMsg is sent into a socket as is and it is not destroyed for possible further reusing.
- Since:
- 5.4
- Author:
- Artem Bilan, Alessio Matricardi
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagementIntegrationManagement.ManagementOverrides
- 
Field SummaryFields inherited from class org.springframework.integration.context.IntegrationObjectSupportEXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagementMETER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.core.OrderedHIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
- 
Constructor SummaryConstructorsConstructorDescriptionZeroMqMessageHandler(org.zeromq.ZContext context, String connectUrl) Create an instance based on the providedZContextand connection string.ZeroMqMessageHandler(org.zeromq.ZContext context, String connectUrl, org.zeromq.SocketType socketType) Create an instance based on the providedZContext, connection string andSocketType.ZeroMqMessageHandler(org.zeromq.ZContext context, Supplier<String> connectUrl) Create an instance based on the providedZContextand connection string supplier.ZeroMqMessageHandler(org.zeromq.ZContext context, Supplier<String> connectUrl, org.zeromq.SocketType socketType) Create an instance based on the providedZContext, connection string supplier andSocketType.
- 
Method SummaryModifier and TypeMethodDescriptionvoiddestroy()Subclasses may implement this method to provide component type information.protected reactor.core.publisher.Mono<Void> handleMessageInternal(Message<?> message) booleanprotected voidonInit()Subclasses may implement this for initialization logic.voidsetMessageConverter(MessageConverter messageConverter) Provide aMessageConverter(as an alternative tomessageMapper) for converting a request message intobyte[]for sending into ZeroMq socket.voidsetMessageMapper(OutboundMessageMapper<byte[]> messageMapper) Provide anOutboundMessageMapperto convert a request message intobyte[]for sending into ZeroMq socket.voidsetSocketConfigurer(Consumer<org.zeromq.ZMQ.Socket> socketConfigurer) Provide aConsumerto configure a socket with arbitrary options, like security.voidSpecify a topic theSocketType.PUBsocket is going to use for distributing messages into the subscriptions.voidsetTopicExpression(Expression topicExpression) Specify a SpEL expression to evaluate a topic aSocketType.PUBis going to use for distributing messages into the subscriptions.It is ignored for all otherSocketTypes supported.voidstart()voidstop()voidwrapTopic(boolean wrapTopic) Specify if the topic thatSocketType.PUBsocket is going to use for distributing messages into the subscriptions must be wrapped with an additional empty frame.Methods inherited from class org.springframework.integration.handler.AbstractReactiveMessageHandlerhandleMessageMethods inherited from class org.springframework.integration.handler.MessageHandlerSupportbuildSendTimer, getIntegrationPatternType, getManagedName, getManagedType, getMetricsCaptor, getObservationRegistry, getOrder, getOverrides, isLoggingEnabled, isObserved, registerMetricsCaptor, registerObservationRegistry, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrackMethods inherited from class org.springframework.integration.context.IntegrationObjectSupportafterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.integration.support.management.IntegrationManagementgetThisAsMethods inherited from interface org.springframework.integration.support.context.NamedComponentgetBeanName, getComponentName
- 
Constructor Details- 
ZeroMqMessageHandlerCreate an instance based on the providedZContextand connection string.- Parameters:
- context- the- ZContextto use for creating sockets.
- connectUrl- the URL to connect the socket to.
 
- 
ZeroMqMessageHandlerCreate an instance based on the providedZContextand connection string supplier.- Parameters:
- context- the- ZContextto use for creating sockets.
- connectUrl- the supplier for URL to connect the socket to.
- Since:
- 5.5.9
 
- 
ZeroMqMessageHandlerpublic ZeroMqMessageHandler(org.zeromq.ZContext context, String connectUrl, org.zeromq.SocketType socketType) Create an instance based on the providedZContext, connection string andSocketType.- Parameters:
- context- the- ZContextto use for creating sockets.
- connectUrl- the URL to connect the socket to.
- socketType- the- SocketTypeto use; only- SocketType.PAIR,- SocketType.PUBand- SocketType.PUSHare supported.
 
- 
ZeroMqMessageHandlerpublic ZeroMqMessageHandler(org.zeromq.ZContext context, Supplier<String> connectUrl, org.zeromq.SocketType socketType) Create an instance based on the providedZContext, connection string supplier andSocketType.- Parameters:
- context- the- ZContextto use for creating sockets.
- connectUrl- the supplier for URL to connect the socket to.
- socketType- the- SocketTypeto use; only- SocketType.PAIR,- SocketType.PUBand- SocketType.PUSHare supported.
- Since:
- 5.5.9
 
 
- 
- 
Method Details- 
setMessageMapperProvide anOutboundMessageMapperto convert a request message intobyte[]for sending into ZeroMq socket. Ignored whenMessage.getPayload()is an instance ofZMsg.- Parameters:
- messageMapper- the- OutboundMessageMapperto use.
 
- 
setMessageConverterProvide aMessageConverter(as an alternative tomessageMapper) for converting a request message intobyte[]for sending into ZeroMq socket. Ignored whenMessage.getPayload()is an instance ofZMsg.- Parameters:
- messageConverter- the- MessageConverterto use.
 
- 
setSocketConfigurer
- 
setTopicSpecify a topic theSocketType.PUBsocket is going to use for distributing messages into the subscriptions. It is ignored for all otherSocketTypes supported.- Parameters:
- topic- the topic to use.
 
- 
setTopicExpressionSpecify a SpEL expression to evaluate a topic aSocketType.PUBis going to use for distributing messages into the subscriptions.It is ignored for all otherSocketTypes supported.- Parameters:
- topicExpression- the expression to evaluate topic for publishing.
 
- 
wrapTopicpublic void wrapTopic(boolean wrapTopic) Specify if the topic thatSocketType.PUBsocket is going to use for distributing messages into the subscriptions must be wrapped with an additional empty frame. It is ignored for all otherSocketTypes supported. This attribute is set totrueby default.- Parameters:
- wrapTopic- true if the topic must be wrapped with an additional empty frame.
- Since:
- 6.2.6
 
- 
getComponentTypeDescription copied from class:IntegrationObjectSupportSubclasses may implement this method to provide component type information.- Specified by:
- getComponentTypein interface- NamedComponent
- Overrides:
- getComponentTypein class- MessageHandlerSupport
 
- 
onInitprotected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
- onInitin class- IntegrationObjectSupport
 
- 
startpublic void start()- Specified by:
- startin interface- Lifecycle
- Specified by:
- startin interface- ManageableLifecycle
 
- 
stoppublic void stop()- Specified by:
- stopin interface- Lifecycle
- Specified by:
- stopin interface- ManageableLifecycle
 
- 
isRunningpublic boolean isRunning()- Specified by:
- isRunningin interface- Lifecycle
- Specified by:
- isRunningin interface- ManageableLifecycle
 
- 
handleMessageInternal- Specified by:
- handleMessageInternalin class- AbstractReactiveMessageHandler
 
- 
destroypublic void destroy()- Specified by:
- destroyin interface- DisposableBean
- Specified by:
- destroyin interface- IntegrationManagement
- Overrides:
- destroyin class- MessageHandlerSupport
 
 
-