2424
2525package cwms .cda .api .messaging ;
2626
27+ import hec .io .FilePath ;
28+ import hec .io .HecFileImpl ;
29+ import hec .util .XMLUtilities ;
2730import oracle .jms .AQjmsFactory ;
2831import org .apache .activemq .artemis .core .config .impl .ConfigurationImpl ;
32+ import org .apache .activemq .artemis .core .config .impl .FileConfiguration ;
2933import org .apache .activemq .artemis .core .server .ActiveMQServer ;
3034import org .apache .activemq .artemis .core .server .ActiveMQServers ;
3135import org .apache .activemq .artemis .jms .client .ActiveMQJMSConnectionFactory ;
3236import org .apache .camel .CamelContext ;
3337import org .apache .camel .builder .RouteBuilder ;
3438import org .apache .camel .component .jms .JmsComponent ;
3539import org .apache .camel .impl .DefaultCamelContext ;
40+ import org .w3c .dom .Document ;
41+ import org .w3c .dom .Element ;
3642
3743import javax .annotation .Resource ;
3844import javax .jms .ConnectionFactory ;
4147import javax .servlet .ServletContextListener ;
4248import javax .servlet .annotation .WebListener ;
4349import javax .sql .DataSource ;
50+ import javax .xml .parsers .DocumentBuilder ;
51+ import javax .xml .parsers .DocumentBuilderFactory ;
52+ import java .io .File ;
4453import java .net .InetAddress ;
4554
4655@ WebListener
@@ -58,15 +67,16 @@ public void contextInitialized(ServletContextEvent servletContextEvent) {
5867 camelContext = new DefaultCamelContext ();
5968 TopicConnectionFactory connectionFactory = AQjmsFactory .getTopicConnectionFactory (new DataSourceWrapper (cwms ), true );
6069 camelContext .addComponent ("oracleAQ" , JmsComponent .jmsComponent (connectionFactory ));
61- //TODO: determine how the port is configured
62- String activeMqUrl = "tcp://" + InetAddress .getLocalHost ().getHostName () + ":61616?protocols=STOMP&webSocketEncoderType=text" ;
63- ActiveMQServer server = ActiveMQServers .newActiveMQServer (new ConfigurationImpl ()
64- .addAcceptorConfiguration ("tcp" , activeMqUrl )
65- .setPersistenceEnabled (false )
66- // .setJournalDirectory("build/data/journal")
67- //Need to update to verify roles
68- .setSecurityEnabled (false )
69- .addAcceptorConfiguration ("invm" , "vm://0" ));
70+ File brokerXmlFile = new File ("src/test/resources/tomcat/conf/broker.xml" ).getAbsoluteFile ();
71+ DocumentBuilderFactory dbFactory = DocumentBuilderFactory .newInstance ();
72+ dbFactory .setNamespaceAware (true );
73+ DocumentBuilder dBuilder = dbFactory .newDocumentBuilder ();
74+ Document doc = dBuilder .parse (brokerXmlFile );
75+ doc .getDocumentElement ().normalize ();
76+ Element rootElement = doc .getDocumentElement ();
77+ FileConfiguration configuration = new FileConfiguration ();
78+ configuration .parse (rootElement , brokerXmlFile .toURI ().toURL ());
79+ ActiveMQServer server = ActiveMQServers .newActiveMQServer (configuration );
7080 ConnectionFactory artemisConnectionFactory = new ActiveMQJMSConnectionFactory ("vm://0" );
7181 camelContext .addComponent ("artemis" , JmsComponent .jmsComponent (artemisConnectionFactory ));
7282 camelContext .addRoutes (new RouteBuilder () {
0 commit comments