2012-02-10 13 views
1

私はポート30003.に耳を傾け、小さなプログラムを持っているがそれは次のようにバイトストリームデータを処理するサーバ・クラスであります統合。ここで同じことを達成することを意図しているもののための私のtcp-コンテキストは次のとおりです。ソケットと春の統合

<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:context="http://www.springframework.org/schema/context" 
    xmlns:ip="http://www.springframework.org/schema/integration/ip" 
    xsi:schemaLocation="http://www.springframework.org/schema/integration 
http://www.springframework.org/schema/integration/spring-integration-2.1.xsd 
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-3.0.xsd 
http://www.springframework.org/schema/integration/ip 
http://www.springframework.org/schema/integration/ip/spring-integration-ip-2.0.xsd 
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd"> 


<context:component-scan base-package="com.atlaschase.falcon.integration"></context:component-scan> 

<int:channel id="heathrowChannel"></int:channel> 

<ip:tcp-connection-factory id="heathrowConnectionFactory" type="server" host="127.0.0.1" port="30003"/> 

<ip:tcp-inbound-channel-adapter id="heathrowInboundAdapter" channel="heathrowChannel" connection-factory="heathrowConnectionFactory"/> 

<int:service-activator id="adsbHandler" input-channel="heathrowChannel" ref="sbsListener"/> 

</beans> 

私は春の統合的なアプローチを使用してプログラムを起動すると、私は次のスタックトレースを取得する - ソケットアドレスが既にあることを私に告げます使用中で。

SEVERE: Error on ServerSocket 
java.net.BindException: Address already in use: JVM_Bind 
    at java.net.PlainSocketImpl.socketBind(Native Method) 
    at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:383) 
    at java.net.ServerSocket.bind(ServerSocket.java:328) 
    at java.net.ServerSocket.<init>(ServerSocket.java:194) 
    at java.net.ServerSocket.<init>(ServerSocket.java:150) 
    at javax.net.DefaultServerSocketFactory.createServerSocket(ServerSocketFactory.java:163) 
    at org.springframework.integration.ip.tcp.connection.TcpNetServerConnectionFactory.run(TcpNetServerConnectionFactory.java:61) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 
    at java.lang.Thread.run(Thread.java:662) 

なぜ私の標準ソケットプログラムがうまく動作するのか理解できません。なぜ統合アプローチが失敗するのですか?私のマシンには、30003ポートでデータを利用できるようにするソフトウェアが少しあります。

お手伝いができたら幸いです。

ありがとうございました

+0

あなたは春に新しい実装を開始する前に、ポート30003上でリスニングプログラムを停止しましたか? –

+0

私が耳を傾けようとしているデータを提供する30003上で動作している**アプリケーション**があります。ソケットアプローチは、そのアプリケーションの実行中にうまく動作しますが、このSIはエラーを生成しています。 – totalcruise

+3

*ポートにリスンする*とは、サーバーソケットを開くことを意味し、同じポートを開くアプリケーションは複数ありません。あなたの春の設定では、ポート30003上の* ServerSocket *を開こうとします。したがって、受信した例外は既に使用中のアドレスです。 –

答えて

1

これは、サーバーとクライアントの間の混乱を取り除くことで解決します。アプリケーションがすでにそのポート番号にバインドされているため、サーバーソケットを生成できませんでした。

「30003」ポートに「聞く」に、私は「クライアント」タイプのはconnectionFactoryを生成する必要がありました:

<ip:tcp-connection-factory id="heathrowConnectionFactory" type="server" host="127.0.0.1" port="30003"/> 
関連する問題