GH-9228: Provide binding to ZeroMqMessageHandler
Fixes: #9228 * add docs * protected constructor in ZeroMqMessageHandlerSpec, expose them via ZeroMq * introduce ZeroMqUtils, for common Zero MQ utilities functions * use ZeroMqUtils.bindSocket in ZeroMqMessageProducer * refactor ZeroMqMessageHandler providing connectUrl and bindPort setters and simple constructors, following the same logic used for ZeroMqMessageProvider * fix tests to follow the new ZeroMqMessageHandler implementation * fix typo * add new updates to whats-new.adoc * address ZeroMQUtils comments * remove connectUrl and boundPort setters, add Javadoc to new constructors * add new DLS constructor for random port * add since closure in ZeroMqUtils * add DSL support methods and specific that, when not defined, the socket will be bound to a random port
This commit is contained in:
committed by
GitHub
parent
78ae221fd5
commit
272dde8945
@@ -30,4 +30,9 @@ The references stay in cache because polling configuration does not allow to pro
|
||||
|
||||
The `LobHandler` (and respective API) has been deprecated for removal in Spring Framework `6.2`.
|
||||
Respective option on `JdbcMessageStore` (and similar) have been deprecated as well.
|
||||
The byte array handling for serialized message is fully deferred to JDBC driver.
|
||||
The byte array handling for serialized message is fully deferred to JDBC driver.
|
||||
|
||||
[[x6.4-zeromq-changes]]
|
||||
=== ZeroMQ Changes
|
||||
|
||||
The outbound component `ZeroMqMessageHandler` (and respective API) can now bind a TCP port instead of connecting to a given URL.
|
||||
@@ -146,7 +146,9 @@ ZeroMqMessageProducer zeroMqMessageProducer(ZContext context, MessageChannel out
|
||||
|
||||
The `ZeroMqMessageHandler` is a `ReactiveMessageHandler` implementation to produce publish messages into a ZeroMQ socket.
|
||||
Only `SocketType.PAIR`, `SocketType.PUSH` and `SocketType.PUB` are supported.
|
||||
The `ZeroMqMessageHandler` only supports connecting the ZeroMQ socket; binding is not supported.
|
||||
This component can connect to the remote socket or bind onto TCP protocol with the provided or random port.
|
||||
The actual port can be obtained via `getBoundPort()` after this component is started and ZeroMQ socket is bound.
|
||||
|
||||
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 (`SocketType.SUB`) must receive the topic frame first before parsing the actual data.
|
||||
|
||||
@@ -158,7 +160,7 @@ Otherwise, an `OutboundMessageMapper<byte[]>` is used to convert a request messa
|
||||
By default, a `ConvertingBytesMessageMapper` is used supplied with a `ConfigurableCompositeMessageConverter`.
|
||||
The socket options (e.g. security or write timeout) can be configured via `setSocketConfigurer(Consumer<ZMQ.Socket> socketConfigurer)` callback.
|
||||
|
||||
Here is a sample of `ZeroMqMessageHandler` configuration:
|
||||
Here is a sample of `ZeroMqMessageHandler` configuration which connect to a socket:
|
||||
|
||||
[source,java]
|
||||
----
|
||||
@@ -173,6 +175,21 @@ ZeroMqMessageHandler zeroMqMessageHandler(ZContext context) {
|
||||
}
|
||||
----
|
||||
|
||||
Here is a sample of `ZeroMqMessageHandler` configuration which bind to a provided port:
|
||||
|
||||
[source,java]
|
||||
----
|
||||
@Bean
|
||||
@ServiceActivator(inputChannel = "zeroMqPublisherChannel")
|
||||
ZeroMqMessageHandler zeroMqMessageHandler(ZContext context) {
|
||||
ZeroMqMessageHandler messageHandler =
|
||||
new ZeroMqMessageHandler(context, 7070, SocketType.PUB);
|
||||
messageHandler.setTopicExpression(
|
||||
new FunctionExpression<Message<?>>((message) -> message.getHeaders().get("topic")));
|
||||
messageHandler.setMessageMapper(new EmbeddedJsonHeadersMessageMapper());
|
||||
}
|
||||
----
|
||||
|
||||
[[zeromq-dsl]]
|
||||
== ZeroMQ Java DSL Support
|
||||
|
||||
|
||||
Reference in New Issue
Block a user