Spring IntegrationでTCPストリームを読み取る方法をはっきりと理解できません。私はそれに接続されているクライアント(TCP、Javaソケット)にいくつかのデータをブロードキャストする外部サービスを持っています。私はすでにSpring Integration内で多くの設定を試してきました。アプリケーションが正常に外部サービスに接続しましたが(サービスのログから確認できます)、まだストリームを取得できません。しかし、(MessageChannelを介して)いくつかのメッセージを手動で送信すると、Beanは正常に動作します。つまり、自分の設定が書き込みイベントをキャッチするように設定されていることを意味します。私は、TCPストリームを受信するためにそれを設定するための明示的なガイドやマニュアルを見つけることができませんでした。私は私のプロジェクトでは、このXML設定を持っている:私の受信チャンネルのエンドポイントである必要がありSpring IngrationでTCPからストリーム(メッセージ)を読み取る方法
<?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-ip="http://www.springframework.org/schema/integration/ip"
xmlns:int="http://www.springframework.org/schema/integration"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/integration/ip http://www.springframework.org/schema/integration/ip/spring-integration-ip.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<bean id="accumulator"
class="ru.utilex.trueguard.Accumulator" />
<int-ip:tcp-connection-factory id="client"
type="client"
host="192.168.2.28"
port="8383"
so-timeout="10000"/>
<int:channel id="input" />
<int:channel id="toSA" />
<int-ip:tcp-outbound-channel-adapter id="inboundClient"
client-mode="true"
channel="input"
auto-startup="true"
connection-factory="client"/>
<int:object-to-string-transformer id="serverBytes2String"
input-channel="input"
output-channel="toSA"/>
<int:service-activator
input-channel="toSA"
ref="accumulator"
method="read"/>
</beans>
私のアキュムレータクラス:
public class Accumulator {
public void read(String buffer) {
System.out.println("We have caught this message: " + buffer);
}
}
ありがとう、Gary。私は両方の構成をインバウンド・チャネル・アダプターとサーバー側に変更し、crlfで区切られたデータをプッシュしましたが、まだ私のアキュムレータには何もありません。メッセージはちょうど –
を起動しません。私は自分のデータトランスフォーマー(バイトから文字列を作る)と唾液の結果をアキュムレータに使用するように私の設定をいくつか変更して、私のアプリケーションが動作するようになった。私の大きな間違いは、メッセージ間に区切り文字を追加しないことでした。そのため、春のアダプターはメッセージをまったく読み取ることができませんでした。誰がコンフィギュレーションを探しているのか、ここにはペーストビンがあります。構成(xml)http://pastebin.com/Dqdkn5kS、Javaクラス:http://pastebin.com/PJ8gYLfa –