mirror of https://github.com/apache/activemq.git
fix for AMQ-1989 and a couple of improvements for Stomp Java client
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@726668 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4229aee737
commit
7aec12eaca
|
@ -226,6 +226,7 @@ public class ProtocolConverter {
|
|||
|
||||
Map<String, String> headers = command.getHeaders();
|
||||
String stompTx = headers.get(Stomp.Headers.TRANSACTION);
|
||||
headers.remove("transaction");
|
||||
|
||||
ActiveMQMessage message = convertMessage(command);
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ public class StompConnection {
|
|||
public void connect(String username, String password) throws Exception {
|
||||
HashMap<String, String> headers = new HashMap();
|
||||
headers.put("login", username);
|
||||
headers.put("password", password);
|
||||
headers.put("passcode", password);
|
||||
StompFrame frame = new StompFrame("CONNECT", headers);
|
||||
sendFrame(frame.toString());
|
||||
}
|
||||
|
@ -120,14 +120,17 @@ public class StompConnection {
|
|||
}
|
||||
|
||||
public void send(String destination, String message) throws Exception {
|
||||
send(destination, message, null);
|
||||
send(destination, message, null, null);
|
||||
}
|
||||
|
||||
public void send(String destination, String message, HashMap<String, String> headers) throws Exception {
|
||||
|
||||
public void send(String destination, String message, String transaction, HashMap<String, String> headers) throws Exception {
|
||||
if (headers == null) {
|
||||
headers = new HashMap<String, String>();
|
||||
}
|
||||
headers.put("destination", destination);
|
||||
if (transaction != null) {
|
||||
headers.put("transaction", transaction);
|
||||
}
|
||||
StompFrame frame = new StompFrame("SEND", headers, message.getBytes());
|
||||
sendFrame(frame.toString());
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.net.SocketTimeoutException;
|
|||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.HashMap;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -29,7 +30,6 @@ import javax.jms.BytesMessage;
|
|||
import javax.jms.Connection;
|
||||
import javax.jms.JMSException;
|
||||
import javax.jms.MapMessage;
|
||||
import javax.jms.Message;
|
||||
import javax.jms.MessageConsumer;
|
||||
import javax.jms.MessageProducer;
|
||||
import javax.jms.ObjectMessage;
|
||||
|
@ -46,6 +46,7 @@ import org.apache.activemq.broker.BrokerService;
|
|||
import org.apache.activemq.broker.jmx.BrokerViewMBean;
|
||||
import org.apache.activemq.command.ActiveMQQueue;
|
||||
import org.apache.activemq.command.ActiveMQTextMessage;
|
||||
import org.apache.activemq.transport.stomp.Stomp.Headers.Subscribe;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
@ -913,6 +914,23 @@ public class StompTest extends CombinationTestSupport {
|
|||
assertEquals(view.getDurableTopicSubscribers().length, 0);
|
||||
}
|
||||
|
||||
public void testMessageIdHeader() throws Exception {
|
||||
stompConnection.connect("system", "manager");
|
||||
|
||||
stompConnection.begin("tx1");
|
||||
stompConnection.send("/queue/" + getQueueName(), "msg", "tx1", null);
|
||||
stompConnection.commit("tx1");
|
||||
|
||||
StompFrame connect = stompConnection.receive();
|
||||
if (!connect.getAction().equals(Stomp.Responses.CONNECTED)) {
|
||||
throw new Exception ("Not connected");
|
||||
}
|
||||
|
||||
stompConnection.subscribe("/queue/" + getQueueName());
|
||||
StompFrame stompMessage = stompConnection.receive();
|
||||
assertNull(stompMessage.getHeaders().get("transaction"));
|
||||
}
|
||||
|
||||
protected void assertClients(int expected) throws Exception {
|
||||
org.apache.activemq.broker.Connection[] clients = broker.getBroker().getClients();
|
||||
int actual = clients.length;
|
||||
|
|
Loading…
Reference in New Issue