🎄 Happy Holidays! 🥳

Most of Solace is closed December 24–January 1 so our employees can spend time with their families. We will re-open Thursday, January 2, 2024. Please expect slower response times during this period and open a support ticket for anything needing immediate assistance.

Happy Holidays!

Please note: most of Solace is closed December 25–January 2, and will re-open Tuesday, January 3, 2023.

Selector on Browser, how to do?

Hi all,
I try to filter a specific message of a queue I want to delete (I have the message ID from a call before).
How to set the selector?
this is my code and I tried a lot of variations on the selector
for example
mi = '485'
mi = 485
JMSMessageID = 485
JMSMessageID = '485'
etc.
when I browse via the console and select a message the only parameter is the message ID so what is the actual call (with java) to delete that message?

below my java code:

 public Boolean DeleteMessageWithBrowser(String destination, int waitTimeout, String messageId) {
        try {
            session = JCSMPFactory.onlyInstance().createSession(properties);
            session.connect();

            queue = JCSMPFactory.onlyInstance().createQueue(destination);
            BrowserProperties br_prop = new BrowserProperties();
            br_prop.setEndpoint(queue);
            br_prop.setTransportWindowSize(1);
            br_prop.setSelector("mi = '"+messageId+"'"); 
            br_prop.setWaitTimeout(waitTimeout);
            Browser myBrowser = session.createBrowser(br_prop); 
            myBrowser.remove(myBrowser.getNext());
            myBrowser.close();
         }
         catch (JCSMPException e) {
             _logNode.debug("Error when getting message, session close. Error: "+e.getMessage());
             if( session != null && !session.isClosed() ) {
                 session.closeSession();
             }
        }   
        finally {
         if( session != null && !session.isClosed() ) {
                _logNode.debug("Message browsed. Exiting.");
                session.closeSession();
         }
     }
        return true;
    }

thx!

Tagged:

Comments

  • pruffieux
    pruffieux Member Posts: 14 ✭✭

    I have the same issue.

    I also tried the JMS messaging api like this:

     jmsTemplate.browseSelected(queueToBrowse, selector, (session, browser) -> {
                Enumeration<SolMessage> enumeration = browser.getEnumeration();
                …
                
    

    with selector using the same key values "mi" or "JMSMessageID" but none of them are working.

    It seems the JMS Header is not automatically set with the internal message Id when I check with JMS Toolbox.

    If anyone has a solution (jcmp or jms) it would be nice.