JBoss configuration : Where should JMS Bridge configuration be? - java

I'm new to JMS programming (Java).
I have a machine M1, in a domain D1 and a machine M2 in another domain D2.
I have in M1 a JMS producer. And in M2 a JMS consumer. Both have as servers JBoss 7.2.
So it seems the only solution is to create a JMS bridge.
I'm reading the official documentation. So I wonder if creating an SSH tunnel is necessary.
Second, in which hornetq-configuration.xml file should I set the following configuration?
<bridge name="my-bridge">
<queue-name>jms.queue.sausage-factory</queue-name>
<forwarding-address>jms.queue.mincing-machine</forwarding-address>
<filter-string="name='aardvark'"/>
<transformer-class-name>
org.hornetq.jms.example.HatColourChangeTransformer
</transformer-class-name>
<retry-interval>1000</retry-interval>
<ha>true</ha>
<retry-interval-multiplier>1.0</retry-interval-multiplier>
<reconnect-attempts>-1</reconnect-attempts>
<failover-on-server-shutdown>false</failover-on-server-shutdown>
<use-duplicate-detection>true</use-duplicate-detection>
<confirmation-window-size>10000000</confirmation-window-size>
<user>foouser</user>
<password>foopassword</password>
<static-connectors>
<connector-ref>remote-connector</connector-ref>
</static-connectors>
<!-- alternative to static-connectors
<discovery-group-ref discovery-group-name="bridge-discovery-group"/>
-->
</bridge>
Should it be in the in JBoss server of the JMS producer machine or consumer machine?
My third question is, is there a difference in settings between JMS bridge and core bridge?
I would be so thankful for any additional information and explainations!
Thank you a lot!

I know this is little late for OP, may be this information helps someone.
Firstly, the difference between Core and JMS bridge.
Read doc here
Core bridges are for linking a HornetQ node with another HornetQ node and do not use the JMS API. A JMS Bridge is used for linking any two JMS 1.1 compliant JMS providers.
The Core bridge uses proprietary HornetQ core api so it can only connect two HornetQ servers. Whereas JMS bridges use the JMS API so could connect any JMS1.1 API complaint servers.eg: HornetQ to ActiveMQ.
The configuration mentioned in question is Core bridge and can be configured in the source server.Since you seem to connect two HornetQ server Core bridges is the way forward. That said, in your case you could use JMS bridges as well since both are JMS complaint.But the recommended approach would be to use Core bridge due to performance advantage gain.
Finally, the JBoss installation server comes with some handy examples.You could find Core bridge example under [JBOSS_HOME]\jboss-as\extras\hornetq\examples\jms\bridge.

Related

JMS connection from Java SE

I would like to create a JMS connection from a Java SE application in a broker-agnostic way.
I'm comparing to JDBC with its URL scheme for database connections. This creates independence from the actual implementation.
For JMS I haven't found something similar. I'm aware that in Java EE the JNDI will fulfill this role, but this is Java SE.
I don't want to tie my code to any particular queue broker as my needs are pretty simple JMS 1.1 send/receive of text messages.
I've looked at Spring Boot too because it is usually good at providing some level of agnosticism. But even with Spring Boot, I do not see such possibility.
JNDI is the way you write your JMS application to connect in a broker-agnostic way. JNDI client classes are part of Java SE. Both Spring and non-Spring Java SE applications use JNDI for this kind of integration.
Any JMS implementation should also provide a JNDI implementation that can be plugged into your application. Typically this is done by placing a file named jndi.properties on your classpath and putting the proper configuration for whatever JNDI implementation you're using into that file. When you create an empty InitialContext the jndi.properties file on your classpath is read automatically. The key=value pairs in jndi.properties are put into the InitialContext so that when you perform a lookup everything works with the implementation you've chosen. You can also configure this programmatically if you like by supplying the implementation specific details to the InitialContext via a constructor.
By using both the JMS and JNDI APIs in your Java SE application and externalizing broker-specific connection details to your jndi.properties file you can effectively isolate your applications from broker-specific code so you can deploy your app and work with different brokers with a few simple changes in a properties file.
The JNDI client implementation will come from whoever is providing the JMS implementation. The JNDI client essentially comes in the form of an javax.naming.spi.InitialContextFactory implementation packaged in a jar and there is usually documentation describing the available properties.
Here are a few examples:
The ActiveMQ 5.x broker provides org.apache.activemq.jndi.ActiveMQInitialContextFactory available in their activemq-client-<version>.jar. Documentation is available here.
The ActiveMQ Artemis broker provides org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory available in their artemis-jms-client-<version>.jar. Documentation is available here.
To be clear, the JMS specification doesn't require the use of JNDI to look-up admin objects, but it establishes the convention and expectation that JMS providers will do so. Section 4.2 of the JMS 1.1 specification states:
Although the interfaces for administered objects do not explicitly depend on JNDI, JMS establishes the convention that JMS clients find them by looking them up in a namespace using JNDI.
and later it says:
It is expected that JMS providers will provide the tools an administrator needs to create and configure administered objects in a JNDI namespace. JMS
provider implementations of administered objects should be both javax.naming.Referenceable and java.io.Serializable so that they can be stored in all JNDI naming contexts.
In my experience, JMS providers are usually eager to provide a JNDI implementation because they won't be as competitive without it since any alternative solution will not be standards compliant and will force users to implement non-portable code.
If you run into a provider that doesn't provide a JNDI implementation you could implement your own following the same pattern used by ActiveMQ 5.x, ActiveMQ Artemis, and Qpid JMS. These 3 implementations are client-side only and simply instantiate the admin objects based on the configuration provided to the InitialContext. Most of the code is boiler plate, and what isn't is very straight-forward.

