このポストを実行し、eventListnerを実装しました。int-event:java.net.ConnectExceptionが存在する場合、インバウンド・チャネル・アダプターが動作しません。接続が拒否されました:connect
:私のサービスの活性化因子は、例外の下で呼ばなっていません<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-ip="http://www.springframework.org/schema/integration/ip"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:int-event="http://www.springframework.org/schema/integration/event"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/integration/event http://www.springframework.org/schema/integration/event/spring-integration-event.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/ip http://www.springframework.org/schema/integration/ip/spring-integration-ip.xsd">
<context:annotation-config />
<!--Deserializer for incoming data on the socket -->
<bean
class="org.springframework.integration.ip.tcp.serializer.ByteArraySingleTerminatorSerializer"
id="serializeAndDeserializer">
<constructor-arg type="byte" value="0" />
</bean>
<int:channel id="tcp-client-input" />
<int:channel id="message" />
<int:gateway id="gateway" service-interface="com.tcpclient.ClientGateway"
default-request-channel="tcp-client-input" default-reply-channel="message" />
<int-ip:tcp-connection-factory id="clientFactory"
type="client" host="10.255.233.21" port="1234" single-use="false"
so-timeout="10000" deserializer="serializeAndDeserializer" serializer="serializeAndDeserializer" />
<int-ip:tcp-outbound-channel-adapter
id="outBoundClient" channel="tcp-client-input" connection-factory="clientFactory"
retry-interval="60000" auto-startup="false" />
<int-ip:tcp-inbound-channel-adapter
id="inBoundClient" channel="message" connection-factory="clientFactory"
client-mode="true" auto-startup="false" retry-interval="60000" />
<int-event:inbound-channel-adapter
channel="eventChannel" error-channel="tcpReceiveError"
event- types="org.springframework.integration.ip.tcp.connection.TcpConnectionExceptionEvent"/>
<int:object-to-string-transformer
input-channel="message" output-channel="message-serviceActivator" />
<int:service-activator input-channel="message-serviceActivator"
method="onRtlsMessageArrival">
<bean class="com.tcpclient.HandleMessage" />
</int:service-activator>
</beans>
サービスアクティベーター
@ServiceActivator(inputChannel = "tcpReceiveError")
public void handleSocketFlags(Message m) {
System.out.println(m.getPayload());
}
:以下のように私は春のTCPチャネルを実装している Best practice for handling low-level socket error in spring integration?
java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method) ~[na:1.8.0_92]
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source) ~[na:1.8.0_92]
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source) ~[na:1.8.0_92]
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source) ~[na:1.8.0_92]
at java.net.AbstractPlainSocketImpl.connect(Unknown Source) ~[na:1.8.0_92]
at java.net.PlainSocketImpl.connect(Unknown Source) ~[na:1.8.0_92]
at java.net.SocksSocketImpl.connect(Unknown Source) ~[na:1.8.0_92]
at java.net.Socket.connect(Unknown Source) ~[na:1.8.0_92]
at java.net.Socket.connect(Unknown Source) ~[na:1.8.0_92]
at java.net.Socket.<init>(Unknown Source) ~[na:1.8.0_92]
at java.net.Socket.<init>(Unknown Source) ~[na:1.8.0_92]
at javax.net.DefaultSocketFactory.createSocket(Unknown Source) ~[na:1.8.0_92]
at org.springframework.integration.ip.tcp.connection.TcpNetClientConnectionFactory.createSocket(TcpNetClientConnectionFactory.java:76) ~[spring-integration-ip-4.2.5.RELEASE.jar:na]
at org.springframework.integration.ip.tcp.connection.TcpNetClientConnectionFactory.buildNewConnection(TcpNetClientConnectionFactory.java:49) ~[spring-integration-ip-4.2.5.RELEASE.jar:na]
at org.springframework.integration.ip.tcp.connection.AbstractClientConnectionFactory.obtainNewConnection(AbstractClientConnectionFactory.java:114) ~[spring-integration-ip-4.2.5.RELEASE.jar:na]
at org.springframework.integration.ip.tcp.connection.AbstractClientConnectionFactory.obtainConnection(AbstractClientConnectionFactory.java:77) ~[spring-integration-ip-4.2.5.RELEASE.jar:na]
at org.springframework.integration.ip.tcp.connection.AbstractClientConnectionFactory.getConnection(AbstractClientConnectionFactory.java:67) ~[spring-integration-ip-4.2.5.RELEASE.jar:na]
at org.springframework.integration.ip.tcp.connection.AbstractClientConnectionFactory.getConnection(AbstractClientConnectionFactory.java:31) ~[spring-integration-ip-4.2.5.RELEASE.jar:na]
at org.springframework.integration.ip.tcp.connection.ClientModeConnectionManager.run(ClientModeConnectionManager.java:54) ~[spring-integration-ip-4.2.5.RELEASE.jar:na]
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) [spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [na:1.8.0_92]
at java.util.concurrent.FutureTask.runAndReset(Unknown Source) [na:1.8.0_92]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source) [na:1.8.0_92]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) [na:1.8.0_92]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_92]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_92]
at java.lang.Thread.run(Unknown Source) [na:1.8.0_92]
私には何かがありません。私はint-event:inbound-channel-adapter
のevent-type
が適切であることを願っています。私が何かを訂正しなければならないかどうか教えてください。
メッセージハンドラが接続さえないときにメッセージハンドラが呼び出されるのはなぜですか?あなたが驚いていることは不明です。 – EJP
接続がないので、例外ではなく、この例外イベントのSpringイベントを定義しました。そのイベントのハンドラを呼び出す必要があります。 –