Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jms queue purge #1230

Open
bbortt opened this issue Oct 9, 2024 · 1 comment
Open

jms queue purge #1230

bbortt opened this issue Oct 9, 2024 · 1 comment
Labels
Prio: High State: To discuss In case there are open questions concerning the issue Type: Bug

Comments

@bbortt
Copy link
Collaborator

bbortt commented Oct 9, 2024

reported in https://citrusframework.zulipchat.com/#narrow/stream/259943-citrus/topic/Problems.20with.20purgeQueues.20action.

The purgeQueues-action does not work for me as expected; the queue does not seem to get purged.

For the setup: my system under tests receives a text/plain body via http/post and sends this body to an artemis topic.

For the test, I simply send some string to the system under test and then receive the corresponding JMS message. The JMS-setup on the citrus-side looks like this:

@Configuration
public class Jms {
  public static final String ENDPOINT = "JMS_ENDPOINT";
  public static final String CONNECTION_FACTORY = "CONNECTION_FACTORY";

  @Bean
  @Qualifier(CONNECTION_FACTORY)
  public ConnectionFactory purgeConnectionFactory(
      @Value("${test-config.artemis.url}") String url,
      @Value("${test-config.artemis.username}") String username,
      @Value("${test-config.artemis.password}") String password) {
    return new ActiveMQJMSConnectionFactory(url, username, password);
  }

  @Bean
  @Qualifier(ENDPOINT)
  public JmsEndpoint jmsEndpoint(
      @Qualifier(CONNECTION_FACTORY) ConnectionFactory connectionFactory,
      @Value("${test-config.artemis.receive.fqqn}") String fqqn) { // fqqn in this case is `messages::citrus`
    return new JmsEndpointBuilder()
        .connectionFactory(connectionFactory)
        .pubSubDomain(true)
        .destination(fqqn)
        .autoStart(true)
        .build();
  }
}

This works fine and as expected.

Now what I want to do is to clear the queue identified by the fqqn, so I implemented the following:

@Configuration
public class BeforeTestSequence {
  @Bean
  public SequenceBeforeTest beforeTest(
      @Qualifier(Jms.CONNECTION_FACTORY) ConnectionFactory connectionFactory,
      @Value("${test-config.artemis.receive.fqqn}") String fqqn) {
    return SequenceBeforeTest.Builder.beforeTest()
        .actions(
            purgeQueues()
                .connectionFactory(connectionFactory)
                .queue(fqqn))
        .build();
  }
}

This does not work as expected. In a "normal run", the test is green. However, if the queue messages::citrus already exists (from a previous run for example) and I write some message to that queue and THEN trigger the tests, the validation fails. The test "sees" the message i send beforehand, so the cleanup that should be happening does not happfen. In fact, I debugged into PurgeJmsQueuesAction::purgeDestination and the message received was always null.

If you need a full reproducer: https://github.com/turing85/citrus-playground/tree/feature/before-test-sequence

To reproduce:

start artemis (docker-compose --file local-deployment/docker-compose.yml up --detach)
start service (./mvnw --projects service quarkus:dev)
run the citrus tests however you like
To send an interfering message to the queue, execute the following curl after the tests have run at least once (i.e. after the queue for citrus was created)`:

curl -v -X POST localhost:8080/send --data "ouch" --header "Content-Type: text/plain"

If you want to access the artemis broker, go to localhost:8161/console, credentials are artemis/artemis.****

@bbortt
Copy link
Collaborator Author

bbortt commented Oct 9, 2024

cc: @turing85

@bbortt bbortt added State: To discuss In case there are open questions concerning the issue Type: Bug Prio: High labels Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Prio: High State: To discuss In case there are open questions concerning the issue Type: Bug
Projects
None yet
Development

No branches or pull requests

1 participant