From 23a46b4be35277e06ec89f48730eeb694e686be8 Mon Sep 17 00:00:00 2001
From: Kenmegne <stephanie.kenmegne@gmail.com>
Date: Thu, 18 Jun 2026 15:40:06 +0000
Subject: [PATCH] add fdx-commons and fdx-consultation

---
 fdx-consultation/fdxconsultation-service-impl/src/main/java/com/megatim/fdxconsultation/service/impl/camel/CamelBootstrap.java |   78 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 78 insertions(+), 0 deletions(-)

diff --git a/fdx-consultation/fdxconsultation-service-impl/src/main/java/com/megatim/fdxconsultation/service/impl/camel/CamelBootstrap.java b/fdx-consultation/fdxconsultation-service-impl/src/main/java/com/megatim/fdxconsultation/service/impl/camel/CamelBootstrap.java
new file mode 100644
index 0000000..2bb699b
--- /dev/null
+++ b/fdx-consultation/fdxconsultation-service-impl/src/main/java/com/megatim/fdxconsultation/service/impl/camel/CamelBootstrap.java
@@ -0,0 +1,78 @@
+package com.megatim.fdxconsultation.service.impl.camel;
+
+import com.megatim.fdxcommons.model.camel.BrokerProperties;
+import com.megatim.fdxcommons.model.camel.FileProperties;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.annotation.PostConstruct;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import javax.enterprise.event.Observes;
+import javax.inject.Inject;
+import org.apache.camel.cdi.CdiCamelConfiguration;
+import org.apache.camel.cdi.CdiCamelContext;
+import org.apache.camel.component.rabbitmq.RabbitMQComponent;
+
+@Singleton
+@Startup
+public class CamelBootstrap {
+
+    @Inject
+    private CdiCamelContext camelContext;
+
+    @PostConstruct
+    public void init() {
+        try {
+            FileProperties fileProperties = new FileProperties(com.megatim.fdxcommons.tools.context.AppContext.BROKER_FILE_PATH);
+
+            // Add RabbitMQ Component with connection details
+            RabbitMQComponent rabbitMQComponent = new RabbitMQComponent();
+            rabbitMQComponent.setHostname(brokerHostName(fileProperties));
+            rabbitMQComponent.setPortNumber(brokerPortNumber(fileProperties));
+            rabbitMQComponent.setUsername(brokerUserName(fileProperties));
+            rabbitMQComponent.setPassword(brokerPassword(fileProperties));
+
+            camelContext.addComponent("rabbitmq", rabbitMQComponent);
+
+            camelContext.start();
+        } catch (IOException ex) {
+            Logger.getLogger(CamelBootstrap.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
+        }
+    }
+
+    public static void configuration(@Observes CdiCamelConfiguration configuration) {
+
+        System.out.println("<-------------------------------------------------------------------------------------------->");
+        System.out.println("<-------------------------------------------------------------------------------------------->");
+        System.out.println("<-------------------------------------------------------------------------------------------->");
+        System.out.println("<-------------------------------------------------------------------------------------------->");
+        System.out.println("<-------------------------------------------------------------------------------------------->");
+
+        System.out.println("INSIDE CONFIGURE OF ROUTE");
+
+        System.out.println("<-------------------------------------------------------------------------------------------->");
+        System.out.println("<-------------------------------------------------------------------------------------------->");
+        System.out.println("<-------------------------------------------------------------------------------------------->");
+        System.out.println("<-------------------------------------------------------------------------------------------->");
+
+//        configuration.autoConfigureRoutes(false);
+        configuration.autoStartContexts(false);
+    }
+
+    private String brokerHostName(FileProperties fileProperties) throws IOException {
+        return fileProperties.properties().getProperty(BrokerProperties.HOSTNAME);
+    }
+
+    private int brokerPortNumber(FileProperties fileProperties) throws IOException {
+        return Integer.parseInt(fileProperties.properties().getProperty(BrokerProperties.PORT_NUMBER));
+    }
+
+    private String brokerUserName(FileProperties fileProperties) throws IOException {
+        return fileProperties.properties().getProperty(BrokerProperties.USER_NAME);
+    }
+
+    private String brokerPassword(FileProperties fileProperties) throws IOException {
+        return fileProperties.properties().getProperty(BrokerProperties.PASSWORD);
+    }
+}

--
Gitblit v1.10.0