Skip to content

Fix AMQP mock messages missing routing key for topic exchanges - #2005

Merged
lbroudoux merged 9 commits into
masterfrom
copilot/fix-amqp-mocks-routing-key
Mar 27, 2026
Merged

lbroudoux merged 9 commits into
masterfrom
copilot/fix-amqp-mocks-routing-key

Conversation

Copilot AI commented Mar 23, 2026 •

Copy link
Copy Markdown
Contributor
  • Add routingKey field to Binding.java domain model
  • Update AsyncAPICommons.completeOperationLevelBindings() to extract AMQP cc field as routing key
  • Update AMQPProducerManager.publishMessage() to accept and use a routing key parameter
  • Update ProducerManager.produceAMQPMockMessage() to pass routing key from binding
  • Add test AMQP AsyncAPI spec fixture with cc routing key binding
  • Add test assertions for routing key in AMQP binding parsing
  • Rebased onto latest master (8c017df)
  • Apply spotless formatting fixes to webapp module (single-line if/assertEquals)
  • Apply spotless formatting fixes to minions/async module (single-line channel.basicPublish and publishMessage calls)
  • Add .github/copilot-instructions.md with mvn spotless:apply reminder
Original prompt

This section details on the original issue you should resolve

<issue_title>AMQP mocks are missing routingKey</issue_title>
<issue_description>### Describe the bug

When you import an asyncapi.yaml file with amqp091 bindings for a topic exchange, the generated mock messages that are sent every couple of seconds won't include a routing key.

The asyncapi bindings mentions the 'cc' and 'bcc' field in the operations spec where you can define the routing Key. Additionally, the example there includes an address field which could perhaps also be used to host the routing key, although not specifically mentioned there? reference: https://github.com/asyncapi/bindings/blob/master/amqp/README.md

Expected behavior

I updated the example spec from here: https://github.com/microcks/api-lifecycle/blob/master/account-service-demo-amqp/account-service-asyncapi-1.2.0.yml to version 3.0.0 of the asyncapi spec with an operation including the CC field.

sample_file.yaml

When listening to the topic exchange that is created after importing this file, you should receive messages on the topic exchange, with the routing_key set to user.signed_up.

Actual behavior

Messages are published to the topic exchange, but routing key is set to None.

How to Reproduce?

