Test REST Consumers against a Mock

Hello, I am trying to test the following scenario:
I publish a mesage to a topic called rest, and then A rest Consumer picks that mesasge up and sends it to the mock server.

Is this scenario possible?
If so, i'll be running a postman mock and Solace will be running localy on Docker(I think i might run into some ssl problems).

Comments

  • arih
    arih Member, Employee Posts: 125 Solace Employee

    hi @PedromDimas

    Yes that is possible with RDP, where basically you'll have a Queue subscribing to the topic and then binding that Queue to a REST Delivery Point that will act as a REST client for your mock server.

    Here's one code labs that might be useful.

    In addition to that, couple of points I'd like to promote around RDP:

    • learn more about the dynamic stuff, which is the substitution expression documented here.
    • the topic can be many, and with finer grain topic name, the Queue can then subscribes with a wildcard to make things more interesting and flexible.
  • PedromDimas
    PedromDimas Member Posts: 11

    Hello @arih !
    Many thanks for the information!
    I will analyse the materials that you mentioned!

  • PedromDimas
    PedromDimas Member Posts: 11

    Hello again @arih
    After following the steps on the code labs i got an error which is wierd and i dont know how to solve this.

    So, i configured ngrock to forward localhost:3000 where i had a mock server running.
    After that i followed all the steps on the code lab and ended up with this error:

    Destination unreachable seemed wierd so i opened a terminal inside the docker container of solace and did a curl to the ngrock and it worked.
    Does any one know why this happened?

  • arih
    arih Member, Employee Posts: 125 Solace Employee

    Hi @PedromDimas

    I'm not familiar with Ngrock, or maybe it's Ngrok?

    While I'm looking at that, can you try curl-ing host.docker.internal:3000 from Solace container first?

  • arih
    arih Member, Employee Posts: 125 Solace Employee

    Wait, the error there is for the 'last' failure, doesn't mean it's still happening. I just realised the op status is actually Up in the picture there :)

    check the RDP page and REST consumer page if everything is green / up.'

    if you still don't see the event in your mock server, then something else is going on.

  • PedromDimas
    PedromDimas Member Posts: 11

    This is my mock setup:
    the server running on my localhost:3000

    ngrok tunneling it

    a queue called rest-q

    subscribed to topic rest

    One rest client called rdp-rest
    which is down


    One rest Consumer
    which is down


    one queu-binding to rest-q

    This is my brest consumer

    The way i am testing it is i use the try me and publish to rest topic

    Solace is running in docker on my local machine.

    the curl

    the curl to my ngrok

    The solace container can reach my ngrok.
    I do not know where i failed :disappointed:

  • PedromDimas
    PedromDimas Member Posts: 11

    And @arih
    Thank you so much for the help!

  • arih
    arih Member, Employee Posts: 125 Solace Employee
    edited November 2021 #9

    Okay, so I did some tests on my own, and it seems Ngrok can give you different destination each time. I've seen the remote endpoint sometimes up and sometimes down and having different address each time :)

    When it works it works, but when it's not it can be a peer TCP closed, or it can be unreachable, or other errors. So for now I think relying on Ngrok is not a good idea :)

    I'm assuming Ngrok is just for dev or for convenience anyway, not production setup right?

    So I suggest to just rely on docker networking instead. What OS are you running? I just searched and it seems for Linux you need to enable the host.docker.internal first. See here: https://medium.com/@TimvanBaarsen/how-to-connect-to-the-docker-host-from-inside-a-docker-container-112b4c71bc66

  • PedromDimas
    PedromDimas Member Posts: 11

    Ngrok is being used just for conevenience while developing, no production.

    I'll try to use docker netwoking.
    Thank you!