Note that there are some explanatory texts on larger screens.

plurals
  1. POService-architecture - the inputStream is losing bytes
    text
    copied!<p>i have a kind of service architecture in my server, listening on a TCP-IP-socked. </p> <pre><code>messageType = protocolHandler.getMessageType(); ITaskProtocol serviceProtocol = serverServices.get(messageType); if (p != null) { String result = serviceProtocol.handleTask(protocolHandler); } </code></pre> <p>i am storing a protocol for a specific task in a hash-map. My problem is, that the protocol that should handle the task is not finding any bytes in the inputStream. the inputStream and socked is inside the "protocolHandler". </p> <p>example:</p> <pre><code>public class ProtocolHandler implements ITaskProtocolHandler { @Override public int getMessageType() throws IOException { return new DataInputStream(stream).readInt(); } </code></pre> <p>However, i can see (because of debugging) that the message was sended. and also the protocol(service) was found in the map and the "handleTask(...)" method of the service was invoked. However, the service is getting no message because the bytes are lost and the protocols are waiting for each other. </p> <p>My guess is that the searching for the service needs too long and the message is lost meanwhile.</p> <p>Important Info: Sometimes it is working sometimes not. the client and server are running on the same pc, it's probably a threads issue.</p> <p>client protocol:</p> <pre><code>clientWorker.send(ServerProtocol.MessageRequestType.JoinTopicRequest.getRequestNumber()); clientWorker.send("some xml-message"); </code></pre> <p>server service-protocol:</p> <pre><code>public String handleTask(ITaskProtocolHandler protocolHandler) throws Exception { Message m = protocolHandler.getMessage()); </code></pre> <p>whats wrong in the architecture?</p> <p>thanks a lot!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload