activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r726668 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/transport/stomp/ test/java/org/apache/activemq/transport/stomp/
Date Mon, 15 Dec 2008 10:17:48 GMT
Author: dejanb
Date: Mon Dec 15 02:17:47 2008
New Revision: 726668

URL: http://svn.apache.org/viewvc?rev=726668&view=rev
Log:
fix for AMQ-1989 and a couple of improvements for Stomp Java client

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompConnection.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java?rev=726668&r1=726667&r2=726668&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java
Mon Dec 15 02:17:47 2008
@@ -226,6 +226,7 @@
 
         Map<String, String> headers = command.getHeaders();
         String stompTx = headers.get(Stomp.Headers.TRANSACTION);
+        headers.remove("transaction");
 
         ActiveMQMessage message = convertMessage(command);
 

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompConnection.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompConnection.java?rev=726668&r1=726667&r2=726668&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompConnection.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompConnection.java
Mon Dec 15 02:17:47 2008
@@ -109,7 +109,7 @@
     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 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());    	
     }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java?rev=726668&r1=726667&r2=726668&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java
Mon Dec 15 02:17:47 2008
@@ -22,6 +22,7 @@
 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.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.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 @@
         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;



Mime
View raw message