java - How to read stream (messages) from TCP in Spring Inegration -


i can't understand how read tcp stream in spring integration. have external service broadcasts data clients connected (tcp, java socket). i've tried many configurations within spring integration. application connects external service (i can confirm service's logs), still can't catch stream. however, when manually send message service (through messagechannel), beans work correctly. mean configuration configured catch write events. not find explicit guides or manuals configuring receiving tcp stream. have xml configuration in project:

<?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> 

my accumulator class should endpoint of receiving channel:

public class accumulator {      public void read(string buffer) {         system.out.println("we have caught message: " + buffer);     }  } 

you need inbound channel adapter.

be aware connection factory configuration, expecting messages on stream delimited crlf (0x0d0a).

if service uses other mechanism demarcate messages, need different deserializer.

the messages emitted inbound adapter have byte[] payloads; if need string, should insert object-to-string-transformer between adapter , service.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -