https://github.com/spring-projects/spring-integration-samples/tree/master/intermediate/tcp-client-server-multiplex Я видел эту иллюстрацию. Итак, я изменил архитектуру.Передача сообщений до шлюза?
- отправить модель
- получить модель И у меня есть вопрос. Я не понимаю роль передачи в модели отправки. Я понимаю сообщение доставки агрегатора для передачи. Но, я не понимаю Как доставить сообщение на шлюз. Как доставить?
Это моя конфигурация интеграции с пружиной.
Это Отправить установку приложения,
<!-- telegram bean -->
<bean id="byteArrayRawSerializer" class="org.springframework.integration.ip.tcp.serializer.ByteArrayRawSerializer">
<property name="maxMessageSize" value="2000"/>
</bean>
<bean id="myCorrelationStrategy" class="com.test.util.MyCorrelationStrategy"/>
<!-- online connection factory -->
<int-ip:tcp-connection-factory id="server" type="server" port="20001" single-use="false" lookup-host="false" so-timeout="60000" serializer="byteArrayRawSerializer" deserializer="byteArrayRawSerializer" />
<int-ip:tcp-connection-factory id="client" type="client" host="localhost" port="10001" single-use="false" so-timeout="60000" serializer="byteArrayRawSerializer" deserializer="byteArrayRawSerializer" />
<!-- Send -->
<int:gateway id="sendGateway"
service-interface="com.test.MySendGateway"
default-reply-timeout="20000"
default-request-channel="sendChannel"/>
<int:publish-subscribe-channel id="sendChannel" />
<int-ip:tcp-outbound-channel-adapter id="sendAdapter" order="2" channel="sendChannel" connection-factory="client" />
<int:bridge input-channel="batchSendChannel" output-channel="toSendAggregator" order="1"/>
<int:channel id="toSendAggregator" datatype="byte[]"/>
<int:aggregator input-channel="toSendAggregator"
output-channel="toSendTransformer"
expire-groups-upon-completion="true"
correlation-strategy="myCorrelationStrategy"
correlation-strategy-method="getCorrelationKey"
release-strategy-expression="size() == 2" />
<int:transformer input-channel="toSendTransformer" expression="payload.get(1)"/>
<int-ip:tcp-inbound-channel-adapter id="sendReplyAdapter" channel="toSendAggregator" connection-factory="client" />
<!-- Receive -->
<int-ip:tcp-inbound-channel-adapter id="inboundAdapter" channel="batchInboundChannel" connection-factory="batchReceiveServer" />
<int-ip:tcp-outbound-channel-adapter id="outboundAdapter" channel="batchOutboundChannel" connection-factory="batchReceiveServer"/>
<int:channel id="batchInboundChannel" />
<int:channel id="batchOutboundChannel"/>
<int:service-activator id="myReceiveServiceActivator" method="receive" input-channel="batchInboundChannel">
<bean class="com.test.endpoint.MyReceiveServiceActivator" />
</int:service-activator>
И это установка приложения Delivery (центр изображения),
<!-- Bean load -->
<bean id="byteArrayRawSerializer" class="org.springframework.integration.ip.tcp.serializer.ByteArrayRawSerializer">
<property name="maxMessageSize" value="2000"/>
</bean>
<!-- Connection factory -->
<int-ip:tcp-connection-factory id="server" type="server" port="30001" using-nio="true" single-use="false" lookup-host="false" so-timeout="10000" serializer="byteArrayRawSerializer" deserializer="byteArrayRawSerializer" />
<int-ip:tcp-connection-factory id="client" type="client" host="${RemoteTarget.ip}" port="${RemoteTarget.port}" using-nio="true" single-use="false" so-timeout="10000" serializer="byteArrayRawSerializer" deserializer="byteArrayRawSerializer" />
<!-- Connection factory -->
<int-ip:tcp-connection-factory id="inboundServer" type="server" port="10001" using-nio="true" single-use="false" lookup-host="false" so-timeout="${server.outbound.connectionTimeout}" serializer="byteArrayRawSerializer" deserializer="byteArrayRawSerializer" />
<int-ip:tcp-connection-factory id="inboardClient" type="client" host="localhost" port="20001" using-nio="true" single-use="false" so-timeout="10000" serializer="byteArrayRawSerializer" deserializer="byteArrayRawSerializer" />
<int-ip:tcp-inbound-channel-adapter id="receiveAdapter" channel="receiveChannel" connection-factory="server" auto-startup="true"/>
<int-ip:tcp-inbound-channel-adapter id="sendReplyAdapter" channel="sendReplyChannel" connection-factory="client" auto-startup="true"/>
<int:channel id="receiveChannel"/>
<int:channel id="sendReplyChannel"/>
<int-ip:tcp-outbound-channel-adapter id="receiveAdapter.inboard" channel="receiveChannel" connection-factory="inboundServer" />
<int-ip:tcp-outbound-channel-adapter id="sendReplyAdapter.inboard" channel="sendReplyChannel" connection-factory="inboardClient" />
<int-ip:tcp-outbound-channel-adapter id="sendAdapter" channel="sendChannel" connection-factory="client" />
<int-ip:tcp-outbound-channel-adapter id="receiveReplyAdapter" channel="receiveReplyChannel" connection-factory="server" />
<int:channel id="sendChannel" />
<int:channel id="receiveReplyChannel"/>
<int:router id="outRouter" input-channel="toRouter" method="route" auto-startup="true">
<bean class="com.test.endpoint.MyRouter"/>
</int:router>
<int:channel id="toRouter"/>
<int-ip:tcp-inbound-channel-adapter id="sendAdapter.inboard" channel="toRouter" connection-factory="inboundServer" auto-startup="true"/>
<int-ip:tcp-inbound-channel-adapter id="receiveReplyAdapter.inboard" channel="toRouter" connection-factory="inboardClient" auto-startup="true"/>
Но, когда я называю gw.send (МВП), то не работает, (точно, остановка сообщения на «sendAdapter.inboard» на машине доставки до тех пор, пока тайм-аут и маршрутизатор не получат это сообщение ....
спасибо. Я пробую так. Но это не работа. –
Я не знаю вашей архитектуры, но если вы следуете этому образцу 'multiplex', вам действительно нужно использовать тот же самый канал публикации-подписки, что и для' tcp: исходящий-канал-адаптер', а также для 'aggregator'. Но в соответствии с вашим кодом для последнего вы используете совершенно другой канал - 'batchSendChannel'. Пожалуйста, будьте осторожны с кодом, я не уверен, что мы должны сделать для вас работу ... –
Извините .. batchSendChannel просто печатает ошибку. Я перейду на точную конфигурацию. –