【问题标题】:solclient send request resulting success and fail at the same timesolclient 发送请求导致成功并同时失败
【发布时间】:2022-12-02 20:15:10
【问题描述】:

I\'m starting a new project with Solace as the load balancer. As I follow the guideline on the official doc to build a service that can send requests to Solace, I encounter a weird issue where my request is successful and fails simultaneously. Here\'s my code

function initSolace(pass: string) {
  var factoryProps = new solace.SolclientFactoryProperties();
  factoryProps.profile = solace.SolclientFactoryProfiles.version10;
  solace.SolclientFactory.init(factoryProps);

  session = solace.SolclientFactory.createSession({
    \"url\": \"ws://localhost:8008\",
    \"userName\": \"tech_core\",
    \"vpnName\": \"testing\",
    \"password\": pass
  }, new solace.MessageRxCBInfo(messageRxCb));

  session.on(solace.SessionEventCode.UP_NOTICE, function (sessionEvent: any) {
    requestData(10000).subscribe();
  });

  session.connect();
}

async function messageRxCb(session: any, message: any) {
  message = Parser.decodeBinaryAttachmentToPb(message, pnlPb.RespPnl);
  console.log(\'result from RxCb\', message); // I got the correct response here
}

function requestData(timeout = 10000) {
  return new Observable(subscriber => {
    const parsedPayload = Parser.createPb({displayCurrency: \'USD\'}, pnlPb.ReqPnl);
    const msg = Parser.encodePbToBinaryAttachment(parsedPayload, pnlPb.ReqPnl);
    const request = solace.SolclientFactory.createMessage();

    request.setDestination(solace.SolclientFactory.createTopicDestination(\'my/testing/topic\'));
    request.setDeliveryMode(solace.MessageDeliveryModeType.DIRECT);
    request.setDeliverToOne(true);
    request.setBinaryAttachment(msg);
    session.sendRequest(request, timeout,
      (ses: any, message: any) => {
        console.log(\'SUCCESS\', message);
        subscriber.next(message);
      },
      (ses: any, event: any) => {
        console.error(\'FAIL\', event); // I got a timeout error here
        subscriber.error(event);
      },
      \'correlation test\'
    )
  });
}

As I run the code, I gets the timeout error from the requestData function AND the correct data from the messageRxCb function as well.

How does this happening? Did I miss any config here?

    标签: callback request timeout solace


    【解决方案1】:
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-06-30
    • 2016-06-18
    • 1970-01-01
    • 1970-01-01
    • 2021-05-19
    • 1970-01-01
    • 2020-04-06
    相关资源
    最近更新 更多