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.
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);
}
}
}