Try PubSub+
If you haven't already, check out our new Developer Portal! You'll find useful information about Solace PubSub+ as well as handy resources to get you started.

Solace Failover

BhumikaBhumika Member Posts: 5

I am using solace topic to send my message and session property in host has multiple comma separated ips (ip1:port1,ip2:port2).So in case of failover how do I know which IP I have connected to,i.e. which IP my message is sent to ?

Answers

  • TomFTomF Member, Employee Posts: 62 Solace Employee

    Hi @Bhumika, probably the easiest way is to look in the Solace API logs. For instance, at INFO level in JCSMP with my log4j.properties (level INFO) I see:
    Connecting to host 'orig=192.168.32.150, host=192.168.32.150' (host 1 of 1, smfclient 2, attempt 1 of 1, this_host_attempt: 1 of 1)
    You'll also get a session event during the connection process that you can look at. This will tell you when the connection is interrupted, when the reconnection is occurring, etc. In JCSMP these are enumerated in SessionEvent, and you can use SessionEvent.getInfo() to get the details.
    You can, of course, also query the broker. Go to the clients tab in PubSub+ Manager - if there are none, this is probably the broker that failed over. You should see your client in the other broker's client list.

  • BhumikaBhumika Member Posts: 5

    Thank You @TomF it was helpful, worked fine.

  • AaronAaron Member, Moderator, Employee Posts: 62 Solace Employee

    Hi @Bhumika! Out of curiosity, what is your use case? What are you trying to achieve, or know... and why? Thanks.

  • BhumikaBhumika Member Posts: 5

    hi @TomF ,I am using C# .NET and used SessionEventargs.info to get the host connected to before calling the session.connect..So would it be correct to know which host i am connected to?
    private void HandleSessionEvent(object sender, SessionEventArgs e)
    {
    try
    {

                // msg = String.Format("Session Event Received: '{0}' Type: '{1}' Text: '{2}' CorrelationTag: '{3}'", e.Event, e.ResponseCode.ToString(), e.Info, e.CorrelationKey)
                // MessageBox.Show(msg)
                //Added by Bhumika J on 27-Apr-2020||To capture host connected to in case of failover||START
                string msg;
              **  msg = e.Info;**
                oLogger.LogInformationMessage("Successfully Connected to :" + msg);
                //Added by Bhumika J on 27-Apr-2020||To capture host connected to in case of failover||END
             }
    

    }

  • TomFTomF Member, Employee Posts: 62 Solace Employee

    @Bhumika I don't think so - I think it returns the virtual router name, rather than the host ip or name. I suppose the next question is: what do you need this information for? What are you going to do with it?

  • BhumikaBhumika Member Posts: 5


    I just want to know which server my message went to.No operation I need to perform on it.

  • TomFTomF Member, Employee Posts: 62 Solace Employee

    OK, so does extracting the host name from the log do what you want? Just trying to make sure you have what you need.

Sign In or Register to comment.