|
ActiveMQ example source code file (SecurityJMXTest.java)
The ActiveMQ SecurityJMXTest.java source code/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.activemq.security; 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; import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXServiceURL; 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.slf4j.Logger; import org.slf4j.LoggerFactory; public class SecurityJMXTest extends TestCase { private static final Logger LOG = LoggerFactory.getLogger(SimpleAuthenticationPluginTest.class); private BrokerService broker; public void setUp() throws Exception { broker = createBroker(); broker.waitUntilStarted(); Thread.sleep(500); } public void tearDown() throws Exception { broker.stop(); } public void testMoveMessages() 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); 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 Other ActiveMQ examples (source code examples)Here is a short list of links related to this ActiveMQ SecurityJMXTest.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.