It seems, that in case using an ActiveMQ-Consumer the depending components are not shut down is the correct order.
As far as I can see, the JMSSessionPool is shutdown before the depending routes were closed.
This causes JMSEsception and each client routes will run into timeouts, before they are forced to shutdown.
Also the amq-broker ist removed before its depending routes.
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<camelContext id="ObjectServerConnection" xmlns="http://camel.apache.org/schema/blueprint" >
<route id="test-aqm-shutdown-route">
<from uri="activemq:buffered-route?concurrentConsumers=5&asyncConsumer=5" />
<!--transacted ref="required" /-->
<convertBodyTo type="java.lang.String" />
<to uri="file:/out.txt" />
</route>
</camelContext>
</blueprint>
As I can see in logfile:
...
2016-12-08 11:48:53,003 | INFO | FelixShutdown | DefaultShutdownStrategy | 151 - org.apache.camel.camel-core - 2.16.4 | Starting to graceful shutdown 1 routes (timeout 300 seconds)
2016-12-08 11:49:02,336 | ERROR | [buffered-route] | faultJmsMessageListenerContainer | 145 - org.apache.servicemix.bundles.spring-jms - 3.2.17.RELEASE_1 | Could not refresh JMS Connection for destination 'buffered-route' - retrying in 5000 ms. Cause: Error while attempting to add new Connection to the pool; nested exception is javax.jms.JMSException: Could not create Transport. Reason: java.io.IOException: Broker named 'amq-broker' does not exist.
2016-12-08 11:49:07,339 | INFO | 5 - ShutdownTask | DefaultShutdownStrategy | 151 - org.apache.camel.camel-core - 2.16.4 | Route: test-aqm-shutdown-route shutdown complete, was consuming from: Endpoint[activemq://buffered-route?asyncConsumer=5&concurrentConsumers=5]
2016-12-08 11:49:07,340 | INFO | FelixShutdown | DefaultShutdownStrategy | 151 - org.apache.camel.camel-core - 2.16.4 | Graceful shutdown of 1 routes completed in 14 seconds
...
2016-12-08 11:47:09,064 | DEBUG | m://amq-broker#0 | AdvisoryConsumer | 122 - org.apache.activemq.activemq-osgi - 5.12.3 | Failed to send remove command: javax.jms.JMSException: Peer (vm://amq-broker#1) disposed.
javax.jms.JMSException: Peer (vm://amq-broker#1) disposed.
at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:72)[122:org.apache.activemq.activemq-osgi:5.12.3]
at org.apache.activemq.ActiveMQConnection.doAsyncSendPacket(ActiveMQConnection.java:1314)[122:org.apache.activemq.activemq-osgi:5.12.3]
at org.apache.activemq.ActiveMQConnection.asyncSendPacket(ActiveMQConnection.java:1306)[122:org.apache.activemq.activemq-osgi:5.12.3]
at org.apache.activemq.AdvisoryConsumer.dispose(AdvisoryConsumer.java:57)[122:org.apache.activemq.activemq-osgi:5.12.3]
at org.apache.activemq.ActiveMQConnection.close(ActiveMQConnection.java:655)[122:org.apache.activemq.activemq-osgi:5.12.3]
at org.apache.activemq.jms.pool.ConnectionPool.close(ConnectionPool.java:168)[122:org.apache.activemq.activemq-osgi:5.12.3]
at org.apache.activemq.jms.pool.ConnectionPool.onException(ConnectionPool.java:379)[122:org.apache.activemq.activemq-osgi:5.12.3]
at org.apache.activemq.ActiveMQConnection$5.run(ActiveMQConnection.java:1982)[122:org.apache.activemq.activemq-osgi:5.12.3]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_102]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_102]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_102]
Caused by: org.apache.activemq.transport.TransportDisposedIOException: Peer (vm://amq-broker#1) disposed.
at org.apache.activemq.transport.vm.VMTransport.oneway(VMTransport.java:91)[122:org.apache.activemq.activemq-osgi:5.12.3]
at org.apache.activemq.transport.MutexTransport.oneway(MutexTransport.java:68)[122:org.apache.activemq.activemq-osgi:5.12.3]
at org.apache.activemq.transport.ResponseCorrelator.oneway(ResponseCorrelator.java:60)[122:org.apache.activemq.activemq-osgi:5.12.3]
at org.apache.activemq.ActiveMQConnection.doAsyncSendPacket(ActiveMQConnection.java:1312)[122:org.apache.activemq.activemq-osgi:5.12.3]
... 9 more
Does anyone have an idea how to solve this?
Update the start-level of the bundle for your route. The container will shutdown bundles in reverse order. It appears your bundle is at the same level (or lower) as the broker bundle.
Also.. if you are using the deploy/ directory, you can update the setting:
etc/org.apache.felix.fileinstall-deploy.cfg:
felix.fileinstall.start.level=XX
ref: http://felix.apache.org/documentation/subprojects/apache-felix-file-install.html
For those that might be encountering this in Karaf/Felix, we got round the issue by writing a Karaf console script which stops our Camel contexts first before issuing the 'shutdown' command.
The context stop command(s) will gracefully stop all routes in that context before it returns.
The context stops take about 15 seconds (about 300 routes), and then the shutdown completes in about 5 seconds (we have over 350 bundles).
So the script looks something like this:
camel:context-stop context1
camel:context-stop context2
camel:context-stop context3
camel:context-stop context4
shutdown -f
(Context names have been changed to protect the innocent)
Related
I am getting below Error in Fuse log. In order to solve it I thought I will give permission to db-32.log file but it doesn't allow me to change permission of this file. Instead I get a warning
"cannot change properties of db-32.log"
Please find below the error log
07:17:20,163 | INFO | AMQ-1-thread-1 | ActiveMQServiceFactory | 197 -
io.fabric8.mq.mq-fabric - 1.2.0.redhat-621084 | Broker amq failed to start.
Will try again in 10 seconds
07:17:20,163 | ERROR | AMQ-1-thread-1 | ActiveMQServiceFactory | 197 -
io.fabric8.mq.mq-fabric - 1.2.0.redhat-621084 | Exception on start:
/opt/install/jboss/jboss-fuse-6.2.1.redhat-084/data/amq/kahadb/db-32.log
(Permission denied)
java.io.FileNotFoundException: /opt/install/jboss/jboss-fuse-6.2.1.redhat-
084/data/amq/kahadb/db-32.log (Permission denied)
at java.io.RandomAccessFile.open0(Native Method)[:1.8.0_91]
at java.io.RandomAccessFile.open(RandomAccessFile.java:316)[:1.8.0_91]
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:243)[:1.8.0_91]
Do you restart the broker under a different user than was previously used to run the broker?
Make sure the OS level user that runs the broker has full access to the configured KahaDB folder on the file system.
I'm trying to set a network of brokers in activemq, my current setup is having two brokers each running on a different vm. My configuration is:
<networkConnectors>
<networkConnector
name="Q:broker1->broker2"
uri="static:(tcp://10.10.10.12:61612)"
duplex="false"
decreaseNetworkConsumerPriority="true"
networkTTL="2"
dynamicOnly="true"
userName="activemq"
password="password">
<excludedDestinations>
<topic physicalName=">" />
</excludedDestinations>
</networkConnector>
</networkConnectors>
I'm getting this error when I start up activemq on broker1:
2016-11-01 17:49:18,571 | INFO | Establishing network connection from vm://localhost?create=false&async=false to tcp://10.10.10.12:61612 | org.apache.activemq.network.DiscoveryNetworkConnector | ActiveMQ Task-1
2016-11-01 17:49:18,572 | INFO | Connector vm://localhost started | org.apache.activemq.broker.TransportConnector | ActiveMQ Task-1
2016-11-01 17:49:18,578 | WARN | Failed to add Connection localhost->localhost-34161-1478036807089-20:1 due to java.lang.SecurityException: User name [activemq] or password is invalid. | org.apache.activemq.broker.TransportConnection | triggerStartAsyncNetworkBridgeCreation: remoteBroker=tcp:///10.10.10.12:61612#43981, localBroker= vm://localhost#18
2016-11-01 17:49:18,580 | WARN | Security Error occurred on connection to: vm://localhost#18, User name [activemq] or password is invalid. | org.apache.activemq.broker.TransportConnection.Service | triggerStartAsyncNetworkBridgeCreation: remoteBroker=tcp:///10.10.10.12:61612#43981, localBroker= vm://localhost#18
2016-11-01 17:49:18,580 | INFO | Network connection between vm://localhost#18 and tcp:///10.10.10.12:61612#43981 shutdown due to a local error: java.lang.SecurityException: User name [activemq] or password is invalid. | org.apache.activemq.network.DemandForwardingBridgeSupport | triggerStartAsyncNetworkBridgeCreation: remoteBroker=tcp:///10.10.10.12:61612#43981, localBroker= vm://localhost#18
2016-11-01 17:49:18,583 | INFO | Connector vm://localhost stopped | org.apache.activemq.broker.TransportConnector | ActiveMQ BrokerService[localhost] Task-8
2016-11-01 17:49:18,584 | INFO | localhost bridge to localhost stopped | org.apache.activemq.network.DemandForwardingBridgeSupport | ActiveMQ BrokerService[localhost] Task-8
2016-11-01 17:49:20,580 | INFO | Stopping vm://localhost#18 because Failed with SecurityException: User name [activemq] or password is invalid. | org.apache.activemq.broker.TransportConnection | ActiveMQ BrokerService[localhost] Task-5
I set the activemq user in broker2 activemq.xml like the following:
<simpleAuthenticationPlugin>
<users>
<authenticationUser username="activemq" password="${activemq.password}"
groups="admins"/>
and the user activemq is defined in credentials-enc.properties file like:
activemq.password=password
why broker1 is enable to establish a connection with broker2? what I'm missing here?
Add the userName and password attributes like this:
<networkConnector .. userName="admin" password="admin".. >
Network Connector Properties
Part 2:
Do you have a property placeholder bean in your activemq.xml file? You need that for the macro replacement to work. Otherwise, the broker probably thinks the password is literally the text below with the $ sign and { } braces.
${activemq.password}
I downloaded Activemq_5.10 and configured using the command "activemq start" from the bin folder.
It is not moving after the last line and is not properly started, because of which the console is not up.
Extract of the log is:
| INFO | For help or more information please see: http://activemq.apache.org | org.apache.activemq.broker.BrokerService | main
| INFO | ActiveMQ WebConsole available at http://0.0.0.0:8161/ | org.apache.activemq.web.WebConsoleStarter | main
| INFO | Initializing Spring FrameworkServlet 'dispatcher' | /admin | main
| INFO | jolokia-agent: No access restrictor found at classpath:/jolokia-access.xml, access to all MBeans is allowed | /api | main
That is the last line logged, ActiveMQ should be started, eg when I do on ActiveMQ 5.10.0
bin/activemq console
I see
INFO | Apache ActiveMQ 5.10.0 (localhost, ID:davsclaus.air-62275-1403850867605-0:1) started
INFO | For help or more information please see: http://activemq.apache.org
WARN | Store limit is 102400 mb (current store usage is 0 mb). The data directory: /opt/apache-activemq-5.10.0/data/kahadb only has 74949 mb of usable space - resetting to maximum available disk space: 74949 mb
INFO | ActiveMQ WebConsole available at http://0.0.0.0:8161/
INFO | Initializing Spring FrameworkServlet 'dispatcher'
INFO | jolokia-agent: No access restrictor found at classpath:/jolokia-access.xml, access to all MBeans is allowed
And I can see the old web console at
http://localhost:8161/
And I can connect to the broker remotely using hawtio as documented here:
http://sensatic.net/activemq/activemq-and-hawtio.html
So I think your ActiveMQ is running as expected.
we're using the so called JDBC Master Slave architecture with Oracle DB. We have 2 nodes and each one has one Broker started. We start the Broker1 (on node1) and it becomes the MASTER obtaining the lock over the tables. Then we start the Broker2 on the node2 and this one starts as SLAVE. WE can see in the log of Slave broker that it's trying to obtain the lock every 10sec, but it fails:
2013-06-12 19:32:38,714 | INFO | Default failed to acquire lease. Sleeping for 10000 milli(s) before trying again... | org.apache.activemq.store.jdbc.LeaseDatabaseLocker | main
2013-06-12 19:32:48,720 | INFO | Default Lease held by Default till Wed Jun 12 19:32:57 UTC 2013 | org.apache.activemq.store.jdbc.LeaseDatabaseLocker | main
Everything works fine and then in one moment in SLAVE's log we see that it suddenly becomes the MASTER:
2013-06-13 00:38:11,262 | INFO | Default Lease held by Default till Thu Jun 13 00:38:17 UTC 2013 | org.apache.activemq.store.jdbc.LeaseDatabaseLocker | main
2013-06-13 00:38:11,262 | INFO | Default failed to acquire lease. Sleeping for 10000 milli(s) before trying again... | org.apache.activemq.store.jdbc.LeaseDatabaseLocker | main
...
2013-06-13 00:38:21,314 | INFO | Default, becoming the master on dataSource: org.apache.commons.dbcp.BasicDataSource#9c6a99d | org.apache.activemq.store.jdbc.LeaseDatabaseLocker | main
2013-06-13 00:38:21,576 | INFO | Apache ActiveMQ 5.8.0 (Default, ID:corerec3-49774-1371083901328-0:1) is starting | org.apache.activemq.broker.BrokerService | main
2013-06-13 00:38:21,692 | WARN | Failed to start jmx connector: Cannot bind to URL [rmi://localhost:1616/jmxrmi]: javax.naming.NameAlreadyBoundException: jmxrmi [Root exception is java.rmi.AlreadyBoundException: jmxrmi]. Will restart management to re-create jmx connector, trying to remedy this issue. | org.apache.activemq.broker.jmx.ManagementContext | JMX connector
2013-06-13 00:38:21,700 | INFO | Listening for connections at: tcp://corerec3:61617?transport.closeAsync=false | org.apache.activemq.transport.TransportServerThreadSupport | main
2013-06-13 00:38:21,700 | INFO | Connector openwire Started | org.apache.activemq.broker.TransportConnector | main
2013-06-13 00:38:21,701 | INFO | Apache ActiveMQ 5.8.0 (Default, ID:corerec3-49774-1371083901328-0:1) started | org.apache.activemq.broker.BrokerService | main
2013-06-13 00:38:21,701 | INFO | For help or more information please see: http://activemq.apache.org | org.apache.activemq.broker.BrokerService | main
2013-06-13 00:38:21,701 | ERROR | Memory Usage for the Broker (512 mb) is more than the maximum available for the JVM: 245 mb | org.apache.activemq.broker.BrokerService | main
2013-06-13 00:38:22,157 | INFO | Web console type: embedded | org.apache.activemq.web.WebConsoleStarter | main
2013-06-13 00:38:22,292 | INFO | ActiveMQ WebConsole initialized. | org.apache.activemq.web.WebConsoleStarter | main
2013-06-13 00:38:22,353 | INFO | Initializing Spring FrameworkServlet 'dispatcher' | /admin | main
while the MASTER's log shows no change from what it usually outputs...
So, it seems that somehow SLAVE obtains the lock (due to hmm... for example connection loss between master and the DB), but if we don't restart the brokers we start losing messages...
The problem is that in the producers' log we can see that it successfully sends the messages to the QueueX, but we don't see the consumer's taking them from the queue...
If we go to the DB and query _ACTIVEMQ_MSGS_ table we see that the messages are unprocessed.
It looks as if the broker (Producers are connected to) has the lock and inserts the messages into the DB and the brokers Clients are consuming from doesn't have the lock and can't consult the tables...
I don't know if all this makes much sense, but I surely hope someone might shed some light upon this one...
I didn't want to saturate the post with the configuration details, but if you need specific details like failover config, IPs, ports etc. I will post it...
We've been using AMQ 5.5.1 in production for several months. Occasionally, we observe that the broker decides to refresh itself with no outside trigger. When this happens, our queue senders fail until the broker is back online some 10 minutes later. I cannot find any information or settings that would cause this behavior .. and let me control it.
Is this normal for the broker to recycle on its own like this? If so, what things would cause it?
2012-12-11 11:02:11,603 | INFO | Refreshing org.apache.activemq.xbean.XBeanBrokerFactory$1#f6ac0b: startup date [Tue Dec 11 11:02:11 EST 2012]; root of context hierarchy | org.apache.activemq.xbean.XBeanBrokerFactory$1 | WrapperSimpleAppMain
2012-12-11 11:02:13,806 | WARN | destroyApplicationContextOnStop parameter is deprecated, please use shutdown hooks instead | org.apache.activemq.xbean.XBeanBrokerService | WrapperSimpleAppMain
2012-12-11 11:02:13,821 | INFO | PListStore:D:\Tools\ActiveMQ\apache-activemq-5.5.1\bin\win32\..\..\data\localhost\tmp_storage started | org.apache.activemq.store.kahadb.plist.PListStore | WrapperSimpleAppMain
2012-12-11 11:02:13,868 | INFO | Using Persistence Adapter: KahaDBPersistenceAdapter[D:\Tools\ActiveMQ\apache-activemq-5.5.1\bin\win32\..\..\data\kahadb] | org.apache.activemq.broker.BrokerService | WrapperSimpleAppMain
2012-12-11 11:02:16,618 | INFO | KahaDB is version 3 | org.apache.activemq.store.kahadb.MessageDatabase | WrapperSimpleAppMain
2012-12-11 11:02:16,697 | INFO | Recovering from the journal ... | org.apache.activemq.store.kahadb.MessageDatabase | WrapperSimpleAppMain
I found that the wrapper exe process was forcing the restart.
I was able to see in the wrapper.log (windows service) that the process was being restarted because the JVM was not responding. So this is not an issue with the broker auto-restarting per se.. it was an issue with the broker JVM somehow becoming hung (separate problem).
Here are the wrapper log entries for those interested:
ERROR | wrapper | 2012/12/11 11:01:58 | JVM appears hung: Timed out waiting for signal from JVM.
ERROR | wrapper | 2012/12/11 11:01:58 | JVM did not exit on request, terminated
STATUS | wrapper | 2012/12/11 11:02:04 | Launching a JVM...