24
24
25
25
package cwms .cda .api .messaging ;
26
26
27
+ import hec .io .FilePath ;
28
+ import hec .io .HecFileImpl ;
29
+ import hec .util .XMLUtilities ;
27
30
import oracle .jms .AQjmsFactory ;
28
31
import org .apache .activemq .artemis .core .config .impl .ConfigurationImpl ;
32
+ import org .apache .activemq .artemis .core .config .impl .FileConfiguration ;
29
33
import org .apache .activemq .artemis .core .server .ActiveMQServer ;
30
34
import org .apache .activemq .artemis .core .server .ActiveMQServers ;
31
35
import org .apache .activemq .artemis .jms .client .ActiveMQJMSConnectionFactory ;
32
36
import org .apache .camel .CamelContext ;
33
37
import org .apache .camel .builder .RouteBuilder ;
34
38
import org .apache .camel .component .jms .JmsComponent ;
35
39
import org .apache .camel .impl .DefaultCamelContext ;
40
+ import org .w3c .dom .Document ;
41
+ import org .w3c .dom .Element ;
36
42
37
43
import javax .annotation .Resource ;
38
44
import javax .jms .ConnectionFactory ;
41
47
import javax .servlet .ServletContextListener ;
42
48
import javax .servlet .annotation .WebListener ;
43
49
import javax .sql .DataSource ;
50
+ import javax .xml .parsers .DocumentBuilder ;
51
+ import javax .xml .parsers .DocumentBuilderFactory ;
52
+ import java .io .File ;
44
53
import java .net .InetAddress ;
45
54
46
55
@ WebListener
@@ -58,15 +67,16 @@ public void contextInitialized(ServletContextEvent servletContextEvent) {
58
67
camelContext = new DefaultCamelContext ();
59
68
TopicConnectionFactory connectionFactory = AQjmsFactory .getTopicConnectionFactory (new DataSourceWrapper (cwms ), true );
60
69
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 );
70
80
ConnectionFactory artemisConnectionFactory = new ActiveMQJMSConnectionFactory ("vm://0" );
71
81
camelContext .addComponent ("artemis" , JmsComponent .jmsComponent (artemisConnectionFactory ));
72
82
camelContext .addRoutes (new RouteBuilder () {
0 commit comments