Stomp ActiveMQ questions

1.4k views Asked by At

I am new to Stomp ActiveMQ. I want to create a login from an android client and I don't know how to use ActiveMq. I\ve installed active mq, configured stomp and run the stompexample. 1. I have an error when running activemq from command line if I add in in the activemq.xml the following line:

 <transportConnector name="stomp+nio" uri="stomp+nio://localhost:61612"/>
            <transportConnector name="stomp+ssl" uri="stomp+ssl://localhost:61612"/>
  1. Can someone please explain what is with tx1 and tx2? Is there a way to send on the queue a message to a specific client? how?

    connection.connect("system", "manager");

        connection.begin("tx1");
        connection.send("/queue/test", "message1");
        connection.send("/queue/test", "message2");
        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();
    
  2. Can someone please tell me how to create an application that sends on a queue a text containing username, password and receives an answer if the register was successful?

1

There are 1 answers

3
Tim Bish On

You need to configure the transport connectors with different port numbers, they can't both share port 61612. Your configure is create a Stomp NIO connector and a different Stomp SSL Connector.

You can't send messages to a distinct client, you just place them on a Queue and if there is a client subscribed it will get the message, that's the nature of Queue based messaging. The TX1 TX2 stuff is sending the messages within a transaction.

Recommend you take some time to read up of JMS Messaging, the Stomp spec and some other messaging based tutorials.