candlepin/candlepin — pull request #542 by jmrodri (2014-03-19 21:12:00+00:00)
Title: Fix concurrent hornetq error.

The HornetQ sessions are not thread safe. They represent a single
thread. Updated EventSinkImpl to use a ThreadLocal for the sessions.

TEST
--------
* Verify problem exists in master still.
* Checkout master ```git checkout master```
* Deploy candlepin ```buildconf/scripts/deploy```
* verify your error log *has* the HornetQ exception:
```
2014-03-19 16:45:37,748 [job=refresh_pools_73518bf2-3a65-4f5e-837f-ccc73a362f22, org=] WARN org.hornetq.core.client - HQ214021: Invalid concurrent session usage. Sessions are not supposed to be used by more than one thread concurrently.
java.lang.Exception: trace
at org.hornetq.core.client.impl.ClientSessionImpl.startCall(ClientSessionImpl.java:1325) [hornetq-core-client-2.3.5.Final.jar:na]
at org.hornetq.core.client.impl.ClientProducerImpl.doSend(ClientProducerImpl.java:215) [hornetq-core-client-2.3.5.Final.jar:na]
at org.hornetq.core.client.impl.ClientProducerImpl.send(ClientProducerImpl.java:133) [hornetq-core-client-2.3.5.Final.jar:na]
at org.candlepin.audit.EventSinkImpl.sendEvent(EventSinkImpl.java:90) [EventSinkImpl.class:na]
at org.candlepin.audit.EventSinkImpl.emitPoolCreated(EventSinkImpl.java:114) [EventSinkImpl.class:na]
at org.candlepin.controller.CandlepinPoolManager.createPool(CandlepinPoolManager.java:367) [CandlepinPoolManager.class:na]
at org.candlepin.controller.CandlepinPoolManager.createPoolsForSubscription(CandlepinPoolManager.java:354) [CandlepinPoolManager.class:na]
at org.candlepin.controller.CandlepinPoolManager.refreshPoolsWithoutRegeneration(CandlepinPoolManager.java:167) [CandlepinPoolManager.class:na]
at org.candlepin.controller.Refresher.run(Refresher.java:90) [Refresher.class:na]
at org.candlepin.pinsetter.tasks.RefreshPoolsJob.toExecute(RefreshPoolsJob.java:78) [RefreshPoolsJob.class:na]
at org.candlepin.pinsetter.tasks.RefreshPoolsJob$$EnhancerByGuice$$73be075b.CGLIB$toExecute$0() [guice-3.0.jar:na]
at org.candlepin.pinsetter.tasks.RefreshPoolsJob$$EnhancerByGuice$$73be075b$$FastClassByGuice$$8579fe9e.invoke() [guice-3.0.jar:na]
at com.google.inject.internal.cglib.proxy.$MethodProxy.invokeSuper(MethodProxy.java:228) [guice-3.0.jar:na]
at com.google.inject.internal.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:72) [guice-3.0.jar:na]
at com.google.inject.persist.jpa.JpaLocalTxnInterceptor.invoke(JpaLocalTxnInterceptor.java:66) [guice-persist-3.0.jar:na]
at com.google.inject.internal.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:72) [guice-3.0.jar:na]
at com.google.inject.internal.InterceptorStackCallback.intercept(InterceptorStackCallback.java:52) [guice-3.0.jar:na]
at org.candlepin.pinsetter.tasks.RefreshPoolsJob$$EnhancerByGuice$$73be075b.toExecute() [guice-3.0.jar:na]
at org.candlepin.pinsetter.tasks.KingpinJob.execute(KingpinJob.java:76) [KingpinJob.class:na]
at org.quartz.core.JobRunShell.run(JobRunShell.java:213) [quartz-2.1.5.jar:na]
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557) [quartz-2.1.5.jar:na]
```

* Verify problem is fixed
* Checkout this PR ``` git checkout hornetq-fix```
* deploy candlepin ```buildconf/scripts/deploy```
* Verify that there is no concurrent session usage warning from HornetQ in the logs from this deployment. You might want to clear your logs or rotate them, or be very diligent in looking at the timestamps.