spring - How to define TcpOutboundGateway bean in java-class configuraiton -
when i've tried define tcpoutboundgateway bean, found class doesn't have "requestchannel" , "replychannelname" setters. how can correctly define bean in java-class configuration?
which java-class configuration equal xml-configuration presented below?
<int-ip:tcp-outbound-gateway id="outgateway" request-channel="input" reply-channel="clientbytes2stringchannel" connection-factory="client" request-timeout="10000" reply-timeout="10000"/>
this code equal client xml configuration presented link.
public static final string string_to_bytes_channel = "stringtobyteschannel"; public static final string request_channel = "requestchannel"; private string host = "localhost"; private int port = 2020; @bean public tcpnetclientconnectionfactory connectionfactory() { tcpnetclientconnectionfactory factory = new tcpnetclientconnectionfactory(host, port); factory.setsingleuse(true); factory.setsotimeout(10000); return factory; } @bean public messagechannel requestchannel() { return new directchannel(); } @bean public messagechannel stringtobyteschannel() { return new directchannel(); } @bean @transformer(inputchannel = string_to_bytes_channel) public objecttostringtransformer objecttostringtransformer() { return new objecttostringtransformer(); } @bean @serviceactivator(inputchannel = request_channel) public tcpoutboundgateway outboundgateway() { tcpoutboundgateway gateway = new tcpoutboundgateway(); gateway.setconnectionfactory(connectionfactory()); gateway.setreplychannel(stringtobyteschannel()); gateway.setrequesttimeout(10000); gateway.setremotetimeout(10000); return gateway; } @messaginggateway(defaultrequestchannel = request_channel) public interface requestgateway { string send(string message); }
Comments
Post a Comment