Is it possible to embed activemq broker into my servlet-container? - java

I have a few tomcat servlet-containers and I need to deploy activemq within one of them to allows the other containers connect to that broker. All the tomcats runnning on the same machine.
I need to avoid deploying a standlone message broker now, beucase it's not allowed by out producion evironment.
To be more specifiec, I'm using spring framework and as far as I understood we can write the following in order to start the embedded broker:
BrokerService broker = new BrokerService();
// configure the broker
broker.addConnector("tcp://localhost:61616");
broker.start();
But does it allow to connect to the broker not only within the same application, but also from the other tomcat instances using the 61616 port?

Yes that allows remote connection on port 61616.
At Apache Camel we have also an example of embedding ActiveMQ broker in a WAR application, and using the xml configuration of ActiveMQ. You can find it here: http://camel.apache.org/activemq-camel-tomcat.html

Related

Monitoring ActiveMQ Artemis apart from Jolokia

I hope to monitor ActiveMQ Artemis instances by configuring and using a SNMP connector by means of known Java properties
-Dcom.sun.management.snmp.interface=127.0.0.1 -Dcom.sun.management.snmp.port=50000 -Dcom.sun.management.snmp.acl=true -Dcom.sun.management.snmp.acl.file=/app/artemis/.snmp.acl
As ActiveMQ instances were monitored, but it does not work -- No error message is reported for Java SNMP properties, but no process is listening the chosen UDP port.
Is still possible to monitor ActiveMQ Artemis this way? And using JMX?
The SNMP agent was removed from Java 11 so that may be why it's not working for you.
However, you can certainly monitor ActiveMQ Artemis via JMX. See the documentation for more details on that.
If you just want to keep an eye on metrics you can use a metrics plugin. Using a plugin like the Prometheus metrics plugin would allow you to see exactly what's happening on the broker, set up alerts, etc.

Connect to RabbitMQ in docker from a stand-alone java application

I have an application A, which is spring boot, microservices based and is dockerized.
A has an inbuilt messaging framework and supports multiple implementations such as RabbitMQ, Kafka and ActiveMQ.
The default broker for the application is RabbitMQ. RabbitMQ runs in a separate container.
Now B is a java console spring boot application.
B needs to listen to a topic on RabbitMQ to receive messages from application A
I am able to implement this in a stand-alone way. That is, I use RabbitMQ specific interfaces, create connection factory and am able to receive messages in B from A.
My question is:
Will I be able to use A's messaging framework in B to listen to messages? I have tried adding a subscriber. I'm able to connect to RabbitMQ but not able to receive messages. RabbitMQ host that I'm using is "localhost"

How can two web-applications, deployed on different application servers communicate via JMS

I am having two java web applications deployed on different app-servers. I want to exchange messages between the two using JMS. I know how to do it for applications running under same app-server, but I cannot find any example for the applications distributed over different app-servers.
I am using Glassfish 4.1 as application server.
You can create queues with same names on both servers, and let the first queue push its messages to the second one using glassfish configuration, so let the imq brokers do the job. Configure the jms connection factory on the first server with the property "AddressList" with value "mq://host2:port2" with the settings for the second broker.
See the glassfish resource template for such a configuration in the OSCM Service Catalog https://github.com/servicecatalog/development/blob/master/oscm-installation/domains/bes_domain/installer/resources-template.xml
The example is the connection factory "jms/bss/masterIndexerQueueFactory" which you can find in this template.
More about the Open Source Project OSCM Cloud Service Management Software

glassfish load balancer configuration

I am trying to configure clustering in glassfish 3.1.1 server. I have made clusters but it deploys application on different port number and different ip i want it shold be handled by the load balancer and application should be run on the ip of loadbalancer only that means if a machine is down the loadbalancer redirects that request on another machine configured in loadbalancer.
How to achieve it? does any one have idea about it? or provide link of tutorial and/or blogs for the same.
http://tiainen.sertik.net/2011/03/load-balancing-with-glassfish-31-and.html
To brief up:
Steps to configure a glassfish cluster with a Load Balancer:
Create a cluster
Create instances for the cluster
Start the cluster
Deploy the web application
Create a network listener to listen the requests coming from the load balancer
Install Apache Web Server and get the mod_jk module
Edit the httpd.conf file and workers.properties file in the conf directory of apache web server
Restart the cluster, glassfish domain and apache daemon
Note: You might need to keep you firewall off if using any Linux OS.

Using ActiveMQ and GlassFish together

Latest version of both, can not see how to enable ActiveMQ as an endpoint in Glassfish. Would like to use ActiveMq as the JMS provider in Glassfish, the stuff I found on google does not make sense. Any advise welcome.
Is it possible to just use the JMS connector and poitn at ActiveMQ - believe not but have I just configured wrong ?
Thanks
Please look at this tutorial: http://javadude.wordpress.com/2011/07/21/glassfish-v3-1-running-embedded-activemq-for-jms-part-1/
I've written an article (based on Sven's) that describes how to connect an external activemq broker to glassfish and deploy a Message Driven Bean that consumes messages from ActiveMQ.
You can find it here: http://geertschuring.wordpress.com/2012/04/20/how-to-connect-glassfish-3-to-activemq-5/
Deploy activemq-rar-[version].rar as Connector Application to Glassfish
You will need some *.jars (http://weblogs.java.net/blog/rampsarathy/archive/2007/03/glassfish_v2_an_1.html) in \domains[domainName]\lib\ext
Create Connector Connection Pool with ActiveMQ
Create Connector Resource (Factory) with Connector Connection Pool from 2.
Create Queues.

Categories