I'm trying to create an extension using quarkus in order to use ibm mq as for a native executable. Until now I've created (in the runtime module) the ConnectionFactory producer:
@ApplicationScoped
public class ConnectionFactoryProducer {
@Produces
@ApplicationScoped
@DefaultBean
public JmsConnectionFactory connectionFactory() throws JMSException {
JmsFactoryFactory ff;
JmsConnectionFactory factory;
ff = JmsFactoryFactory.getInstance(JmsConstants.WMQ_PROVIDER);
factory = ff.createConnectionFactory();
// Always work in TCP/IP client mode
factory.setIntProperty(CommonConstants.WMQ_CONNECTION_MODE, CommonConstants.WMQ_CM_CLIENT);
factory.setStringProperty(CommonConstants.WMQ_HOST_NAME, "localhost");
factory.setIntProperty(CommonConstants.WMQ_PORT, 1414);
factory.setStringProperty(CommonConstants.WMQ_CHANNEL, "DEV.ADMIN.SVRCONN");
factory.setStringProperty(CommonConstants.WMQ_QUEUE_MANAGER, "QM1");
factory.setStringProperty(WMQConstants.USERID, "admin");
factory.setStringProperty(WMQConstants.PASSWORD, "passw0rd");
return factory;
}
}
The deployment module contains the processor:
public final class IbmExtProcessor {
private static final String FEATURE = "ibm-ext";
@BuildStep
FeatureBuildItem feature() {
return new FeatureBuildItem(FEATURE);
}
}
Where FEATURE is the name of the extension.
But when I try to execute the code using the extension by importing it as a dependency in my project nothing happens. It looks like classes that use the dependency are no more in the application context. Example of a message producer:
public class NumberProducer implements Runnable {
private final Random random = new Random();
private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
@Inject
private ConnectionFactoryProducer cf;
private ConnectionFactory c;
void onStart(@Observes StartupEvent ev) throws JMSException {
c=cf.connectionFactory();
scheduler.scheduleWithFixedDelay(this, 0L, 1L, TimeUnit.SECONDS);
}
void onStop(@Observes ShutdownEvent ev) {
scheduler.shutdown();
}
@Override
public void run() {
JMSContext context = c.createContext();
Queue destination=context.createQueue("queue:///DEV.QUEUE.1");
try {
TextMessage message = context.createTextMessage(String.format("Value : %d", random.nextInt(100)));
JMSProducer producer = context.createProducer();
producer.send(destination, message);
System.out.println(message);
} catch (Exception e) {
throw e;
}
}
}
In this case i will never get the print of the message variable. Anyone can help? I think i've missed something in the extension but i can't figure out what could be.