* ChannelMessage)
*/
public void sendMessage(byte[] data, boolean waitForAck) throws IOException {
- boolean messageTransfered = false ;
IOException exception = null;
setAttempt(0);
try {
// first try with existing connection
pushMessage(data,false,waitForAck);
- messageTransfered = true ;
} catch (IOException x) {
SenderState.getSenderState(getDestination()).setSuspect();
exception = x;
setAttempt(getAttempt()+1);
// second try with fresh connection
pushMessage(data, true,waitForAck);
- messageTransfered = true;
exception = null;
} catch (IOException xx) {
exception = xx;
} finally {
setRequestCount(getRequestCount()+1);
keepalive();
- if(messageTransfered) {
-
- } else {
- if ( exception != null ) throw exception;
- }
+ if ( exception != null ) throw exception;
}
-
}
* open real socket and set time out when waitForAck is enabled
* is socket open return directly
*/
- protected void openSocket() throws IOException {
+ protected void openSocket() throws IOException {
if(isConnected()) return ;
try {
socket = new Socket();
* @see DataSender#disconnect()
* @see DataSender#closeSocket()
*/
- protected void closeSocket() {
+ protected void closeSocket() {
if(isConnected()) {
if (socket != null) {
try {
* @since 5.5.10
*/
- protected void pushMessage(byte[] data, boolean reconnect, boolean waitForAck) throws IOException {
+ protected void pushMessage(byte[] data, boolean reconnect, boolean waitForAck) throws IOException {
keepalive();
if ( reconnect ) closeSocket();
if (!isConnected()) openSocket();
* @throws java.io.IOException
* @throws java.net.SocketTimeoutException
*/
- protected void waitForAck() throws java.io.IOException {
+ protected void waitForAck() throws java.io.IOException {
try {
boolean ackReceived = false;
boolean failAckReceived = false;