How do I clear entries from solcache?

anawatts
anawatts Member Posts: 4

I'm using solcache and instead of getting our admins to reset the cache, it would be nice to be able to use the Java API to clear entries. I'm not seeing any way to do this. Can you help, or do I need full admin privileges to do so?

Best Answer

  • [Deleted User]
    [Deleted User] Posts: 0 ✭✭
    #2 Answer ✓

    There are a few ways of going about this, with the easiest being to request that you admin(s) grant you a limited management account with only RW on your message-vpn. This enables you to use SolAdmin to manage your VPN.

    If that's not an option, then the other way would be sending a SEMP command over the message bus. You would publish the below message to topic #SEMP/<router_name>/ADMIN/DISTRIBUTED-CACHE:

    <rpc>
        <admin>
            <distributed-cache>
                <name>myDistributedCacheName</name>
                <vpn-name>myVpnName</vpn-name>
                <delete-messages>
                    <topic>my/topic/name</topic>
                </delete-messages>
            </distributed-cache>
        </admin>
    </rpc>
    

    You can use wildcards in the topic string, so for example using a topic string of > will delete all messages in the cache..

    A few things to note is that your message-vpn must be configured with the following options:

    • Allow SEMP over Message Bus
    • Allow Admin Commands
    • Allow Distributed Cache Commands

    You can find more info around enabling these features in your message-vpn here, with details on Publishing SEMP Requests over the Message Bus here. We also have a SempGetOverMB.java sample that is provided with the Solace Java API.

    I hope this helps!

Answers

  • [Deleted User]
    [Deleted User] Posts: 0 ✭✭
    #3 Answer ✓

    There are a few ways of going about this, with the easiest being to request that you admin(s) grant you a limited management account with only RW on your message-vpn. This enables you to use SolAdmin to manage your VPN.

    If that's not an option, then the other way would be sending a SEMP command over the message bus. You would publish the below message to topic #SEMP/<router_name>/ADMIN/DISTRIBUTED-CACHE:

    <rpc>
        <admin>
            <distributed-cache>
                <name>myDistributedCacheName</name>
                <vpn-name>myVpnName</vpn-name>
                <delete-messages>
                    <topic>my/topic/name</topic>
                </delete-messages>
            </distributed-cache>
        </admin>
    </rpc>
    

    You can use wildcards in the topic string, so for example using a topic string of > will delete all messages in the cache..

    A few things to note is that your message-vpn must be configured with the following options:

    • Allow SEMP over Message Bus
    • Allow Admin Commands
    • Allow Distributed Cache Commands

    You can find more info around enabling these features in your message-vpn here, with details on Publishing SEMP Requests over the Message Bus here. We also have a SempGetOverMB.java sample that is provided with the Solace Java API.

    I hope this helps!

  • anawatts
    anawatts Member Posts: 4

    That did it! Thanks!