ActiveMq and mosquitto bridge not working - activemq

I am getting below error on activemq console when i am trying to connect from mosquitto to activemq.
WARN | Transport Connection to: tcp://192.168.0.27:48689 failed: java.io.IOException: Unknown data type: 77
MY setup is as below
192.168.0.27 ---- Mosquitto broker with below configuration for bridge
connection try
try_private false
address 192.168.0.22:61616
username myuser
password mypassword
start_type automatic
clientid 1
notifications true
topic inbound/# in alpha/ beta/
topic outbound/# out harry/ larry
My ActiveMQ broker is 192.168.0.22 with TansportConnector is as below
<transportConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&wireformat.maxFrameSize=104857600"/>
</transportConnectors>

This won't work because the connector on the broker is being created as the OpenWire connector which only works with OpenWire clients. You need to add an MQTT connector to your broker:
<transportConnectors>
<transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&wireformat.maxFrameSize=104857600"/>
</transportConnectors>
Then you can configure you other MQTT resources to connect there.

Related

ActiveMQ configuration

I'm new to ActiveMQ and I'd like to know how and where to add this line of code to enable MQTT on my broker. I'm running broker on Mac.
Kindly help me with this configuration.
By default, MQTT protocol is supported for ActiveMQ when it starts if you download from Apache ActiveMQ. Apache has configured the broker well in /conf/activemq.xml so that you can run it directly. Meanwhile, openwire, amqp, stomp and ws are enabled for ActiveMQ as well.
<transportConnectors>
<!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
</transportConnectors>
After you have create a new broker using tool ARTEMIS_PATH/bin/artemis[.cmd in Windows] named for example TestBroker, there will be broker's work path in ARTEMIS_PATH/bin/TestBroker.
The file that configure connectors is broker.xml and it will be located in ARTEMIS_PATH/bin/TestBroker/etc/broker.xml

ActiveMQ messages getting stuck in networked broker setup

I have two ActiveMQ brokers in a network setup. The clients are configured with randomize=true and are able to connect fine. However, the messages do not get forwarded from one broker to the other and remain in the queue. For example, I have a particular queue which has multiple producers and one consumer. If I look at the queue on the broker to which the one consumer is connected to, all messages are dequeued immediately. However, on the other broker messages get queued and do not get drained.
Listed below are my networkConnectors and transportConnectors setup for the two brokers. I have tried adding duplex="true" as well as changing the networkTTL to 1 and those didn't seem to make any difference.
BrokerA:
<networkConnectors>
<networkConnector name="LocalBrokerToB"
networkTTL="2"
uri="static:(tcp://hostnameB:61617)"/>
</networkConnectors>
<transportConnectors>
<transportConnector name="nioConnectorFront" uri="nio://hostnameA:61616?maximumConnections=1024 "/>
<transportConnector name="nioConnectorBack" uri="tcp://hostnameA:61617?maximumConnections=1024 "/>
</transportConnectors>
BrokerB:
<networkConnectors>
<networkConnector name="LocalBrokerToA"
networkTTL="2"
uri="static:(tcp://hostnameA:61617)"/>
</networkConnectors>
<transportConnectors>
<transportConnector name="nioConnectorFront" uri="nio://hostnameB:61616?maximumConnections=1024 "/>
<transportConnector name="nioConnectorBack" uri="tcp://hostnameB:61617?maximumConnections=1024 "/>
</transportConnectors>
Any ideas on what could be the problem? An example configuration that someone has working would be a great help.
You should connect the networkConnector to the transport connector of the other broker. That is port 61616 in your example, not 61617.
You should verify in the broker logs or via Web Console / JMX that the network connection actually gets established.
Adding duplex="true" let's one of the brokers initiate the connection which is great in case of firewalls etc. In your case, that should not matter.

In my ActiveMQ config I have problems with the udp and http protocols

In chapter 4 of the book ActiveMQ in action, you add protocols. So I did
<broker ...>
<transportConnectors>
<transportConnector name="nio" uri="nio://0.0.0.0:61617?..."/>
<transportConnector name="udp" uri="udp://0.0.0.0:61618?..."/>
<transportConnector name="http" uri="http://0.0.0.0:8080?..."/>
The nio seems to be OK, but udp and http not. If you start the server, you see,
INFO | Listening for connections at: nio://walnut.nuts.org:61617?trace=true
INFO | Connector nio started
INFO | Connector udp started
INFO | Connector http started
So no listeners with udp and http.
With upd, I see nothing.
With http, I see,
Exception in thread "ActiveMQ Transport: HTTP Reader http://localhost:8080" com.thoughtworks.xstream.io.StreamException: : input contained no data
What am I doing wrong?
Thanks.

ActiveMQ 5.8 network of broker with custom jmx port