ActiveMQ 5.1.1 WebSphere 8.5.5 Activation Spec configuration?

Thanks to Maarten I was able to get basic ActiveMQ JMS topics and connection factories working in WAS. He has a nice write up in his reply to this topic: ActiveMQ 5.11 with WebSphere Application Server 8.5
But I cannot find a way to define any ActiveMQ JMS Activation Specs in the WAS admin console. And of course I need those in order to trigger my MDBs. ActiveMQ simply doesn't show up as a JMS provider when creating a new AS.
How do I configure Activation Specs in WAS using ActiveMQ as the provider? Am I missing a jar file?
activemq-client-5.11.0.jar
hawtbuf-1.11.jar
slf4j-api-1.7.10.jar
If you want to use Activation specification, you need to install ActiveMQ as JCA 1.5 compliant resource adapter. As far as I know, ActiveMQ provides resource adapter as separate install.
See also:
Deploying the ActiveMQ Resource Adapter into IBM WebSphere
Managing messaging with a third-party JCA 1.5 or 1.6-compliant messaging provider
ActiveMQ resource adapter
Listener ports are stabilized, and should only be used if provider doesn't support JCA.
Really straight forward once you understand (of course).
From the IBM Redbook mentioned above, sg247770.pdf, we need to configure ActiveMQ as a Generic JMS provider in WAS. And since we want to use Activation Specs, again from the Redbook, we need to use the ActiveMQ Resource Adapter, or rar file. There is a link on the ActiveMQ page to the latest rar, I don't need to provide it here. Once the rar is installed, using the WAS Console/Resources/Resource Adapters menu, you can configure J2C CFs, ASs, and administered objects including Queues and Topics from the rar configuration page. These will all have custom properties where you will enter your destinations, etc.

Using AMQP with JTA

Are there any good examples of using AMQP client in CMT/JTA environment? I know that AMQP supports transactional messaging, but I don't know how it aligns with JTA.
So far I have managed to setup Apache Qpid java broker and connect to it from a Java application using latest JBossTS (Narayana 5.0.0.M1) as standalone JTA. Basic tests showed that messages successfully appear in a queue when I commit TX and are properly ignored when I rollback. But I'm not sure whether this proves that I can safely use Qpid client in CMT.
There is a linkedin AMQP Group where it's said:
"There started a sub spec of AMQP 1.0 concerning distributed tx which was heavily influenced by Microsoft. Totally incompatible with JTA."
That might be reason why you (and me too) haven't found any example.
source: https://www.linkedin.com/groups/AMQP-JTA-1369617.S.5995685814774882304?trk=groups_most_popular-0-b-ttl&goback=%2Egmp_1369617

Tibco with JMS Application

I want to use tibco in my jms application. Can any one help me how can I use tibco and also please what are the benefits from tibco.
Take a look at the samples directory in your Tibco EMS installation directory. It provides samples for the most common scenarios using the ems libs directly.
If you are using Spring to wire up your messaging there really isn't anything different you do for EMS compared to connnecting to ActiveMQ for example. Create a MessageListenerContainer or a JMSTemplate and you are on your way.
The different between TIBCO EMS and other JMS providers is a BIG question (bascially a trade-off between price, your open-source affinity, 24/7 customer support etc.)
How to use it ?
I would recommend writing your own example JMS consumer, straigth from examples from a good book, for example: Java Message Service, by Richard Monson-Haefel and others.
(this one is small but concise)
and then configure your example with arguments like this:
For TIBCO's EMS JNDI:
-jndiContextFactory com.tibco.tibjms.naming.TibjmsInitialContextFactory
-jndiProviderUrl tibjmsnaming://localhost:7222
-topic TEST
..

JBoss JMS provider

I need to write a Message Driven Bean. I'm using JBoss IDE 1.5. I understand the concept behind MDB's but I don't really know how to install the JMS provider (JBoss MQ? I think) and use it so that it will be used to broker my message to an MDB.
does anyone know of a tutorial I can use ?
JBossMQ is the default JMS provider in JBoss 3.2.x and 4.x but is replaced by JBoss Messaging1 in JBoss AS 5.0 (JBoss Messaging 1.x is the default JMS provider in JBoss AS version 5).
Depending on the version of JBoss you are using, you already have a JMS provider so I'm not sure what you want to install. And for the configuration part (e.g. how to create a Queue/Topic to which you could send messages), you have to provide some XML files.
Check the Configuration section of http://www.jboss.org/community/wiki/jbossmq and especially the Destinations page for JBossMQ. This blog post might help too.
Check the chapter 6.6 Configuring Destinations of the Jboss Messaging 1.4 user guide. This blog post might help.
Note that starting with JBoss AS version 5.1.0, there is an admin console that allows to create JMS Destinations (expand the "JMS Destinations" entry in the tree view, click on either Queues or Topics, and the in the right panel click the "Add a new resource" button) and/or Connection Factories.
1Starting from version 2.0, JBoss Messaging has been rebranded to HornetQ.

Categories

Resources