Gozirra maintainer?

113 views
Skip to first unread message

Hans Eklund

unread,
Oct 12, 2014, 3:05:04 PM10/12/14
to stomp...@googlegroups.com
About STOMP for Java.

Is anyone maintaining the Gozirra Java STOMP 1.0 library anymore?


I think think this page looks kind of slow (gets ngnx 404 on many of the links)


Anyway, should anyone be using this library or wants to use it (despite other)
i just wanted to point out there is a weakness in the Client class.

I have submitted a patch to the maintaner and did a pull request:

My dirty fix was to add a bail out condition to the busy loop that made my thread hang
once in 10.000-times or so.

in file /gozirra/src/main/java/net/ser1/stomp/Client.java

replace the Client() constructor to:

    public Client(String server, int port, String login, String pass)
           
throws IOException, LoginException {
        _socket
= new Socket(server, port);
        _input
= _socket.getInputStream();
        _output
= _socket.getOutputStream();


        _listener
= new Receiver(this, _input);
        _listener
.start();


       
// Connect to the server
       
HashMap header = new HashMap();
        header
.put("login", login);
        header
.put("passcode", pass);
        transmit
(Command.CONNECT, header, null);
       
// Busy loop bail out
       
int x=0;
       
try {
           
String error = null;
           
while (!isConnected() && ((error = nextError()) == null)) {
               
Thread.sleep(100);
               
if (x++ > 20) {
                   
throw new LoginException("Did not connect in time!");
               
}
           
}
           
if (error != null) throw new LoginException(error);
       
} catch (InterruptedException e) {
       
}
   
}

Make sure to handle the LoginException accordingly with ample retries etc.

/H

Reply all
Reply to author
Forward
0 new messages