다른 bean (로컬 삽입)의 비동기 메소드를 사용하여 일부 데이터를 삽입하는 상태 비 저장 빈을 보유하고 있습니다. 이 데이터 삽입에는 시간이 걸리기 때문에이 작업을 마칠 때까지 기다리지 않아도됩니다. 이 데이터 삽입 후 같은 bean의 다른 메소드를 호출하려고한다. 디버그 지점을 메서드에 넣으면 서버는이 지점에 도달하는 데 약 90 초 동안 기다립니다. Jboss는 트랜잭션이 비동기 메소드를 완료하기를 기다릴 수 있습니다. 나는 무슨 일이 일어나고 있는지 모른다. .JBOSS EAP 6은 비동기 방식으로 ejb 메소드 호출을 차단했습니다.
@Stateless
public class SimulationNodePersistenceBean implements SimulationNodePersistenceRemote, SimulationNodePersistenceLocal {
@Resource
SessionContext context;
@EJB
private SimulationResultGraphPersitenceBean graphPersistenceBean;
@Asynchronous
@TransactionAttribute(TransactionAttributeType.REQUIRED)
private void addResultGraphsToDatabase(long id, Graph[] graphList) {
ResultGraph paramGraph;
ResultGraphPoint dataPoint;
Graph graph;
for (int i = 0; i < graphList.length; i++) {
graph = graphList[i];
paramGraph = new ResultGraph();
try {
graphPersistenceBean.persistGraph(paramGraph);
} catch (Exception databaseException) {
// TODO add error message to the contingency simulation messages
// list
logger.error("Error saving ResultGraph:" + paramGraph);
}
}
long duration = System.nanoTime() - startTime;
logger.debug("Graphs inserted to DB in (sec) :" + (duration/NANO_SECOND_CONVERSION_FACTOR));
}
// @Asynchronous
public void persistSimulationResults(long contingencySimulationId, Graph[] graphList,
List<AB> reiList) {
if (graphList != null) {
addResultGraphsToDatabase(contingencySimulationId, graphList);
}
if (reiList != null) {
//another method
}
calculateContSimStability(contingencySimulationId);
}
@Override
public void calculateSimIndex(long id) {
}
주요 콩
@Stateless
public class SimulationResultGraphPersitenceBean {
@PersistenceContext(unitName = "DBService")
private EntityManager em;
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
@Asynchronous
public void persistGraph(ResultGraph graph) throws SiGuardPersistenceException {
try {
ResultGraphService service = new ResultGraphService(em);
service.create(graph);
em.flush();
} catch (Exception ex) {
throw new PersistenceException("Error persisting graph", ex);
}
}
에서 호출 이것은 다른 콩이 클라이언트입니다 주요 bean.This는 비동기 적으로 작동 호출합니다.
이 메서드를 호출 한 후에는 SimulationNodePersistenceBean의 다른 메서드를 호출합니다.이 메서드는 몇 분 동안 기다립니다.
getSimulationEJB().calculateSimIndex(contSimId);
jstack을 사용하여 스레드 덤프를 만들었습니다. 실제로 Jboss As 6에서이 문제가 발생하지 않았습니다. Jboss EAP 6으로 응용 프로그램을 마이그레이션했습니다. 4. 구성을 변경해야 할 수도 있습니다. 그러나 나는 무엇을해야하는지 모른다.
스레드 덤프를 확인했습니다. 블로킹 상태에서는 스레드를 찾지 못했습니다. 다른 키워드를 찾아야합니까?
문제를 설명하기 위해 몇 가지 샘플 코드 (또는 의사 코드)를 제공 할 수 있다면 쉽게 이해할 수 있습니다. –
코드를 추가하여 편집했습니다. – user725455
addResultGraphsToDatabase() 메소드에 대한 호출이 표시되지 않습니다. 내 생각 엔 당신이 persistSimulationResults()에서 호출하는 것입니다. 무엇보다도 비동기 적으로 호출되었는지 확인해야합니다 (비동기 및 동기화 메소드를 혼합 할 때). 비동기 메소드를 sessionContext에서 호출하는 것을 잊지 마십시오. 나는 당신이이 일반적인 실수를 저 지르지 않았 음을 확신하고 싶습니다. https://satishgopal.wordpress.com/2011/04/24/ejb-3-1-asynchronous-methods/ ("동기화 및 비동기 혼합"단락을보십시오) 여기를보십시오. 알려줘. –