Issue #2726: Fix context tracker for MessageProducer

Change-Id: Id5ba1f100d99909ef0918fb7482bbdc7540aff8e

Former-commit-id: b41584617a29a555a30aa8a0e4e5e7969ed4bfc2
This commit is contained in:
Richard Peter 2014-04-21 13:53:48 -05:00
parent 5f82bb7cc8
commit 3daac788ad
2 changed files with 32 additions and 18 deletions

View file

@ -375,8 +375,14 @@ public class MessageProducer implements IMessageProducer, InterceptStrategy {
* track the thread this context is using for proper dependency
* management.
*/
CamelContext prev = MessageProducer.this.currentThreadContext
.get();
MessageProducer.this.currentThreadContext.set(context);
target.process(exchange);
try {
target.process(exchange);
} finally {
MessageProducer.this.currentThreadContext.set(prev);
}
}
@Override
@ -385,12 +391,16 @@ public class MessageProducer implements IMessageProducer, InterceptStrategy {
* track the thread this context is using for proper dependency
* management.
*/
CamelContext prev = MessageProducer.this.currentThreadContext
.get();
MessageProducer.this.currentThreadContext.set(context);
try {
target.process(exchange);
} catch (Throwable e) {
exchange.setException(e);
} finally {
MessageProducer.this.currentThreadContext.set(prev);
}
callback.done(true);
return true;

View file

@ -43,7 +43,7 @@ import com.raytheon.uf.edex.core.IContextStateProcessor;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 17, 2013 2161 bkowal Initial creation.
* Mar 11, 2014 2726 rjpeter Graceful shutdown.
* Mar 11, 2014 2726 rjpeter Graceful shutdown, don't forward empty pdo lists.
* </pre>
*
* @author bkowal
@ -99,14 +99,16 @@ public class ModelSoundingPersistenceManager implements IContextStateProcessor {
if (container != null) {
List<PluginDataObject> pdoList = container.getPdos();
PluginDataObject[] pdos = pdoList
.toArray(new PluginDataObject[pdoList.size()]);
try {
EDEXUtil.getMessageProducer().sendSync(
"modelSoundingPersistIndexAlert", pdos);
} catch (EdexException e) {
logger.error("Failed to persist " + pdos.length
+ " PluginDataObject(s)!", e);
if ((pdoList != null) && !pdoList.isEmpty()) {
PluginDataObject[] pdos = pdoList
.toArray(new PluginDataObject[pdoList.size()]);
try {
EDEXUtil.getMessageProducer().sendSync(
"modelSoundingPersistIndexAlert", pdos);
} catch (EdexException e) {
logger.error("Failed to persist " + pdos.length
+ " PluginDataObject(s)!", e);
}
}
}
} catch (Throwable e) {
@ -125,14 +127,16 @@ public class ModelSoundingPersistenceManager implements IContextStateProcessor {
protected void storeContainer(ModelSoundingStorageContainer container) {
List<PluginDataObject> pdoList = container.getPdos();
PluginDataObject[] pdos = pdoList.toArray(new PluginDataObject[pdoList
.size()]);
try {
EDEXUtil.getMessageProducer().sendSync(
"modelSoundingPersistIndexAlert", pdos);
} catch (EdexException e) {
logger.error("Failed to persist " + pdos.length
+ " PluginDataObject(s)!", e);
if ((pdoList != null) && !pdoList.isEmpty()) {
PluginDataObject[] pdos = pdoList
.toArray(new PluginDataObject[pdoList.size()]);
try {
EDEXUtil.getMessageProducer().sendSync(
"modelSoundingPersistIndexAlert", pdos);
} catch (EdexException e) {
logger.error("Failed to persist " + pdos.length
+ " PluginDataObject(s)!", e);
}
}
}