importing the file mentioned in the expected behaviour section should reproduce the issue (if microcks version 1.13.2. is deployed with asyncAPI capabilities and rabbitmq is configured using values.yaml

Microcks version or git rev

1.13.2

Install method (docker-compose, helm chart, operator, docker-desktop extension,...)

helm chart

Additional information

If I follow the implementation in the microcks repository I cannot find any function call of the amqpPublisher that sets the routing key to anything other than an empty string (e.g.

channel.basicPublish(destinationName, "", properties, value.getBytes(StandardCharsets.UTF_8));
)
</issue_description>

Comments on the Issue (you are @copilot in this section)

@lbroudoux Seems totally legit as it looks like we're only doing a basic publish. I remember we're managing routing keys but it is only for tests, not for mocks.

📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Copilot AI changed the title [WIP] Fix AMQP mocks to include routing key in generated messages Fix AMQP mock messages missing routing key for topic exchanges Mar 23, 2026
Copilot AI requested a review from lbroudoux March 23, 2026 12:06
@lbroudoux

Copy link
Copy Markdown
Member

@copilot Can you rebase this PR?

dependabot Bot and others added 3 commits March 24, 2026 14:05
Bumps [lodash-es](https://github.com/lodash/lodash) from 4.17.21 to 4.17.23.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](lodash/lodash@4.17.21...4.17.23)

---
updated-dependencies:
- dependency-name: lodash-es
  dependency-version: 4.17.23
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Copilot AI commented Mar 24, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Can you rebase this PR?

Done — rebased onto the latest master (8c017df). The PR now sits cleanly on top of the two commits that landed in master since the branch was created (fix: #2008 and chore(deps): bump lodash-es).

@lbroudoux lbroudoux left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you didn't run mvn spotless:apply to format the code according to conventions. Please fix that.

Copilot AI commented Mar 24, 2026 •

Copy link
Copy Markdown
Contributor Author

It looks like you didn't run mvn spotless:apply to format the code according to conventions. Please fix that.

Fixed in commit 0266890. The CI logs showed two violations: the if condition in AsyncAPICommons.java and the assertEquals in the test both needed to fit on a single line (each was within the 120-char limit).

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • archive.eclipse.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.13/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.13/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.13 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.13/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/microcks/microcks/webapp org.codehaus.plexus.classworlds.launcher.Launcher spotless:apply -q (dns block)
    • Triggering command: /usr/bin/curl curl -s --max-time 5 REDACTED potless-maven-plugin-2.39.0.jar (dns block)
    • Triggering command: /usr/bin/curl curl -v --max-time 10 REDACTED ib-2.41.0.jar (dns block)
  • packages.confluent.io
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.13/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.13/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.13 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.13/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/microcks/microcks org.codehaus.plexus.classworlds.launcher.Launcher install -pl commons/model,commons/util,commons/el,webapp -Dtest=AsyncAPIImporterTest#testAsyncAPIWithAMQPBindingRoutingKey -DfailIfNoTests=false -am -q (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@lbroudoux lbroudoux left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lbroudoux
lbroudoux marked this pull request as ready for review March 26, 2026 14:33
@lbroudoux
lbroudoux requested a review from yada as a code owner March 26, 2026 14:33
@lbroudoux

Copy link
Copy Markdown
Member

@copilot looks like we still have formatting issues... Look at https://github.com/microcks/microcks/actions/runs/23300705129/job/67761951191?pr=1993#step:4:1600

Please format code with mvn spotless:apply on all the changes.

Copilot AI commented Mar 26, 2026 •

Copy link
Copy Markdown
Contributor Author

@copilot looks like we still have formatting issues... Look at https://github.com/microcks/microcks/actions/runs/23300705129/job/67761951191?pr=1993#step:4:1600

Please format code...

Fixed in commit 03ffd02. The CI showed two spotless violations in the minions/async module: channel.basicPublish(...) and amqpProducerManager.publishMessage(...) each needed their arguments joined onto a single line to satisfy the 120-char limit rule.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • archive.eclipse.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.14/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.14/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.14 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.14/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/microcks/microcks org.codehaus.plexus.classworlds.launcher.Launcher spotless:apply -pl minions/async -q (dns block)
  • packages.confluent.io
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.14/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.14/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.14 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.14/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/microcks/microcks org.codehaus.plexus.classworlds.launcher.Launcher spotless:apply -pl minions/async -q (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from lbroudoux March 26, 2026 14:43
@SebastienDegodez

Copy link
Copy Markdown
Member

@copilot looks like we still have formatting issues... Look at https://github.com/microcks/microcks/actions/runs/23300705129/job/67761951191?pr=1993#step:4:1600

Please format code with mvn spotless:apply on all the changes.

@copilot update github-instructions with this, it's MANDATORY !

Copilot AI commented Mar 26, 2026

Copy link
Copy Markdown
Contributor Author

@copilot looks like we still have formatting issues... Look at https://github.com/microcks/microcks/actions/runs/23300705129/job/67761951191?pr=1993#step:4:1600

Please forma...

Updated in commit 0616883 — the section heading is now "Code Formatting — MANDATORY", the opening sentence uses bold to stress it must run before every Java commit, and a final reminder block reinforces there are no exceptions.

@lbroudoux lbroudoux added this to the 1.14.0 milestone Mar 27, 2026

@lbroudoux lbroudoux left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lbroudoux
lbroudoux merged commit 870ccaa into master Mar 27, 2026
18 of 19 checks passed
@lbroudoux
lbroudoux deleted the copilot/fix-amqp-mocks-routing-key branch March 27, 2026 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AMQP mocks are missing routingKey

3 participants