I am trying to run a network of broker with 2 brokers on the same network but on 2 different virtual machines.
Because of some internal constraints I have to use a custom jmx port.
I am using the Tanuki wrapper to launch ActiveMQ on an Ubuntu server.
Here is the relevant part of my activemq.xml
<broker xmlns="http://activemq.apache.org/schema/core" advisorySupport="false" useJmx="true" brokerName="test1" dataDirectory=".../data/activemq">
<networkConnectors>
<networkConnector uri="multicast://1.2.3.4:101234?group=test"
dynamicOnly="true"
networkTTL="3"
prefetchSize="1"
decreaseNetworkConsumerPriority="true"
userName="user"
password="password"/>
</networkConnectors>
<transportConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616" rebalanceClusterClients="true" updateClusterClients="true" />
<transportConnector name="nio" uri="nio://0.0.0.0:61617" rebalanceClusterClients="true" updateClusterClients="true" discoveryUri="multicast://1.2.3.4:101234?group=test" />
</transportConnectors>
...
<managementContext>
<managementContext createConnector="false"/>
</managementContext>
...
</broker>
Here is the relevant part of wrapper.conf:
# Uncomment to enable jmx
wrapper.java.additional.1=-Dcom.sun.management.jmxremote
wrapper.java.additional.2=-Dcom.sun.management.jmxremote.port=4321
wrapper.java.additional.3=-Dcom.sun.management.jmxremote.authenticate=false
wrapper.java.additional.4=-Dcom.sun.management.jmxremote.ssl=false
When running ActiveMQ on both broker, I see the process with the expected options:
activemq 30682 30680 3 13:27 ? 00:00:30 java -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=4321 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djavax.net.ssl.keyStore=../../conf/broker.ks -Djavax.net.ssl.trustStore=../../conf/broker.ts -Dcom.sun.management.jmxremote -Dorg.apache.activemq.UseDedicatedTaskRunner=true -Djava.util.logging.config.file=logging.properties -Dactivemq.conf=../../conf -Dactivemq.data=../../data -Xms2048m -Xmx2048m -Djava.library.path=../../bin/linux-x86-64/ -classpath ../../bin/wrapper.jar:../../bin/activemq.jar -Dwrapper.key=y4TuwO32Hj6kN7w8 -Dwrapper.port=32000 -Dwrapper.jvm.port.min=31000 -Dwrapper.jvm.port.max=31999 -Dwrapper.pid=30680 -Dwrapper.version=3.2.3 -Dwrapper.native_library=wrapper -Dwrapper.service=TRUE -Dwrapper.cpu.timeout=10 -Dwrapper.jvmid=1 org.tanukisoftware.wrapper.WrapperSimpleApp org.apache.activemq.console.Main start
The port is open on the running shorewall.
The network of broker is up but I cannot connect to the jmx using jvisualvm with server_dns:4321. It returns the error
"cannot connect to server_dns:4321 using service:jmx:rmi:///jndi/rmi://server_dns:4321/jmxrmi
I can see some traffic on the port via tcpdump.
Could anybody tell me what I am doing wrong or how I should use ActiveMQ as a Network Of Broker with a custom jmx port?
JMX needs 2 open ports. An extra one is necessary for rmi.
I figured it out thanks to this post: Apache ActiveMQ browser can't connect to JMX console
In my case the fix is to change the configuration of my wrapper to expose the rmi port and open the port on the firewall
# Uncomment to enable jmx
wrapper.java.additional.1=-Dcom.sun.management.jmxremote
wrapper.java.additional.2=-Dcom.sun.management.jmxremote.port=4321
wrapper.java.additional.3=-Dcom.sun.management.jmxremote.port=8765
wrapper.java.additional.4=-Dcom.sun.management.jmxremote.authenticate=false
wrapper.java.additional.5=-Dcom.sun.management.jmxremote.ssl=false

Configuring AMQP transport connector for ActiveMQ broker in Camel

Goal i'm trying to achieve is to start AMQP protocol listening from Apache Camel's ActiveMQ broker.
I've did create maven module from org.apache.camel.archetypes:camel-archetype-activemq (Creates a new Camel project that configures and interacts with ActiveMQ.) archetype, did mvn camel:run and it succeeded. Then after i've did a change for amqp protocol:
<!-- This creates an embedded ActiveMQ Broker -->
<broker xmlns="http://activemq.apache.org/schema/core" useJmx="true" persistent="false">
<transportConnectors>
<transportConnector name="default" uri="tcp://localhost:61616" />
<transportConnector name="amqp+nio" uri="amqp+nio://localhost:5672"/>
</transportConnectors>
</broker>
Now when i start camel i get following exception:
Listening for connections at: tcp://localhost:61616
Connector default Started
ERROR Failed to start Apache ActiveMQ. Reason: java.io.IOException:
Transport Connector could not be registered in JMX:
Transport scheme NOT recognized: [amqp+nio]
That archetype sets up a base set of ActiveMQ dependencies to kick start a minimal broker. You also need to include
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-amqp</artifactId>
<version>5.8.0</version>
</dependency>
to expose AMQP transport connectors.