I did some research but i wasnt able to find an answer.
What i like to do is, changing ActiveMQ configuration while it is running.
Lets say I want to increase the memory usage, flow control etc. while activemq is running. But i dont want to restart it. Is this possible? I tried it but the changes didnt kick in.
is there a way to do this?
I do have C++ and java clients (producers and consumers respectively)
The ActiveMQ configuration can be changed at runtime via JMX. However, any changes that are made at runtime will not be persisted to the configuration file.
As mentioned by bsnyder it you can change broker config at runtime with JMX.
An easy way of doing this is to use JConsole to get to the broker's JMX Beans (instructions here), there is also a JMX API if you need to this through code.
Related
I need to use dynamic keystores in my Spring Boot application because at any moment i might have to change them and i don't want to have any downtime.
From what i saw it this post i have three options:
Writing a custom KeyManager;
Use a reverse-proxy;
Or on Tomcat use local JMX to reload SSL context.
In last one i don't really understand the implications of that. The reverse-proxy seems the easier way, but is it the best approach?
If someone could point me which one would be the best solution and why or recommend something else would be much appreciated.
You can have your own implementation of SslStoreProvider which will enable you to get the keystore/truststore from whatever source you want (does not need to be on disk).
Then check out #RefreshScope you can recreate beans (like your own SslStoreProvider) with it.
Here you can find an example (please note that this was only created to demonstrate a bug in spring-boot 1.x which was fixed in 2.x).
The external reverse-proxy approach is the most flexible. It doesn't require any changes to your application or deployment logic and will address most of the scenarios. The downside is that your architecture gets more complex and requires additional server resource for the proxy server.
You can take it a step further and do blue-green deployments:
The blue-green deployment approach does this by ensuring you have two production environments, as identical as possible. At any time one of them, let's say blue for the example, is live. As you prepare a new release of your software you do your final stage of testing in the green environment. Once the software is working in the green environment, you switch the router so that all incoming requests go to the green environment - the blue one is now idle.
We maintain our server once a week.
Sometimes, the customer wishes that we change some settings which is already cached in server.
My colleague always write some JSP code to change these settings which are stored in the memory.
Is it a good method to use this kind of methodology?
If our project is not a Web container, which tools can help me?
Usually, in my experience, the server configuration is not stored only in memory of server:
What happens that after a configuration change, the server has been restarted / just went down for some system reason?
What happens if you have more than one instance of the same server to work on (a cluster of servers in other words)?
So, usually, people opt for various "externalized configuration" options that can range from "file-based" configuration + redeploy the whole cluster upon each configuration change, to configuration management servers (like Consul, etc.d, etc). There are also some solutions that came from (and used in) a java world: Apache Zookeeper, Spring cloud config server to name a few, there are others. In addition, sometimes, it's convenient to store the configurations in a database.
Now to your question: If your project is not a web container and you don't care that configuration will "disappear" after a server restart and you're not running a distributed cluster of servers, then, using JSP indeed doesn't seem appropriate in this case.
Maybe you should take a look at JMX - Java management extensions, that have a built-in solution so that you probably will be able to get rid of a web container (which seems to be not used by your team anyway other than for JSP modifications that you've described).
You basically need in memory cache, there are multiple solutions found in answers which include creating your own implementation or using existing java library. You can also get data from database and add cache over the database layer.
I have two questions for which I couldn't find any popular/widely accepted solutions:
What is the easiest way to start zookeeper server using Java Program?
And, is it possible to add servers to zookeeper cluster without having to manually go to each machine and update their config files with new node's id and ip:port entry?
Can someone please help? Thanks!
If you want to start a new ZooKeeper server process from your Java code, you would do it the same way you would start any other external process from Java, e.g. using a ProcessBuilder. There is nothing special here in case of ZooKeeper. You can check the official docs on how the actual command should look like. It gets complicated if you want to supervise the process for production use, so in that case it would be better to use something provided on your OS (e.g. upstart, runit, etc...), or take a look at Exhibitor for code examples: https://github.com/Netflix/exhibitor.
If you are asking about starting a ZooKeeper cluster from your Java program, then you complicate things further, since you would basically need to supervise multiple ZooKeeper JVM processes on different hosts. Also take a look at Exhibitor.
If your question is about starting a ZooKeeper server instance inside the same JVM process as your Java code (embedded), then it is also possible. There are a few important details to keep in mind, take a look at this answer:
Is it possible to start a zookeeper server instance in process, say for unit tests?
Regarding your second question, real support for dynamic cluster reconfiguration was added just recently, in 3.5.0: http://zookeeper.apache.org/doc/trunk/zookeeperReconfig.html.
Prior to this, you can still "add servers to zookeeper cluster without having to manually go to each machine and update their config", but you have to use a configuration management tool like Chef, Puppet or similar, and in this case you would also need to do a restart of the cluster to uptake new config.
I would like to edit Connectors on the fly on my web-app code. However, for achieving this, I need to access the server from the web-app. How can do this access? It was tried going up from the JMX but it did not work either.
At my case, using JMX was the solution. I looked at the MBeans and I found out Beans directly related to what I wanted, I iterated over the beans and performed my actions over the right ones. This way, I could start/stop them and get the effect I wanted to.
I successfully set up JMX monitpring in zabbix.
With the default template, I can get a good idea about the performance of my application.
I now need to monitor the state of the running threads. So find out, weather it is running, paused or interrupted.
In jConsole, I can see this. So I assume, JMX does allow this.
Does anybody know if this can be done within zabbix monitoring? I assume I need to define a discovery rule for the threads, but I cannot find any docs about this.
Thanks for your help, all input appreciated!
There are two aspects to your question: (a) observing the state of the existing threads through JMX and (b) low-level discovery for JMX thread monitoring using Zabbix.
Regarding (a), I am currently not aware of any JMX object that would expose this information. By default JVM provides objects like jmx["java.lang:type=Threading",ThreadCount] and jmx["java.lang:type=Threading",DaemonThreadCount], both of which are included in the default "Template JMX Generic". However, I am not aware of any JMX objects that would provide a more detailed information. Please share if you know some.
Regarding (b), there is a built-in item jmx.discovery, which returns a list of all JMX objects found on the JMX agent. However, with limited filtering abilities and without a possiblity to create an item of the correct type based on {#JMXTYPE} macro, it was mostly meant for internal testing purposes and that is why it is undocumented.
However, you can find an example of jmx.discovery at ZBX-6273. With the recent addition of multiple LLD filters in ZBXNEXT-581, you can try filtering the thread objects of interest. Alternatively, you can wait until ZBXNEXT-1223 is implemented or use the patches and utilities mentioned there in the meanwhile. In particular, the recent addition at https://www.zabbix.org/wiki/Docs/howto/jmx_discovery is useful.