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

Reactive Messaging JMS connector support #30943

Open
mpumd opened this issue Feb 7, 2023 · 15 comments
Open

Reactive Messaging JMS connector support #30943

mpumd opened this issue Feb 7, 2023 · 15 comments
Labels

Comments

@mpumd
Copy link

mpumd commented Feb 7, 2023

Description

Hi everybody,

Related to the zulip topic, https://quarkusio.zulipchat.com/#narrow/stream/187030-users/topic/Artemis.20jms.20.2B.20smallrye-jms.20connector, we are looking for a smart way to talk with jboss eap6 by jms message (configurable protocol like hornetq core). Initial tests works by the old school way (create factory -> connexion -> session...). With the quarkus-artemis-jms extension, we were able to inject a ConnectionFactory, and produce/consume messages against our hornetq broker. It compile natively.

@Path("/activemqjms2")
@RegisterForReflection(targets = { HornetQClientProtocolManagerFactory.class, ActiveMQConnectionFactory.class })
public class ActiveMQJMS2Resource {

    private static final Logger log = LoggerFactory.getLogger(ActiveMQJMS2Resource.class);     
    
    @Inject ConnectionFactory factory;     

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String connection() throws JMSException {
        
        Queue queue = ActiveMQDestination.createQueue(PacketImpl.OLD_QUEUE_PREFIX + QUEUE_NAME);
        
        try (Connection connection = factory.createConnection()) {
            int count = 0;
            connection.start();
            try (Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE)) {
                try (MessageProducer producer = session.createProducer(queue)) {
                    String text = "coucou at " + new Date();
                    for (int i = 0; i < 10; i++) {
                        producer.send(session.createTextMessage(text + " - " + i));
                    }
                }
                // session.commit();
            }
            log.info("sent 10 messages");
            try (Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE)) {
                try (MessageConsumer consumer = session.createConsumer(queue)) {
                    Message message = consumer.receive(2000);
                    while (message != null) {
                        if (message instanceof TextMessage textMessage) {
                            log.info("received " + textMessage.getText());
                        } else {
                            log.info("received " + message);
                        }
                        count++;
                        message = consumer.receive(2000);
                    }
                }
                // session.commit();
            }
            return "received messages: " + count;
        }
    }
}
<dependency>
    <groupId>io.quarkiverse.artemis</groupId>
    <artifactId>quarkus-artemis-jms</artifactId>
    <version>2.0.4</version>
</dependency>
<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>artemis-hqclient-protocol</artifactId>
    <version>2.26.0</version>
</dependency>
quarkus:
  artemis:
    url: (tcp://jboss1:5049,tcp://jboss2:5049)?protocolManagerFactoryStr=org.apache.activemq.artemis.core.protocol.hornetq.client.HornetQClientProtocolManagerFactory
    username: user
    password: pass

Although this is technically working, we would like an improved jms support, such as what is already provided by the smallrye jms connector.

here are the main requirements:

XA support is not a requirement.

here is what has been done on SB:

@Component
public class ValidationBrokerListener {     

    @JmsListener(
        destination = "com.x.jee.ValidationBroker.jms.Out.Queue",
        selector = "event = 'MyEvent' AND participant = 'X'",
        concurrency = "1-10")
    @Transactional
    public void processMessage(Message message) throws JMSException, InterruptedException {
        // ...
    }
}

or in the old days of EAP (nothing fancy):

@MessageDriven(name = "MyMDB", activationConfig = {
    @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
    @ActivationConfigProperty(propertyName = "maxSession", propertyValue = "${Messaging.maxSession:3}"),
    @ActivationConfigProperty(propertyName = "destination", propertyValue = "com/x/Messaging/MyQueue"),
    @ActivationConfigProperty(propertyName = "rebalanceConnections", propertyValue = "true") 
})
@ResourceAdapter("${MyRarName}")
public class MyMDB implements MessageListener {  
    public void onMessage(Message msg) {
        ...
    }
}

Many thanks.

Implementation ideas

No response

@mpumd mpumd added the kind/enhancement New feature or request label Feb 7, 2023
@quarkus-bot
Copy link

quarkus-bot bot commented Feb 7, 2023

You added a link to a Zulip discussion, please make sure the description of the issue is comprehensive and doesn't require accessing Zulip

This message is automatically generated by a bot.

@quarkus-bot
Copy link

quarkus-bot bot commented Feb 8, 2023

/cc @cescoffier (reactive-messaging), @ozangunalp (reactive-messaging)

@cescoffier cescoffier changed the title JMS support Reactive Messaging JMS connector support Feb 13, 2023
@vsevel
Copy link
Contributor

vsevel commented Mar 28, 2023

hello, have you considered this issue? what is the status? thanks

@cescoffier
Copy link
Member

We would like to do it, but we have other priorities at the moment (like getting Quarkus 3 out of the door).

@vsevel
Copy link
Contributor

vsevel commented Mar 28, 2023

ok. understood. thanks.

@vsevel
Copy link
Contributor

vsevel commented Jul 26, 2023

Hello, any news on this? Is it part of a roadmap? Thanks

@Serkan80
Copy link

Have you looked at SmallRye Reactive JMS ?

I’m currently also trying to use it, but it seems like the IBM MQ driver isn’t ported to Jakarta yet.

And I also find the documentation lacking. Besides adding the smallrye-jms dependency, I also had to add the quarkus-reactive-amqp & jakarta-jms-api to make my application at least startup without errors.

@vsevel
Copy link
Contributor

vsevel commented Jul 29, 2023

Thanks @Serkan80 . I missed the news

@vsevel
Copy link
Contributor

vsevel commented Jul 31, 2023

anybody knows if it supports:

  • connection pooling and concurrency configuration => yes from documentation
  • listener style consumer => yes from documentation
  • authentication => yes from documentation
  • participation in the managed quarkus transaction (single resource manager)?
  • selectors, with parameterisation if provided through annotation?
  • distributing consumers on both nodes of the targeted cluster : rebalanceConnections?

what version of quarkus does it work with?
thanks

@Serkan80
Copy link

See here for a list of available configurations and this will answer most of your questions.

what version of quarkus does it work with?

Currently, none. I was also struggling to make it work with Quarkus until I saw Clement saying in another thread that Quarkus doesn’t support reactive-jms and it’s really unfortunate.

However, you might have a chance using reactive messaging if your message broker supports amqp.

@cescoffier
Copy link
Member

Unfortunately, we still didn't have time to integrate (and improve) the JMS connector. While on the roadmap, I can't tell when we will do it.

@vsevel
Copy link
Contributor

vsevel commented Oct 10, 2023

we now use the ironjacamar extension

@vsevel vsevel closed this as completed Oct 10, 2023
@cescoffier
Copy link
Member

@vsevel Does ironjacamar integrate with reactive messaging? Handle the duplicated contexts and virtual threads?

If not, we should re-open this issue.

@vsevel
Copy link
Contributor

vsevel commented Oct 11, 2023

I would say no. although I have no idea on how to approach it.

@vsevel vsevel reopened this Oct 11, 2023
@Serkan80
Copy link

Serkan80 commented Dec 8, 2023

@vsevel I've made smallrye-reactive-jms work with IBM MQ, see my post on stackoverflow:

https://stackoverflow.com/questions/60885669/quarkus-ibm-mq-extension/77625283#77625283

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

No branches or pull requests

5 participants