activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r1480189 - in /activemq/trunk: activemq-broker/src/main/java/org/apache/activemq/broker/jmx/ activemq-unit-tests/src/test/java/org/apache/activemq/security/
Date Wed, 08 May 2013 09:15:17 GMT
Author: dejanb
Date: Wed May  8 09:15:17 2013
New Revision: 1480189

URL: http://svn.apache.org/r1480189
Log:
https://issues.apache.org/jira/browse/AMQ-4522 - set timeToLive when sending a message using
JMX

Modified:
    activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/DestinationView.java
    activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/DestinationViewMBean.java
    activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/SecurityJMXTest.java

Modified: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/DestinationView.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/DestinationView.java?rev=1480189&r1=1480188&r2=1480189&view=diff
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/DestinationView.java
(original)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/DestinationView.java
Wed May  8 09:15:17 2013
@@ -299,7 +299,7 @@ public class DestinationView implements 
     }
 
     @Override
-    public String sendTextMessage(Map headers, String body, String userName, String password)
throws Exception {
+    public String sendTextMessage(Map<String, String> headers, String body, String
userName, String password) throws Exception {
 
         String brokerUrl = "vm://" + broker.getBrokerName();
         ActiveMQDestination dest = destination.getActiveMQDestination();
@@ -320,7 +320,15 @@ public class DestinationView implements 
 
             producer.setDeliveryMode(msg.getJMSDeliveryMode());
             producer.setPriority(msg.getPriority());
-            long ttl = msg.getExpiration() - System.currentTimeMillis();
+            long ttl = 0;
+            if (msg.getExpiration() != 0) {
+                ttl = msg.getExpiration() - System.currentTimeMillis();
+            } else {
+                String timeToLive = headers.get("timeToLive");
+                if (timeToLive != null) {
+                    ttl = Integer.valueOf(timeToLive);
+                }
+            }
             producer.setTimeToLive(ttl > 0 ? ttl : 0);
             producer.send(msg);
 

Modified: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/DestinationViewMBean.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/DestinationViewMBean.java?rev=1480189&r1=1480188&r2=1480189&view=diff
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/DestinationViewMBean.java
(original)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/DestinationViewMBean.java
Wed May  8 09:15:17 2013
@@ -181,7 +181,7 @@ public interface DestinationViewMBean {
      * @throws Exception
      */
     @MBeanInfo("Sends a TextMessage to a password-protected destination.")
-    String sendTextMessage(@MBeanInfo("headers") Map<?,?> headers, @MBeanInfo("body")
String body, @MBeanInfo("user") String user, @MBeanInfo("password") String password) throws
Exception;
+    String sendTextMessage(@MBeanInfo("headers") Map<String,String> headers, @MBeanInfo("body")
String body, @MBeanInfo("user") String user, @MBeanInfo("password") String password) throws
Exception;
     /**
      * @return the percentage of amount of memory used
      */

Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/SecurityJMXTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/SecurityJMXTest.java?rev=1480189&r1=1480188&r2=1480189&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/SecurityJMXTest.java
(original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/security/SecurityJMXTest.java
Wed May  8 09:15:17 2013
@@ -79,7 +79,7 @@ public class SecurityJMXTest extends Tes
                 "destinationType=Queue,destinationName=TEST.Q");
         QueueViewMBean queueMbean = MBeanServerInvocationHandler.newProxyInstance(connection,
name, QueueViewMBean.class, true);
         HashMap<String, String> headers = new HashMap<String, String>();
-        headers.put("JMSExpiration", Long.toString(System.currentTimeMillis() + 2000));
+        headers.put("timeToLive", Long.toString(2000));
         headers.put("JMSDeliveryMode", Integer.toString(DeliveryMode.PERSISTENT));
         queueMbean.sendTextMessage(headers, "test", "system", "manager");
         // allow message to expire on the queue



Mime
View raw message