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
Related
I have some transactional code that worked very well in old versions of Apache Karaf. Now in Apache Karaf 4.0.4 I see a lot of exceptions.
java.lang.IllegalStateException: Cannot log transactions as org.apache.derby.jdbc.EmbedXAResource#77cbf3e5 is not a NamedXAResource.
and
org.apache.aries.transaction.manager - 1.3.0 | Please correct the integration and supply a NamedXA
java.lang.IllegalStateException: Cannot log transactions as TransactionContext{transactionId=null,connection=ActiveMQConnection
I found the answer and post it here to give others a quicker way to solve the same problem. It took me quite a while and some help from Guillaume to figure this out.
The geronimo transaction manager that is used in Apache Karaf inside the Aries transaction manager bundle can recover transactions. By default this feature is switched off in older karaf versions. In Apache Karaf 4.0.4 this has changed.
The config etc/org.apache.aries.transaction.cfg contains this setting
aries.transaction.recoverable = true
It activates the recovery support. The downside of this is that all jdbc and jms Connections must then implement NamedXAResource. This is outside the standard so most jdbc and jms providers do not support this.
The solution for ActiveMQ is to use the JCAPoolingConnectionFactory. For jdbc you can wrap your XADataSource using aries transaction jdbc. It provides a pooling support that also supports recovery.
If you are happy with how your application worked before you can simply set the above switch back to false. The transactions will then work like in older Apache Karaf versions.
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.
We recently upgraded from JBoss 4.2 to JBoss 6.1. The new JMS messaging (now using HornetQ) gets stuck, where there are 15 consumers, but no more than 15 messages are processed. It looks like an acknowledge problem, where the messages are not getting acknowledged. They are consumed by a MDB that is written with EJB 2.0, and the acknowledge-mode is Auto-acknowledge (we are currently experimenting with bringing it up to 2.1 to see if that makes a difference). Has anyone experience this? Is there a way to configure the server to Auto-acknowledge by default?
The bean is in a container managed transaction.
The source of the problem is here. Once that exception happens, the queue is basically dead, and will not acknowledge further messages.
You should provide a valid testcase to HornetQ developers (or application server developers) showing that there's a valid usecase you are doing, and it's not an invalid usage.
So far the exception you showed is caused by an invalid XA usage, what doesn't make it a bug on HornetQ so far.
How can i can achieve remote transaction while using Remote EJB (over RMI/IIOP or RMI/JRMP).
Is that JBoss 4.0 support this kind of transaction or should i use jotm or atomikos?
Thanks in advance
JBoss 4 is a certified J2EE 1.4 application server and thus supports client-controlled transaction which are part of the J2EE specification. In other words, JBoss provides a Transaction Manager, there is no need for a standalone transaction manager like JOTM, Atomikos, etc.
For the record, JBoss default transaction manager is based on Arjuna TS since JBoss 4.2 which is a rock solid technology.
See the chapter 4.2.3. UserTransaction Support for more details.
From jboss.org. This example is from v. 3.2 but I know it works through v. 4.0.3
There is no way to handle transactions from the client without using a TM on the client. The way to design apps is to call services on the server that handle that for you. All J2EE containers that include JTS/JTA (Ones that are more than just web app servers) will support single a two-phase transaction processing.
The client piece should be in charge of just doing presentation and possibly doing calculations as well as they pertain to displaying the data.
if you must use this strategy, go ahead use a Transaction Coordinator (TM) on the client like JOTM or Atomikos or even possibly JBOSS's JBoss transactions.
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.