1

I am trying to publish a large text message to a Solace queue using Solace .NET APIs. And I have subscribed to that queue in a different JAVA application. It works absolutely fine when the message size is small. But if the message is large, subscriber cannot read the message.

        messageToPublish = readFile();
        IMessage message = ContextFactory.Instance.CreateMessage();
        message.Destination = queue;
        message.DeliveryMode = MessageDeliveryMode.Direct;
        //message.BinaryAttachment = Encoding.ASCII.GetBytes(messageToPublish);
        SDTUtils.SetText(message, messageToPublish);
        session.Send(message); 

Is there a way to run session.send(message) synchronously?

Thanks.

Dixit Gokhale
  • 601
  • 1
  • 12
  • 32

2 Answers2

1

It is possible that the Solace Appliance/Virtual Message Router(VMR) has discarded the message.

On the Appliance/VMR, you can take a look at the queue statistics to determine what has happened to the message. Double click on the queue's name in SolAdmin to display the following window.

SolAdmin - Ingress Spool Discard Statistics

In this screenshot, my message was discarded because the spool quota was exceeded. (Note that I had configured an extremely tiny quota for a quick reproduction.)


Do note that you've elected to use MessageDeliveryMode.Direct, which means that the message will be delivered through a reliable, but not guaranteed channel. There are no negative acknowlegements if a direct message cannot be delivered.

If the message must be guaranteed, MessageDeliveryMode.Persistent should be used. In the event that a message cannot be delivered, a RejectedMessageError session event will be triggered to indiciate that a problem has occured. You might want to refer to AdPubAck.cs sample code in the Solace .NET API for details.

Russell Sim
  • 1,693
  • 2
  • 14
  • 22
  • There are no messages discarded. I just checked the SolAdmin details. I have made the MessageDeliveryMode as Persistent. The problem is it's not able to publish the message successfully. As I mentioned previously, I have these 3 lines session.Dispose();context.Dispose();ContextFactory.Instance.Cleanup(); immediately after session.send(message). Whereas if I place Thread.Sleep(2000) in between session.send(message) and those 3 lines (dispose), message gets pushed successfully to the queue and subscriber picks it up and everything works as intended. – Dixit Gokhale Oct 19 '15 at 10:09
  • In this case, it looks like you've terminated/disposed the API before it was able to successfully publish the message. Do note that Guaranteed messages are only guaranteed to be published after the API has acknowledged that the message. You will need to wait for the SessionEvent.Acknowledgement session event before cleaning up the API. AdPubAck.cs is a good example to look at how to handle publish acknowledgement session events. – Russell Sim Oct 20 '15 at 11:06
0

There is also a possible printing bug with Eclipse. Are you able to verify whether the message was actually received by the Java application?

String myReceivedText = ((TextMessage) message).getText();
System.out.println("myReceivedText.length = " + myReceivedText.length());

If the message can be received with the correct length, then it is likely to be this Eclipse bug: java System.out.println() strange behavior long string

Running the Java application via the command line will display the long string.

Community
  • 1
  • 1
Russell Sim
  • 1,693
  • 2
  • 14
  • 22