Author: clebert.suconic(a)jboss.com
Date: 2010-02-26 19:01:24 -0500 (Fri, 26 Feb 2010)
New Revision: 8905
Modified:
trunk/src/main/org/hornetq/ra/inflow/HornetQActivation.java
trunk/src/main/org/hornetq/ra/inflow/HornetQMessageHandler.java
Log:
https://jira.jboss.org/jira/browse/HORNETQ-312 - Fixing multiple sessions on MDB durable
Modified: trunk/src/main/org/hornetq/ra/inflow/HornetQActivation.java
===================================================================
--- trunk/src/main/org/hornetq/ra/inflow/HornetQActivation.java 2010-02-26 17:32:57 UTC
(rev 8904)
+++ trunk/src/main/org/hornetq/ra/inflow/HornetQActivation.java 2010-02-27 00:01:24 UTC
(rev 8905)
@@ -261,7 +261,7 @@
{
ClientSession session = setupSession();
- HornetQMessageHandler handler = new HornetQMessageHandler(this, session);
+ HornetQMessageHandler handler = new HornetQMessageHandler(this, session, i);
handler.setup();
session.start();
handlers.add(handler);
Modified: trunk/src/main/org/hornetq/ra/inflow/HornetQMessageHandler.java
===================================================================
--- trunk/src/main/org/hornetq/ra/inflow/HornetQMessageHandler.java 2010-02-26 17:32:57
UTC (rev 8904)
+++ trunk/src/main/org/hornetq/ra/inflow/HornetQMessageHandler.java 2010-02-27 00:01:24
UTC (rev 8905)
@@ -64,11 +64,14 @@
private final HornetQActivation activation;
private boolean useLocalTx;
+
+ private final int sessionNr;
- public HornetQMessageHandler(final HornetQActivation activation, final ClientSession
session)
+ public HornetQMessageHandler(final HornetQActivation activation, final ClientSession
session, final int sessionNr)
{
this.activation = activation;
this.session = session;
+ this.sessionNr = sessionNr;
}
public void setup() throws Exception
@@ -107,6 +110,13 @@
}
else
{
+ // The check for already exists should be done only at the first session
+ // As a deployed MDB could set up multiple instances in order to process
messages in parallel.
+ if (sessionNr == 0 && subResponse.getConsumerCount() > 0)
+ {
+ throw new javax.jms.IllegalStateException("Cannot create a subscriber
on the durable subscription since it already has subscriber(s)");
+ }
+
SimpleString oldFilterString = subResponse.getFilterString();
boolean selectorChanged = selector == null && oldFilterString != null
||