assign default JMS priority when none is set on a Message.

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1071432 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2011-02-16 22:54:23 +00:00
parent e0c678e9a0
commit 14722f8627
2 changed files with 27 additions and 1 deletions

View File

@ -22,9 +22,12 @@ import java.util.Map;
import javax.jms.Destination; import javax.jms.Destination;
import javax.jms.JMSException; import javax.jms.JMSException;
import javax.jms.MessageListener;
import javax.jms.MessageProducer;
import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.command.ActiveMQDestination;
import org.apache.activemq.command.ActiveMQMessage; import org.apache.activemq.command.ActiveMQMessage;
import org.apache.activemq.command.Message;
/** /**
* Implementations of this interface are used to map back and forth from Stomp * Implementations of this interface are used to map back and forth from Stomp
@ -107,6 +110,8 @@ public interface FrameTranslator {
o = headers.remove(Stomp.Headers.Send.PRIORITY); o = headers.remove(Stomp.Headers.Send.PRIORITY);
if (o != null) { if (o != null) {
msg.setJMSPriority(Integer.parseInt((String)o)); msg.setJMSPriority(Integer.parseInt((String)o));
} else {
msg.setJMSPriority(javax.jms.Message.DEFAULT_PRIORITY);
} }
o = headers.remove(Stomp.Headers.Send.TYPE); o = headers.remove(Stomp.Headers.Send.TYPE);

View File

@ -296,6 +296,27 @@ public class StompTest extends CombinationTestSupport {
assertEquals("GroupID", "abc", amqMessage.getGroupID()); assertEquals("GroupID", "abc", amqMessage.getGroupID());
} }
public void testSendMessageWithNoPriorityReceivesDefault() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
String frame = "CONNECT\n" + "login: system\n" + "passcode: manager\n\n" + Stomp.NULL;
stompConnection.sendFrame(frame);
frame = stompConnection.receiveFrame();
assertTrue(frame.startsWith("CONNECTED"));
frame = "SEND\n" + "correlation-id:c123\n" + "destination:/queue/" + getQueueName() + "\n\n" + "Hello World"
+ Stomp.NULL;
stompConnection.sendFrame(frame);
TextMessage message = (TextMessage)consumer.receive(2500);
assertNotNull(message);
assertEquals("Hello World", message.getText());
assertEquals("getJMSPriority", 4, message.getJMSPriority());
}
public void testReceipts() throws Exception { public void testReceipts() throws Exception {
StompConnection receiver = new StompConnection(); StompConnection receiver = new StompConnection();