9

I am trying several stomp libraries for java (gozirra, stompj, activemq). All these libraries have poor documentation, such as having only one example, and I have a serious problem:

I need SSL support.

The stomp+ssl protocol exists and is supported by activemq but I am not able to find a Java client that supports it.

Michael Currie
  • 13,721
  • 9
  • 42
  • 58
mgiammarco
  • 371
  • 5
  • 16

3 Answers3

3

I found this forum discussion about JMS on Android, which references the experimental Stomp API included in ActiveMQ 5.2 and greater (example copied below)

Also mentioned is that the REST API might be a better fit for mobile devices, allowing state to be maintained purely at the broker.

StompConnection connection = new StompConnection();
connection.open("localhost", 61613);

connection.connect("system", "manager");
StompFrame connect = connection.receive();
if (!connect.getAction().equals(Stomp.Responses.CONNECTED)) {
    throw new Exception ("Not connected");
}

connection.begin("tx1");
connection.send("/queue/test", "message1", "tx1", null);
connection.send("/queue/test", "message2", "tx1", null);
connection.commit("tx1");

connection.subscribe("/queue/test", Subscribe.AckModeValues.CLIENT);

connection.begin("tx2");

StompFrame message = connection.receive();
System.out.println(message.getBody());
connection.ack(message, "tx2");

message = connection.receive();
System.out.println(message.getBody());
connection.ack(message, "tx2");

connection.commit("tx2");
connection.disconnect();
Joe Coder
  • 4,498
  • 31
  • 41
  • Thank but I have found (and tried ) at least three java stomp client and they work. Unfortunately no SSL and I badly need it. Thanks for the REST idea but I will try after I fail all attempts with stomp. – mgiammarco Feb 20 '12 at 19:33
  • Are you sure your SSL certs are working? Have you had success with any STOMP+SSL clients (non-Java)? – Joe Coder Feb 24 '12 at 00:32
  • I can say that I have successfully configured the activemq server to use stomp+ssl protocol. Tried with telnet it starts an ssl negotiation. I have not yet tried with any client (java or non java). – mgiammarco Feb 24 '12 at 13:33
2

With library from activemq do it this way :

                System.setProperty("javax.net.ssl.keyStore",
            "/home/foo/.keystore/client.ks");
    System.setProperty("javax.net.ssl.keyStorePassword", "changeme");
    System.setProperty("javax.net.ssl.trustStore",
            "/home/foo/.keystore/client.ts");

    StompConnection connection = new StompConnection();
    SSLSocketFactory factory = (SSLSocketFactory) SSLSocketFactory
            .getDefault();
    SSLSocket sslsocket = (SSLSocket) factory.createSocket("127.0.0.1",
            61612);
    connection.open(sslsocket);
user3364855
  • 161
  • 1
  • 4
2

Not sure it works on Android but worth a try is the FuseSource StompJMS client available on Github. It uses the hwatdispatch library which has both standard TCP and SSL transports built in. Worth a shot anyway.

Tim Bish
  • 17,475
  • 4
  • 32
  • 42
  • I have tried it following your suggestion, I have seen it supports ssl, but due to the fact that there is no example and no docs, I am not able to configure the keystore and so the ssl connection fails. Any idea? – mgiammarco Mar 11 '12 at 01:15
  • Ok I confirm that FuseSource Stomp implementation works with ssl but the documentation is lacking... – mgiammarco Apr 23 '12 at 18:02
  • It has a horrible license - you would need to make your application source code freely available if you use this, which means it is no use commercially. – tentimes Nov 20 '12 at 20:31