Deleting all messages in JMS queue in Widlfy 9

北城以北 提交于 2019-12-10 19:20:46

问题


I am trying to remove messages from JMS queue on Wildfly 9.0.2 (JBoss) using JMX, see following code:

    MBeanServer server = ManagementFactory.getPlatformMBeanServer();

    try {
        String name = "jboss.as.expr:subsystem=messaging,hornetq-server=default,jms-queue=MyQueue";
        ObjectName objectName = new ObjectName(objectNameString);
        String result = (String) server.invoke(objectName, "removeMessages", new Object[]{null},
                new String[]{"java.lang.String"});
        return result;
    } catch (MalformedObjectNameException | InstanceNotFoundException | MBeanException | ReflectionException ignored) {
        log.errorv(ignored, "Error removing messages from JMS queue [{0}]", name);
        return null;
    }

There is an active consumer on that queue. The code runs without exception and returns string "0", but no messages are actually removed. I tried also to use some value as message filter (*), but got failure:

    javax.management.ReflectionException: "HQ119020: Invalid filter: *"

Any idea how to remove the messages?

来源:https://stackoverflow.com/questions/38974400/deleting-all-messages-in-jms-queue-in-widlfy-9

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!