It has been pointed out that the above proposal would require existing applications would need to cast the MessageConsumer that is returned down to a TopicSubscriber.
This suggests that we need to provide new versions of this method which return a MessageConsumer. This would allow us to mark the old methods as deprecated and propose them for removal.
We can't simply add new methods with the same name which return a MessageConsumer since the compiler would consider these duplicate methods.
Two options have been proposed:
We could define new methods named createConsumer:
MessageConsumer createConsumer(Topic topic, java.lang.String name)
MessageConsumer createConsumer(Topic topic, java.lang.String name, java.lang.String messageSelector, boolean noLocal)
However there's potential confusion between the first of those methods and the existing method to create an ordinary consumer with a message selector:
MessageConsumer createConsumer(Destination destination, java.lang.String messageSelector)
The compiler would allow it, but if the user tried to create a durable subscription using a variable which was really a Topic but which was declared as Destination then the wrong method would be called.
It could also be argued that removing the word "durable" from the method name would be confusing for users.
We could either live with these drawbacks, or we could use:
We could define new methods named createDurableConsumer:
MessageConsumer createDurableConsumer(Topic topic, java.lang.String name)
MessageConsumer createDurableConsumer(Topic topic, java.lang.String name, java.lang.String messageSelector, boolean noLocal)