1

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.

MoveFast
  • 3,011
  • 2
  • 27
  • 53
  • Can you elaborate on your use case? Why do you want a queue, with clients browsing but never consuming? Who consumes a message? Would a database be better for your work flow? – philwb Nov 28 '11 at 14:28

1 Answers1

3

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);
        }
    }
}
szhem
  • 4,672
  • 2
  • 18
  • 30
  • I want to enforce this option. This way it is upon to discretion of client to choose browse only. – MoveFast Nov 25 '11 at 12:13
  • 1
    Currently there is no way to do what you want on the broker's side. You have to make your clients use browse_only option somehow. For example by means of custom _PropertiesFileInitialContextFactory_ like in my edited answer. – szhem Nov 28 '11 at 11:47
  • Agree with mijer, besides a browse only queue does not fit the jms model. – jkysam Nov 28 '11 at 15:21
  • @mijer I need something that can be enforced on the broker. this way if a client wants to consumer some message, he can do this without anyone stopping him. – MoveFast Nov 30 '11 at 04:56
  • @ManojGumber, what is your usecase? With current implementation of MRG/qpid you cannot do it. At least you can be convinced of it by contacting MRG support. If you need `N` clients to consume the same message consider using one exchange that is binded to `N` queues. Then make each client consume messages only from its own queue. To restrict access of each client to not permitted queues there are [access control lists](https://cwiki.apache.org/qpid/acl.html) – szhem Nov 30 '11 at 05:27
  • @mijer My usecase is there is some data (which can be few million messages) that I want all clients to get whenever they come up. Having different queues for each, too much resources it will take. The same work a single queue can do but it has to be browse only enforced queue. Because I do not want that one client consumes the messages and others are deprived of it. I am talking with Redhat folks and will updates on what they say – MoveFast Nov 30 '11 at 07:12