Interest of using activeMQ resource adapter - java

I am creating a Java application in eclipse to let different devices communicate together using a publish/subscribe protocol.
I am using Jboss and ActiveMQ and I want to know if I should use an ActiveMQ resource adapter to integrate the broker in jboss in a standalone mode or I should just add dependencies in my pom.xml file and use explicit java code like indicated here http://activemq.apache.org/how-do-i-embed-a-broker-inside-a-connection.html.
Here the documentation I found to integrate ActiveMQ within jboss in a standalone mode https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_A-MQ/6.1/html/Integrating_with_JBoss_Enterprise_Application_Platform/DeployRar-InstallRar.html
Could someone tell me what is the difference between the two approaches?

Here is the answer for my question:
The first approach starts a broker within your webapp itself. You can use a
normal consumer (not a message-driven bean - MDB), but only your webapp can
access it, via the VM transport (vm://).
The second approach lets the app server manage both the connection to the
broker and the creation of the broker, so it's probably also within the JVM
that runs your webapp and probably only accessible to your webapp, but
those details are hidden from you by the app server. You can only consume
messages via an MDB, but this provides a uniform interface that doesn't
need to change if you switch to another JMS provider in the future.
Since the standard way to integrate a JEE webapp with a JMS broker is via
the RA, I'd recommend using that approach simply for consistency and
standardization. That should also allow you to switch to a standalone
ActiveMQ broker (or another JMS product) in the future with minimal effort.

Related

Wildfly remote EJB calls through outbound connection through loadbalancer

We have some Wildfly servers running in standalone mode.
Every single instance provides a bunch of stateless services that can be accessed through ejb remote calls (http-remoting) from some webapplications.
The outbound connection of the webapplication points to a http loadbalancer using round robin, no stickiness. This balancers checks the availability of the service applications before connecting.
This work so far, failover also.
The problem:
The number of standalone servers could vary. Once an outbound connection is established from one of the webapps it will never be closed. So always the same standalone server is reached until it would die.
The purpose that under heavy load we just start another VM running a standalone server that would also be used by the loadbalancer does not work, because no new connection is established from the webapps.
Question:
Is this a scenario that could work, and if, is it possible to configure the webapps to start a new connection after some time, requests counts, or whatever?
I tried no keep alives for tcp or http header in undertow and request idle time, but no success so far.
Kind regards
Marcus
There is no easy way to dynamically load balance ejb remote calls due to their binary nature. The JBoss EJB client enables specifications of multiple remote connections, that are invoked in round-robin fashion, but the list is still hardcoded in your client config.
Example jboss client config jboss-ejb-client.properties:
endpoint.name=client-endpoint
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=node1,node2
remote.connection.node1.host=192.168.1.105
remote.connection.node1.port = 4447
remote.connection.node1.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.connection.node1.username=appuser
remote.connection.node1.password=apppassword
remote.connection.node2.host=192.168.1.106
remote.connection.node2.port = 4447
remote.connection.node2.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.connection.node2.username=appuser
remote.connection.node2.password=apppassword
I understand, that your web application is also java based. Is there any reason why not run both the EJB layer and Web on the same server within a single .ear deployment? That way you could use local access, or even inject #EJB beans directly into your web controllers without the need to serialize all calls into binary form for remote EJB with the benefit of much simpler configuration and better performance.
If your application is actually a separate deployment then the preferred way is to expose your backend functionality via REST API(JAX-RS). This way it would be accessible via HTTP, that you could simply access from your web app and you can load balance it just like you did with your web UI(you can choose to keep your API http context private - visible only locally for the services on the same network, or make it public e.g. for mobile apps) .
Hope that helps
You should be using the standalone-ha.xml or standalone-full-ha.xml profile. While you might not need the ha part to manage the state of stateful beans across your cluster, you need it for the ejbclient to discover the other nodes in your cluster automatically
In effect, the load balancing is done by the ejbclient, not a separate dedicated load balancer

How to manage messages in apache ActiveMQ

I have Apache ActiveMQ embedded into my java 8 server side project. Its working fine, and I am able to send and consume messages from pre-configured queues. I now need to be able programatically remove messages from the queue upon request. After reading some docs I found that Apache ActiveMQ has a sub-project called Artemis that seems to provide the required functionality. But I am a bit confused on how to do it. Is Artemis sort of plugin on top of ActiveMQ and I just need to add required dependencies and use the tools or is it a separate product and it doesn't work with Active MQ but as an independent product. If so how do I manage individual messages (in particular delete requested message) in Active MQ?
First off, 'ActiveMQ Artemis' is a sub-project within the ActiveMQ project that represents an entirely new broker with a radically different underlying architecture than the main ActiveMQ broker. You would run one or the other.
To manage messages in the ActiveMQ broker you would use the JMX Mamagement API and the Queue#remove methods it exposes to remove specific messages. This can be done using the Message ID or more broadly using a message selector to capture more than one message if need be. The JMX API is also exposed via Jolokia so that you can manage the broker via simple REST calls instead of the JMX way if you prefer.
In any case this sort of message level management on the broker is a bit of an anti-pattern in the messaging world. If you find yourself needing to treat the broker as a database then you should ask yourself why you aren't using a database since a broker is not a database. Often you will run into many more issues trying to manage your messages this way as opposed to just putting them into a database.

Reusing Tomcat Tribes configuration to send messages between nodes

I have Tomcat session replication using static members tribe configuration in my server and it is working fine. However, I wanted to leverage the same setup in my application to send messages between members of the cluster to facilitate my event architecture my app uses. The reason I want to use this is for the following reasons:
Tribes is a peer to peer communication framework already built into tomcat.
Reuse the configuration of peers.
No need to add additional overhead of new libraries.
Is there a way to programmatically gain access to Tomcat's Cluster Channel object to send message over? Or is there a way to figure out the members of the cluster to create your own channel to minimize the need to duplicate configuration?
Here is an example of using JMX to find the cluster configuration. It's pretty hacky, but there might be an cleaner way to find this information in JMX.
http://www.coderanch.com/t/570194/Tomcat/find-Tomcat-cluster-members

Does Jboss 7 support remote jndi lookups from a remote client

I have custom components that are standalone java components that do not run within the Jboss application server. These components need to interface with a HornetQ JMS queue which runs inside of AS7.
Looking at the Jboss AS 7 documentation, there seems to be conflicting information on whether remote JNDI lookup is supported or not.
This JIRA entry seems to provide some information https://issues.jboss.org/browse/AS7-1338 but it doesnt explain it well.
I guess my question is, Is it possible to access JMS queues running within the AS 7 application server from an external standalone client via remote JNDI lookup? If it is not possible is there an alternative approach that can be used to get to the JMS queues from an external remote JNDI lookup?
Looking at this comment (and subsequent ones) I'd say this is supported in AS 7.1.0.Final (and later). The fact that this goes over remoting and no longer over rmi is an implementation detail which you need to cater for in your code.

What do I need to realize notification using JMS?

I just need notification system. javax.jms.* - good solution I think, but I can't understand what do I need to use JMS?
I don't want to use any app. servers like GlassFish or Tomcat, I just would like to use standard jdk and myserver(very light) and myclient(very light too) and some MessageSystem to exchanging bitween myserver and myclient. As I understand to use JMS I need JMS Provider. For example: ActiveMQ. But I don't uderstand ActiveMQ needs any server?(GlassFish probably), and what kind of *.jar do I need from Java EE ?
JMS provider or more correctly a Message Broker can be a stand-alone application. Most of J2EE app servers include a broker inside them but yes we also have many very good stand alone JMS brokers, ActiveMQ is good, then there is OpenJMS and many others. And as they are stand alone they don't need another app server to run them. And they usually come with every needed jar as well :) SO you'll not need to copy any jar from other app-server to say ActiveMQ or OpenJMS.
ActiveMQ runs as a standalone server; it requires the Java VM like any Java application but nothing else beyond that.
Other stand alone JMS brokers (open source) which can be run standalone or even embedded in your Java application are Open Message Queue (OpenMQ) which is also included in GlassFish, and the new JBoss HornetQ message broker which will be the JMS implementation in JBoss application server.

Categories

Resources