java - How to change the port in an embedded HornetQ programmatically -
java - How to change the port in an embedded HornetQ programmatically -
i want alter default port in embedded hornetq. works when done in hornetq-configuration.xml file:
<acceptors> <acceptor name="netty-acceptor"> <factory-class>org.hornetq.integration.transports.netty.nettyacceptorfactory</factory-class> <param key="port" value="6446"/> </acceptor> </acceptors>
but changing programmatically not. load configuration file, , seek override, without success - here try:
// load configuration fileconfiguration configuration = new fileconfiguration(); configuration.setconfigurationurl("hornetq-configuration.xml"); // prepare configuration objects string netty = nettyacceptorfactory.class.getname(); map<string, object> transportparams = new hashmap<string, object>(); transportparams.put(transportconstants.host_prop_name, "localhost"); transportparams.put(transportconstants.port_prop_name, 6446); transportconfiguration transpconf = new transportconfiguration(netty, transportparams); // add together configuration (clearing before didn't helped either)) configuration.getacceptorconfigurations().add(transpconf); configuration.start(); // moving right after setting file didn't helped // start server hornetqserver server = hornetqservers.newhornetqserver(configuration); jmsservermanager jmsservermanager = new jmsservermanagerimpl(server, "hornetq-jms.xml"); jmsservermanager.setcontext(null); jmsservermanager.start();
any ideas? thanks
this didn't work because configuration.start()
override added.
you should able this:
fileconfiguration configuration = new fileconfiguration(); configuration.setconfigurationurl("hornetq-configuration.xml"); configuration.start(); // <<<----------------- // prepare configuration objects string netty = nettyacceptorfactory.class.getname(); map<string, object> transportparams = new hashmap<string, object>(); transportparams.put(transportconstants.host_prop_name, "localhost"); transportparams.put(transportconstants.port_prop_name, 6446); transportconfiguration transpconf = new transportconfiguration(netty, transportparams); configuration.getacceptorconfigurations().clear(); // <<<----------------- // add together configuration configuration.getacceptorconfigurations().add(transpconf);
java embedded jms hornetq
Comments
Post a Comment