Author: gtully
Date: Fri Nov 27 08:23:13 2009
New Revision: 884779
URL: http://svn.apache.org/viewvc?rev=884779&view=rev
Log:
svn merge -c 884778 - resolve
https://issues.apache.org/activemq/browse/AMQ-2516 - broker send to dlq now
uses broker security context so it will bypass the authentication plugin when
configured
Modified:
activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java
activemq/branches/activemq-5.3/activemq-core/src/test/java/org/apache/activemq/security/SecurityJMXTest.java
Modified:
activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java
URL:
http://svn.apache.org/viewvc/activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java?rev=884779&r1=884778&r2=884779&view=diff
==============================================================================
---
activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java
(original)
+++
activemq/branches/activemq-5.3/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java
Fri Nov 27 08:23:13 2009
@@ -61,6 +61,7 @@
import org.apache.activemq.filter.BooleanExpression;
import org.apache.activemq.filter.MessageEvaluationContext;
import org.apache.activemq.filter.NonCachedMessageEvaluationContext;
+import org.apache.activemq.security.SecurityContext;
import org.apache.activemq.selector.SelectorParser;
import org.apache.activemq.store.MessageRecoveryListener;
import org.apache.activemq.store.MessageStore;
@@ -1291,6 +1292,7 @@
ConnectionContext answer = new ConnectionContext(new
NonCachedMessageEvaluationContext());
answer.setBroker(this.broker);
answer.getMessageEvaluationContext().setDestination(getActiveMQDestination());
+ answer.setSecurityContext(SecurityContext.BROKER_SECURITY_CONTEXT);
return answer;
}
Modified:
activemq/branches/activemq-5.3/activemq-core/src/test/java/org/apache/activemq/security/SecurityJMXTest.java
URL:
http://svn.apache.org/viewvc/activemq/branches/activemq-5.3/activemq-core/src/test/java/org/apache/activemq/security/SecurityJMXTest.java?rev=884779&r1=884778&r2=884779&view=diff
==============================================================================
---
activemq/branches/activemq-5.3/activemq-core/src/test/java/org/apache/activemq/security/SecurityJMXTest.java
(original)
+++
activemq/branches/activemq-5.3/activemq-core/src/test/java/org/apache/activemq/security/SecurityJMXTest.java
Fri Nov 27 08:23:13 2009
@@ -18,7 +18,13 @@
import java.net.URI;
+import java.util.HashMap;
+import java.util.concurrent.TimeUnit;
+import javax.jms.Connection;
+import javax.jms.DeliveryMode;
+import javax.jms.QueueBrowser;
+import javax.jms.Session;
import javax.management.MBeanServerConnection;
import javax.management.MBeanServerInvocationHandler;
import javax.management.ObjectName;
@@ -28,9 +34,11 @@
import junit.framework.TestCase;
+import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.broker.BrokerFactory;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.jmx.QueueViewMBean;
+import org.apache.activemq.command.ActiveMQQueue;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -46,6 +54,7 @@
}
public void tearDown() throws Exception {
+ broker.stop();
}
public void testMoveMessages() throws Exception {
@@ -58,6 +67,34 @@
String msgId = queueMbean.sendTextMessage("test", "system", "manager");
queueMbean.moveMessageTo(msgId, "TEST1.Q");
}
+
+
+ public void testBrowseExpiredMessages() throws Exception {
+ JMXServiceURL url = new
JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1199/jmxrmi");
+ JMXConnector connector = JMXConnectorFactory.connect(url, null);
+ connector.connect();
+ MBeanServerConnection connection =
connector.getMBeanServerConnection();
+ ObjectName name = new
ObjectName("org.apache.activemq:BrokerName=localhost,Type=Queue,Destination=TEST.Q");
+ QueueViewMBean queueMbean = (QueueViewMBean)
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("JMSDeliveryMode",
Integer.toString(DeliveryMode.PERSISTENT));
+ String msgId = queueMbean.sendTextMessage(headers, "test", "system",
"manager");
+ // allow message to expire on the queue
+ TimeUnit.SECONDS.sleep(3);
+
+ Connection c = new
ActiveMQConnectionFactory("vm://localhost").createConnection("system",
"manager");
+ c.start();
+
+ // browser consumer will force expriation check on addConsumer
+ QueueBrowser browser = c.createSession(false,
Session.AUTO_ACKNOWLEDGE).createBrowser(new ActiveMQQueue("TEST.Q"));
+ assertTrue("no message in the q",
!browser.getEnumeration().hasMoreElements());
+
+ // verify dlq got the message, no security exception as brokers
context is now used
+ browser = c.createSession(false,
Session.AUTO_ACKNOWLEDGE).createBrowser(new ActiveMQQueue("ActiveMQ.DLQ"));
+ assertTrue("one message in the dlq",
browser.getEnumeration().hasMoreElements());
+ }
+
protected BrokerService createBroker() throws Exception {
return
createBroker("org/apache/activemq/security/simple-auth-broker.xml");