What causes messages to go to Incoming Message Discards and how to prevent it

eosis
eosis Unconfirmed, Member Posts: 6

I have a producer calling send after invoking newTopicProducer.
Send looks successful, but not seeing it arrive at the queue that is set up for that topic.
Looking at the stats on the Solace UI, I just see the messages being discarded.
Are there tools to see why the messages are being discarded?

Tagged:

Comments

  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 538 admin
    edited December 2020 #2

    Hey @eosis ! Could you provide more information about your setup? a code snippet will help and how have you setup your Solace configuration? Are you publishing to a topic and you have a queue that is subscribed to this topic? do you also have any ACLs configured in your account? And how are you consuming the messages from your queue? This could help in understanding the issue you are facing better :)

  • eosis
    eosis Unconfirmed, Member Posts: 6

    I do have a queue subscribed to this topic. Below is PRODUCER info
    private static final String EVENT_TYPE = "x.y.z.a";

    private BusClient newBusClient() throws BusException {
        return com.boomi.bus.BusClient.builder().withCompressionEnabled(false)
                .withHost("tcps://mr16jp1pl891vj.messaging.solace.cloud:55443").withUsername("solace-cloud-client")
                .withPassword("g****").withVpn("ellenservice").build();
    }
    

    private xxPublisher() {
    _busClient = newBusClient();
    _producer = _busClient.newTopicProducer();
    }

    public CompletableFuture<Void> publish(Map<String, String> fields) {
        Event event = new Event(EVENT_TYPE)
              .withEventBody(OBJECT_MAPPER.valueToTree(fields)).withDestination(EVENT_TYPE);
        return _producer.send(event);   /// calls Solace producer
    
  • eosis
    eosis Unconfirmed, Member Posts: 6

    My consumer is setup. But, even without a consumer waiting on the queue, I would not understand why the message is being discarded. I think I should see the msg sent even without the consumer waiting???
    Thank you for trying to assist. Appreciate it
    try (BusClient client = newBusClient()) {
    client.createQueue(QUEUE_NAME);
    client.addSubscription(QUEUE_NAME, "x.y.z.a");
    consume(client, consumer);
    }
    Then, I consume like this:
    try {
    consumer = client.newQueueConsumer(QUEUE_NAME, new MessageListener() {
    @Override
    public void onMessageReceived(com.boomi.bus.Message msg) {
    handleMsg(msg);
    }
    @Override
    public void onError(BusException e) {
    ...
    }
    });
    consumer.start();
    while (true) {
    Thread.sleep(1000);
    }
    }

  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 538 admin

    Thanks for sharing your code snippet. Not sure what this API or wrapper you are using around the Solace API, however it’s important to know that direct messages published to the broker with no topic subscriptions will be dropped. Since the producer is instantiated from the wrapper it’s not clear if you’re attempting to send a direct or persistent message to the broker...

    One thing you can do to confirm your configuration is to send a message using the Try-Me tab that you can access from your service on the Solace Cloud PS+ manager. You can publish a message on topic x.y.z.a (as per your example) and see if it shows up in your queue (since i’m assuming you have configured your queue with the topic subscription). And if the message is in the queue, you can use the same try me tool to subscribe to the topic and consume messages published to the topic of choice.

    I would recommend checking out the samples on this github org as well. https://github.com/SolaceSamples. What you can do is use one of the samples to publish topics to your broker and you can subscribe either using one of the samples as well or the try me tab.

    One thing i want to point out from a Solace best practices perspective is the topic hierarchy. It’s not “wrong” to use periods to separate the levels, but using forward slashes “/“ in topics will help with leveraging wildcards. Check out more details here https://docs.solace.com/PubSub-Basics/Understanding-Topics.htm. You can subscribe to a wildcard “>” to see what topic the messages are published on.

    I hope this helps, let me know if you want more information.

  • TomF
    TomF Member, Employee Posts: 412 Solace Employee

    Hi @eosis, @Tamimi has some great advice above. One tool that will really help you is the output of:
    show message-vpn {Message VPN name} stats
    Buried in all those statistics are these metrics:

    Total Ingress Discards                                                      0
      No Subscription Match                                                     0
      Topic Parse Error                                                         0
      Parse Error                                                               0
      Message Too Big                                                           0
      Publish Topic ACL                                                         0
      Message Spool Congestion                                                  0
      Message Spool Ingress Discards                                            0
    

    These are what will help you identify why your ingress messages are being discarded. I suspect you might see the No Subscription Match counter climbing, as that's the most common cause. That will tell you that the topic that you are sending to doesn't match the subscription on the queue in the way you think.

    Pro Tip 1!

    Turn on "discard to sender on no subscription match":

    solace> enable
    solace#> configure
    solace(configure)# > client-profile {client profile name} message-vpn {Message VPN name}
    solace(configure/client-profile)# > message-spool
    solace((configure/client-profile/message-spool)#  > reject-msg-to-sender-on-no-subscription-match
    

    This will ensure your publishing app gets a negative acknowledgement, so you can see immediately there's a problem.

    Pro Tip 2!

    While debugging, turn on subscription match logging.

  • eosis
    eosis Unconfirmed, Member Posts: 6

    Thank you for your suggestions. I'll give them a try today!

  • Aaron
    Aaron Member, Administrator, Moderator, Employee Posts: 634 admin

    Note that detailed discard reasons are not provided in the current view of PubSub+ Manager. :-(

    So to run the commands that Tom is talking about, you'll have to go into the CLI shell on port 2222, and login with the management username/password.

  • eosis
    eosis Unconfirmed, Member Posts: 6

    I managed to get all messages properly handled by updating my topic.
    Are there instructions for installing CLI?

  • TomF
    TomF Member, Employee Posts: 412 Solace Employee

    CLI is already there on the broker. All you have to do is ssh to broker port 2222, or run docker exec -it <container_name> /usr/sw/loads/currentload/bin/cli -A if the broker is running in a container. See this section in the documentation.

  • eosis
    eosis Unconfirmed, Member Posts: 6

    Great, thanks all for your help! everything is working and I learned a lot!