在Redhat MRG/Apache QPID中创建一个仅浏览队列



如何强制队列只能在Red Hat MRG/Apache QPID中浏览,以便客户端只能浏览队列。

我认为没有这样的选项来配置代理,但是您的客户端可以以仅浏览模式连接到队列。

direct://amq.direct//myqueue?browse=true

——编辑——

另一种让客户端使用browse_only队列的方法。

package foo.bar;
import java.util.Hashtable;
import java.util.Map;
import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.jndi.PropertiesFileInitialContextFactory;
import org.apache.qpid.jndi.ReadOnlyContext;
public class CustomPropertiesFileInitialContextFactory extends PropertiesFileInitialContextFactory {
    @SuppressWarnings({ "rawtypes", "unchecked" })
    @Override
    protected ReadOnlyContext createContext(Map data, Hashtable environment) {
        makeDestinationsReadOnly(data);
        return super.createContext(data, environment);
    }
    protected void makeDestinationsReadOnly(Map<String, AMQDestination> dests) {
        for(AMQDestination dest : dests.values()) {
            dest.setBrowseOnly(true);
        }
    }
}

最新更新