Issue #2726: Fix context tracker for MessageProducer
Change-Id: Id5ba1f100d99909ef0918fb7482bbdc7540aff8e Former-commit-id:3daac788ad
[formerlyc23e741c65
[formerly b41584617a29a555a30aa8a0e4e5e7969ed4bfc2]] Former-commit-id:c23e741c65
Former-commit-id:90c6eeb91d
This commit is contained in:
parent
0bf7593ccd
commit
4c45d0dae6
2 changed files with 32 additions and 18 deletions
|
@ -375,8 +375,14 @@ public class MessageProducer implements IMessageProducer, InterceptStrategy {
|
||||||
* track the thread this context is using for proper dependency
|
* track the thread this context is using for proper dependency
|
||||||
* management.
|
* management.
|
||||||
*/
|
*/
|
||||||
|
CamelContext prev = MessageProducer.this.currentThreadContext
|
||||||
|
.get();
|
||||||
MessageProducer.this.currentThreadContext.set(context);
|
MessageProducer.this.currentThreadContext.set(context);
|
||||||
|
try {
|
||||||
target.process(exchange);
|
target.process(exchange);
|
||||||
|
} finally {
|
||||||
|
MessageProducer.this.currentThreadContext.set(prev);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -385,12 +391,16 @@ public class MessageProducer implements IMessageProducer, InterceptStrategy {
|
||||||
* track the thread this context is using for proper dependency
|
* track the thread this context is using for proper dependency
|
||||||
* management.
|
* management.
|
||||||
*/
|
*/
|
||||||
|
CamelContext prev = MessageProducer.this.currentThreadContext
|
||||||
|
.get();
|
||||||
MessageProducer.this.currentThreadContext.set(context);
|
MessageProducer.this.currentThreadContext.set(context);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
target.process(exchange);
|
target.process(exchange);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
exchange.setException(e);
|
exchange.setException(e);
|
||||||
|
} finally {
|
||||||
|
MessageProducer.this.currentThreadContext.set(prev);
|
||||||
}
|
}
|
||||||
callback.done(true);
|
callback.done(true);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -43,7 +43,7 @@ import com.raytheon.uf.edex.core.IContextStateProcessor;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Jul 17, 2013 2161 bkowal Initial creation.
|
* 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>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author bkowal
|
* @author bkowal
|
||||||
|
@ -99,6 +99,7 @@ public class ModelSoundingPersistenceManager implements IContextStateProcessor {
|
||||||
|
|
||||||
if (container != null) {
|
if (container != null) {
|
||||||
List<PluginDataObject> pdoList = container.getPdos();
|
List<PluginDataObject> pdoList = container.getPdos();
|
||||||
|
if ((pdoList != null) && !pdoList.isEmpty()) {
|
||||||
PluginDataObject[] pdos = pdoList
|
PluginDataObject[] pdos = pdoList
|
||||||
.toArray(new PluginDataObject[pdoList.size()]);
|
.toArray(new PluginDataObject[pdoList.size()]);
|
||||||
try {
|
try {
|
||||||
|
@ -109,6 +110,7 @@ public class ModelSoundingPersistenceManager implements IContextStateProcessor {
|
||||||
+ " PluginDataObject(s)!", e);
|
+ " PluginDataObject(s)!", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
// fail safe so store thread doesn't fail
|
// fail safe so store thread doesn't fail
|
||||||
logger.error(
|
logger.error(
|
||||||
|
@ -125,8 +127,9 @@ public class ModelSoundingPersistenceManager implements IContextStateProcessor {
|
||||||
|
|
||||||
protected void storeContainer(ModelSoundingStorageContainer container) {
|
protected void storeContainer(ModelSoundingStorageContainer container) {
|
||||||
List<PluginDataObject> pdoList = container.getPdos();
|
List<PluginDataObject> pdoList = container.getPdos();
|
||||||
PluginDataObject[] pdos = pdoList.toArray(new PluginDataObject[pdoList
|
if ((pdoList != null) && !pdoList.isEmpty()) {
|
||||||
.size()]);
|
PluginDataObject[] pdos = pdoList
|
||||||
|
.toArray(new PluginDataObject[pdoList.size()]);
|
||||||
try {
|
try {
|
||||||
EDEXUtil.getMessageProducer().sendSync(
|
EDEXUtil.getMessageProducer().sendSync(
|
||||||
"modelSoundingPersistIndexAlert", pdos);
|
"modelSoundingPersistIndexAlert", pdos);
|
||||||
|
@ -135,6 +138,7 @@ public class ModelSoundingPersistenceManager implements IContextStateProcessor {
|
||||||
+ " PluginDataObject(s)!", e);
|
+ " PluginDataObject(s)!", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checking in a model sounding container makes it available for the store
|
* Checking in a model sounding container makes it available for the store
|
||||||
|
|
Loading…
Add table
Reference in a new issue