Category Archives: activemq

What can slow down Apache Camel’s ActiveMQ message sending?

Recently, I have performance problem with Apache Camel and ActiveMQ where there's lots of message in pending queue. So I have add logs to print out Apache Camel message history when there's a performance problem with the time used in each steps. And from the log below, it is the sending message to ActiveMq part which took more than 50 seconds to finish.

....
activemqShared:sendToQueueA : 50699 ms, timeStamp : 10:08:43.173,
activemqShared:sendToQueueB : 59010 ms, timeStamp : 10:09:33.872,

And That part of the Camel route is like this

...
.to("activemqShared:sendToQueueA")
.to("activemqShared:sendToQueueB)

Basically this part should just send the message to ActiveMq and that's finished. Then there're consumers that would receive the tasks to be processed asynchronously.

So what can cause sending a message to ActiveMQ take such a long time? My speculation right now is network problem or something that make camel not receive notification that the message has been processed (?)

Apache Activemq 5.14.4 changes while upgrading form 5.9.1

Currently we are using Activemq 5.9.1, we are upgrading to 5.14.4, we have observed few changes but i could not get the exact reason.

  1. context.start() is not working instead of that we need to use context.startAllRoutes()
  2. setAutoStartup(true) we need to give before starting the routs
  3. while registering the context we set setNoStart(true) in 5.9, we need to remove in 5.14.4 then only working
  4. in Activemq.xml we need to remove zkSessiontimeout.

we are not getting the exact reason for the all the above changes.

Why am I unable to Send messages to ActiveMQ from WSO2 EI 6.0.0?

I followed the link ESB as a JMS Producer to configure the sender and receiver. I have also placed the following jars activemq-broker-5.8.0.jar activemq-client-5.8.0.jar activemq-kahadb-store-5.8.0.jar geronimo-jms_1.1_spec-1.1.1.jar geronimo-j2ee-management_1.1_spec-1.0.1.jar geronimo-jta_1.0.1B_spec-1.0.1.jar hawtbuf-1.9.jar Slf4j-api-1.6.6.jar activeio-core-3.1.4.jar into WSO2_EI_HOME/lib

When I configured a proxy with the following code and tried to send the messages to the queue, but the messages aren't delivering.

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="Sender"
       startOnLoad="true"
       statistics="disable"
       trace="disable"
       transports="http,https">
   <target>
      <inSequence>
         <property name="OUT_ONLY" value="true"/>
         <send>
            <endpoint>
               <address uri="jms:/VALLYSOFTQ?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&amp;java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&amp;java.naming.provider.url=tcp://localhost:61616&amp;transport.jms.DestinationType=queue"/>
            </endpoint>
         </send>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </target>
   <description/>
</proxy>

The same configuration worked earlier for me but I don't know what happened, the messages are not going to the queue now.

Thanks in advance.

Why am I unable to listen to messages from ActiveMQ in WSO2 EI 6.0.0?

I followed the link Configure Active MQ with WSO2 EI to configure the sender and receiver. I have also placed the following jars activemq-broker-5.8.0.jar activemq-client-5.8.0.jar activemq-kahadb-store-5.8.0.jar
geronimo-jms_1.1_spec-1.1.1.jar geronimo-j2ee-management_1.1_spec-1.0.1.jar geronimo-jta_1.0.1B_spec-1.0.1.jar hawtbuf-1.9.jar Slf4j-api-1.6.6.jar activeio-core-3.1.4.jar into WSO2_EI_HOME/lib

When I configured a proxy with the following code and tried to listen the messages from the queue, my proxy service became fault.

    <?xml version="1.0" encoding="UTF-8"?>
<proxy name="ActiveMQListenerService" startOnLoad="true"
    transports="jms" xmlns="http://ws.apache.org/ns/synapse">
    <target>
        <inSequence>
            <log level="full">
                <property expression="$body" name="body" />
            </log>
            <property name="OUT_ONLY" scope="default" type="STRING"
                value="true" />
        </inSequence>
        <outSequence />
        <faultSequence />
    </target>
    <parameter name="transport.jms.ContentType">
        <rules>
            <jmsProperty>contentType</jmsProperty>
            <default>text/plain</default>
        </rules>
    </parameter>
    <parameter name="redeliveryPolicy.maximumRedeliveries">1</parameter>
    <parameter name="transport.jms.DestinationType">queue</parameter>
    <parameter name="transport.jms.SessionTransacted">true</parameter>
    <parameter name="redeliveryPolicy.redeliveryDelay">2000</parameter>
    <parameter name="transport.jms.CacheLevel">consumer</parameter>
    <parameter name="transport.jms.Destination">VALLYSOFTQ</parameter>
</proxy>

The service is faulted and I am getting the following message in the WSO2 admin console.

Unable to configure the service ActiveMQListenerService for the JMS transport: Service doesn't have configuration information for transport jms. This service is being marked as faulty and will not be available over the JMS transport.

What have I done wrong? Kindly help.

How to connect to an ActiveMQ server by setting the username and password programmatically?

I create an ActiveMQ server in order to send some messages. I use Apache Activemq version 5.14.4 I want to be asked for username and password when I try to connect to the ActiveMQ server and that's why I added a simple authentification plugin into the activemq.xml as you can see bellow.

String username = "admin";
String password = "anything";
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616");
        factory.setUserName(username);
        factory.setPassword(password);
        factory.setTrustedPackages(Arrays.asList("com.h4p.server"));
        Connection connection = null;
        Session session = null;
        Destination destination = null;
        try {
            connection = factory.createConnection();
            connection.start();
            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            destination = session.createQueue("myQueue");
        } catch (JMSException e) {
            e.printStackTrace();
        }
...

Into the broker element I added a security level using SimpleAuthentificationPlugin:

    <simpleAuthenticationPlugin anonymousAccessAllowed="false">
        <users>
            <authenticationUser username="admin" password="anything" groups="admins"/>
        </users>
    </simpleAuthenticationPlugin>

    <authorizationPlugin>
        <map>
            <authorizationMap>
                <authorizationEntries>
                    <authorizationEntry queue="myQueue" write="admins" read="admins" admin="admins" />  
                    <authorizationEntry topic="ActiveMQ.Advisory.>" write="admins" read="admins" admin="admins" />                      
                </authorizationEntries>
            </authorizationMap>
        </map>
    </authorizationPlugin>I

As you can see, I set the username and password at factory level, although I can set them when I create the connection.

Which option is best, to set the username&password to the factory or when I create the connection?

ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616");
        factory.setUserName(username);
        factory.setPassword(password);

vs

connection = factory.createConnection(username, password);

Anyway, with security I can't to connect to the ActiveMQ server:

javax.jms.JMSException: Could not connect to broker URL: tcp://localhost:61616. Reason: java.net.ConnectException: Connection refused: connect

The files in \apache-activemq-5.14.4\conf directory have this configurations: users.properties: admin=admin, groups.properties: admins=admin and credentials.properties:

activemq.username=admin
activemq.password=anything

If I comment the simpleAuthenticationPlugin and authorizationPlugin, then I can connect to the server, send the messages I want to sent and consume them. Also, I can connect to the server,send and consume the messages if I remove anonymousAccessAllowed="false" or put it on true, but this is not what I want.

Could you please tell me how can I connect to the ActiveMQ server configured with that security level by setting the username and password programmatically?

Connection never released with expiryTimeout set

I run Apache Camel to consume and produce messages from/to Apache ActiveMQ instance.

I used the org.apache.activemq.pool.PooledConnectionFactory as connection factory in order to share connections throught sessions.

I configure 30 consumer, 15 connection and 200 max active sessions by connection.

I provide an expiryTimeout to my PooledConnectionFactory, but the problem is that connections are never released.

I inspect the Camel instance with remote debug, I found org.apache.activemq.jms.pool.ConnectionPools managed by the PooledConnectionFactory. After the expiryTimeout elapsed I see the ConnectionPool tagged as expired, but the connection always has some reference to other session on the same connection and the connection is always considered as reusable (throught borrowObject method) as long as it is referenced.

The aim of PooledConnectionFactory is to share a connection with some consumer. How can I make these connections expired from time to time if sharing connection prevent closing connection ?

I try with 1 connection for each consumer and connection are much more released, but it xould go against pool idea isn'it ?

Errors in ActiveMQ command line inferface

Hi am using Apache ActiveMQ 5.13 version and trying to get monitoring details.

I have written java code to get some monitoring details as shown below

Feb 02, 2017 12:04:01 AM com.QueueStats main

Time of Stats : 2017-02-02 00:04:01
Healthstatus : Good
TotalMessageCount : 406
TotalConsumerCount : 29
TotalEnqueueCount : 135
TotalDequeueCount : 0
TotalConnectionsCount : 59
TotalProducerCount : 1

Instead of java code i want this kind of output from command line interface

i have tried some simple commands like

$ activemq-admin --list
$ activemq-admin list --jmxurl service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi

with the above commands am getting error as

Error: Unable to access jarfile /usr/bin/run.jar

and other command

activemq --list

Error

INFO: Loading '/usr/share/activemq/activemq-options'
INFO: Using java '/usr/bin/java'
mkdir: missing operand
Try 'mkdir --help' for more information.
/usr/bin/activemq: 399: /usr/bin/activemq: /usr/bin/java -Xms512M -Xmx512M -Dorg.apache.activemq.UseDedicatedTaskRunner=true                
-Dactivemq.classpath="/var/lib/activemq/conf;"               
-Dactivemq.home="/usr/share/activemq"               
-Dactivemq.base="/var/lib/activemq/"               
-Dactivemq.conf="/var/lib/activemq/conf"               
-Dactivemq.data="/var/lib/activemq/data"                              
-jar "/usr/share/activemq/bin/run.jar" --list: not found

can anyone suggest how to overcome this errors.

Error creating an Apache Apollo broker

I downloaded and unzipped the Apache Apollo distribution as described in their site.

~/Developer/Web/MQTT/apache-apollo-1.7.1/bin/apollo create mybroker

I got teh below output in the Terminal.

Creating apollo instance at: mybroker

ERROR: mybroker/etc/log4j.properties (No such file or directory)

That command is supposed to create the etc sub directory among others.

Any idea why this error is occurring?