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

发布于 2024-12-17 04:09:04 字数 88 浏览 7 评论 0原文

如何强制只能在 Red Hat MRG/Apache QPID 中浏览队列,以便客户端只能浏览该队列。即使某些客户端尝试从队列中消费消息,他也应该无法做到这一点。

How can I enforce a queue to be browse only in Red Hat MRG/Apache QPID so that clients can only browse the queue. Even if some client tries to consume message off queue, he should not be able to do it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜声 2024-12-24 04:09:04

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

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

--编辑--

让客户端使用 browser_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);
        }
    }
}

I don't think there is such an option to configure the broker, but your clients can connect to the queue in browse-only mode.

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

--EDIT--

Another way to make clients use browse_only queues.

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);
        }
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文