Hide Forgot
Description of problem: Creating divert in CLI does not check whether referenced queues exists: /subsystem=messaging/hornetq-server=default/divert=badDivert:add(divert-address=badQueue,forwarding-address=badDivertQueue) {"outcome" => "success"} There should be check whether queues exists and fail they're not present.
Please note that divert deals only with *addresses*, not *queues*. Afaik, HornetQ does not expose a way to know whether an address _exists_ (meaning that there are queues bound to it). To be able to have the check you want, HornetQ should have to handle the check when creating the divert.
Miroslav, can you clarify why creating a divert for an address that has no bindings is a bad thing? I don't see anything wrong with this. First off, it is impossible for the "divert-address" to be invalid because HornetQ will create a "divert binding" on the address specified in the configuration. Second, even if the "forwarding-address" doesn't have any bindings at the time the divert is created, it could have bindings later. Consider, for example a JMS topic on which non-durable subscribers will come and go (and their corresponding bindings which will be created and removed).
I understand. My concern is about user who makes a typo in name of address. Then he'll notice it usually when server is running and already processing messages. We can still create a divert but some kind of warning would be great. What do you think?
Well, there's not much we can do for typos in the "divert-address". However, I suppose we could log a warning if there are no bindings on the "forwarding-address". That said, the warn message would go to the log file. I don't think it would make sense to have org.hornetq.core.management.impl.HornetQServerControlImpl.createDivert() return a piece of data that represented whether or not the "forwarding-address" had any bindings so the CLI wouldn't be able to display this warning (assuming it could display such a warning). Let me know if you want to proceed with this solution.
If CLI shows this warning then we should proceed with this. Otherwise I don't think it's worth of effort.
Jeff, actually it looks like you can attempt to get the AddressControl for the "forwarding-address" and respond appropriately if it doesn't exist. See org.jboss.as.messaging.AddressControlHandler#getAddressControl for an example. What do you think?
we can add a warning if the forwarding-address but that would not prevent the operation to succeed. The CLI user would not see the warning, it would only be displayed in the server logs
So if CLI operation is successful (but there are some problems) then CLI user cannot get any warning?