diff --git a/pom.xml b/pom.xml
index b291fc6..11488ed 100644
--- a/pom.xml
+++ b/pom.xml
@@ -84,12 +84,6 @@
test
-
- org.springframework
- spring-asm
- ${spring.version}
- test
-
org.springframework
diff --git a/src/main/java/com/libzter/a/A.java b/src/main/java/com/libzter/a/A.java
index 7c43d80..0ee9f7f 100644
--- a/src/main/java/com/libzter/a/A.java
+++ b/src/main/java/com/libzter/a/A.java
@@ -77,6 +77,7 @@ public void output(Object... args) {
public static String CMD_USER = "U";
public static String CMD_PASS = "P";
public static String CMD_SET_HEADER = "H";
+ public static String CMD_PRIORITY = "i";
public static String DEFAULT_COUNT_GET = "1";
public static String DEFAULT_COUNT_ALL = "0";
@@ -109,6 +110,7 @@ public void run(String[] args) throws InterruptedException{
opts.addOption(CMD_WAIT,"wait",true,"Time to wait on get operation. Default 50. 0 equals infinity");
opts.addOption(CMD_USER,"user",true,"Username to connect to broker");
opts.addOption(CMD_PASS,"pass",true,"Password to connect to broker");
+ opts.addOption(CMD_PRIORITY,"priority",true,"sets JMSPriority");
@SuppressWarnings("static-access")
Option property = OptionBuilder.withArgName("property=value" )
.hasArgs(2)
@@ -277,6 +279,7 @@ protected void executePut(CommandLine cmdLine) throws IOException, JMSException
Properties props = cmdLine.getOptionProperties(CMD_SET_HEADER);
String type = cmdLine.getOptionValue(CMD_TYPE,DEFAULT_TYPE);
String encoding = cmdLine.getOptionValue(CMD_ENCODING, Charset.defaultCharset().name());
+
Message outMsg = null;
// figure out input data
String data = cmdLine.getOptionValue(CMD_PUT);
@@ -295,7 +298,7 @@ protected void executePut(CommandLine cmdLine) throws IOException, JMSException
TextMessage textMsg = sess.createTextMessage(data);
outMsg = textMsg;
}
-
+
MessageProducer mp = sess.createProducer(createDestination(cmdLine.getArgs()[0]));
if( cmdLine.hasOption("n")){;
mp.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
@@ -309,6 +312,16 @@ protected void executePut(CommandLine cmdLine) throws IOException, JMSException
if( cmdLine.hasOption("r")){
outMsg.setJMSReplyTo(createDestination(cmdLine.getOptionValue("r")));
}
+
+ if( cmdLine.hasOption(CMD_PRIORITY)){
+ try{
+ int priority = Integer.parseInt(cmdLine.getOptionValue(CMD_PRIORITY));
+ mp.setPriority(priority);
+ }catch(NumberFormatException nfe){
+ throw new NumberFormatException("JMSPriority has to be an integer value");
+ }
+ }
+
// send multiple messages?
if( cmdLine.hasOption("c")){
int count = Integer.parseInt(cmdLine.getOptionValue("c"));
diff --git a/src/test/java/com/libzter/a/ATestCases.java b/src/test/java/com/libzter/a/ATestCases.java
index bce995e..9f6d61c 100644
--- a/src/test/java/com/libzter/a/ATestCases.java
+++ b/src/test/java/com/libzter/a/ATestCases.java
@@ -4,6 +4,7 @@
import static com.libzter.a.A.CMD_GET;
import static com.libzter.a.A.CMD_PUT;
import static com.libzter.a.A.CMD_WAIT;
+import static com.libzter.a.A.CMD_PRIORITY;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -113,6 +114,18 @@ public void testPutQueue() throws Exception{
assertEquals("test",msg.getText());
}
+ @Test
+ public void testPutWithPriority() throws Exception{
+ final int priority = 6;
+ String cmdLine = CMD_LINE_COMMON + "-" + CMD_PRIORITY +" " + priority + " -" + CMD_PUT + "\"test\""
+ + " TEST.QUEUE";
+ a.run(cmdLine.split(" "));
+ MessageConsumer mc = session.createConsumer(testQueue);
+ TextMessage msg = (TextMessage)mc.receive(TEST_TIMEOUT);
+ assertEquals("test",msg.getText());
+ assertEquals(priority,msg.getJMSPriority());
+ }
+
@Test
public void testPutTopic() throws Exception{
String cmdLine = CMD_LINE_COMMON + "-" + CMD_PUT + "\"test\"" + " topic://TEST.TOPIC";