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

When using the Request-Reply Pattern, Topics with the prefix “jms-tem-” are not successfully deleted after use. #135

Open
kaifahm opened this issue Apr 23, 2024 · 2 comments

Comments

@kaifahm
Copy link

kaifahm commented Apr 23, 2024

@kaifahm kaifahm changed the title No calls in the close close producer of logic in the com.datastax.oss.pulsar.jms.PulsarMessageProducer#close. No calls close producer of logic in the com.datastax.oss.pulsar.jms.PulsarMessageProducer#close. Apr 24, 2024
@kaifahm kaifahm changed the title No calls close producer of logic in the com.datastax.oss.pulsar.jms.PulsarMessageProducer#close. When using the Request-Reply Pattern, Topics with the prefix “jms-tem-” are not successfully deleted after use. Apr 25, 2024
@kaifahm
Copy link
Author

kaifahm commented Apr 25, 2024

After investigation, it was found that the producers associated with these temporary topics were not correctly closed, resulting in their failure to be successfully deleted. While tracing the code in com.datastax.oss.pulsar.jms.PulsarMessageProducer#close, it was observed that there is no logic to close the producer. The reason behind this is that the PulsarConnectionFactory caches the producer, which prevents it from being closed here. However, considering that these temporary topics are likely to be used only once, there should be no need to cache their producers.

@kaifahm
Copy link
Author

kaifahm commented Apr 25, 2024

I'm doing this for now, using com.datastax.oss.pulsar.jms.PulsarMessageProducer#close to determine if it's a temporary topic, and if so, closing the producer and removing it from the buffer. Would you like the author to help see if this is possible?😊

PulsarMessageProducer.java

  public void close() throws JMSException {
    Utils.checkNotOnMessageProducer(session, this);

    if (closed) {
      return;
    }

    PulsarDestination destination = (PulsarDestination) getDestination();
    if (destination.getName().contains("jms-temp-")) {
      Producer<?> producer = session.getProducerForDestination(destination);
      if (producer == null) {
        return;
      }
      try {
        producer.close();
        session.removeProducer(this);
        closed = true;
      } catch (Exception e) {
        throw Utils.handleException(e);
      }
    } else {
      closed = true;
    }
  }

PulsarSession.java

  public void removeProducerForDestination(Destination destination) throws JMSException {
    PulsarDestination pulsarDestination = (PulsarDestination) destination;
    String key = pulsarDestination.getName();
    getFactory().removeProducer(key);
  }

PulsarConnectionFactory.java

  public void removeProducer(String key) {
    producers.remove(key);
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant