1

I am using the dependency in my pom.xml

<dependency>
    <groupId>org.amqphub.quarkus</groupId>
    <artifactId>quarkus-qpid-jms</artifactId>
</dependency>

my yml properties file

quarkus:
   qpid-jms: amqp:url:port
   username: username
   password: password

I have a class like

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.jms.ConnectionFactory;
import javax.jms.JMSContext;
import javax.jms.JMSRuntimeException;
import javax.jms.Session;
import org.apache.camel.Exchange;
import org.apache.camel.Proccesor;

@ApplicationScoped
public class JMSProducer implements Processor {
    @Inject
    ConnectionFactory connectionFactory;

    @Override
    public void process(Exchange exchange) throws Exception {
        try (JMSContext context = connectionFactory.createContext(Session.AUTO_ACKNOWLEDGE)){
            context.createProducer().send(context.createQueue("my_queue"), exchange.getMessage().getBody(String.class));
        } catch (JMSRuntimeException ex) {}
    }
}

After this I call this class as a bean in a procces of my apache camel route.

I'm new to these issues, I hope you can help me.

1 Answers1

1

If you want to use Camel and AMQP to produce messages to a queue, then you can use the camel-quarkus-amqp extension. It uses quarkus-qpid-jms. You can add a dependency for it like this.

<dependency>
    <groupId>org.apache.camel.quarkus</groupId>
    <artifactId>camel-quarkus-amqp</artifactId>
</dependency>

Then define your connection configuration in application.yml.

quarkus:
  qpid-jms:
    url: your connection url
    username: your username
    password: your password

A simple Camel route to produce a message to a queue might look like this.

public class Routes extends RouteBuilder {

    public void configure() throws Exception {
        from("direct:sendMessage")
                .to("amqp:queue:myQueue");
    }
}

Note: to use the direct endpoint you need camel-quarkus-direct added as a dependency.

There is more information in the Camel & Camel Quarkus documentation:

https://camel.apache.org/camel-quarkus/2.16.x/reference/extensions/amqp.html

https://camel.apache.org/components/3.20.x/amqp-component.html

James Netherton
  • 1,092
  • 1
  • 7
  • 9