nats.java icon indicating copy to clipboard operation
nats.java copied to clipboard

ServiceEndpoint 'group' field not not included in reported 'subject' during service discovery.

Open jimmydivvy opened this issue 3 years ago • 2 comments

Observed behavior

When specifying a 'group' on ServiceEndpoint.builder(), the 'subject' reported by service discovery is incorrect.

(A repository with an example test case is available here - https://github.com/jimmydivvy/jNatsEndpointGroupBug)

If we have the following ServiceEndpoint as part of a service named EchoService

ServiceEndpoint
        .builder()
        .endpointName("Echo")
        .endpointSubject("echo")
        .group(Group("acme"))

Then we expect it to listen on the subject 'acme.echo' - which it does.

However if we perform service discovery, the subject name is incorrectly reported as just 'echo'

nats micro info EchoService

Endpoints:

               Name: Echo
            Subject: echo

Expected behavior

Reported subject should include the group name (i.e. 'acme.subject'), matching the subject the service is actually listening on.

Server and client version

// Both provided by nix-pkgs
nats-server: v2.9.22
nats-cli: 0.1.1 
// JNats version
implementation("io.nats:jnats:2.17.0")

Host environment

MacOS Ventura 13.4

Steps to reproduce

  • Checkout the example repository (https://github.com/jimmydivvy/jNatsEndpointGroupBug)
  • Run nats-server on localhost
  • Run ./gradlew run

This will print out some assertions with expected and actual results

jimmydivvy avatar Oct 10 '23 08:10 jimmydivvy

Thanks for bring this to our attention. This will be fixed pretty soon.

scottf avatar Oct 11 '23 15:10 scottf

Fixed in https://github.com/nats-io/nats.java/pull/1010

scottf avatar Oct 19 '23 16:10 scottf