2017-09-28 1 views
0

J'essaie d'exécuter un programme batch JSR352 Java en mode Java SE en utilisant l'implémentation JBERET. Je peux voir ma méthode main() s'exécuter. C'est dans cette méthode main() que je reçois le contrôle d'un opérateur de travail et démarre le travail.JSR352 - JBERET - Comment vérifier le journal des tâches du programme batch Java?

public static void main(String[] args) { 

    LoggingConfig logConfiguration = new LoggingConfig(); 

    logger.info("Begining Batch with JBeret approach"); 

    JobOperator jo = BatchRuntime.getJobOperator(); 
    long id = jo.start("PilotJob", null); 

    logger.info("End of Batch"); 

} 

Mais, je ne vois aucune instruction de journal à l'intérieur de mon lecteur, processeur, graveur ou écouteurs imprimés.

J'ai une logging.properties définie et chargée depuis mon dossier src/main/resources/META-INF. Les instructions de journal dans ma méthode main() sont imprimées en fonction, mais les instructions de journal dans mon lecteur/graveur/processeur et les écouteurs n'impriment pas du tout.

public class LoggingConfig { 
    public LoggingConfig() { 
     try { 
      // Load a properties file from class path that way can't be achieved 
      // with java.util.logging.config.file 

       final LogManager logManager = LogManager.getLogManager(); 
       try (final InputStream is = getClass().getResourceAsStream("/META-INF/logging.properties")) 
       { 
        logManager.readConfiguration(is); 
       } 

     } catch (Exception e) { 
      System.out.println("Error while reading Log configuration file"); 
      e.printStackTrace(); 
     } 
    } 
} 

Pourquoi mes déclarations de journaux (java bibliothèque journal) dans mon programme de commandes java à imprimer?

Voici les journaux de la méthode main(). Je peux clairement voir qu'un travail a été démarré, mais je ne sais pas pourquoi les instructions de journal du programme de traitement par lots ne sont pas imprimées.

INFO: App Begining Batch with JBeret approach - v1.0 
    INFO: org.jboss.weld.Version WELD-000900: 2.2.15 (Final) 
    INFO: org.jboss.weld.Bootstrap WELD-ENV-000014: Falling back to Java Reflection for bean-discovery-mode="annotated" discovery. Add org.jboss:jandex to the classpath to speed-up startup. 
    INFO: org.jboss.weld.Bootstrap WELD-000101: Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously. 
    WARN: org.jboss.weld.Interceptor WELD-001700: Interceptor annotation class javax.ejb.PostActivate not found, interception based on it is not enabled 
    WARN: org.jboss.weld.Interceptor WELD-001700: Interceptor annotation class javax.ejb.PrePassivate not found, interception based on it is not enabled 
    DEBUG: org.jboss.weld.Bootstrap WELD-000100: Weld initialized. Validating beans 
    DEBUG: org.jboss.weld.Reflection WELD-000620: interface javax.enterprise.inject.Intercepted is not declared @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will use this annotation, however this may make the application unportable. 
    DEBUG: org.jboss.weld.Reflection WELD-000620: interface javax.enterprise.inject.Decorated is not declared @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will use this annotation, however this may make the application unportable.   
    FINE: javax.batch.runtime.BatchRuntime Loaded BatchContainerServiceProvider with className = org.jberet.operations.JobOperatorImpl 
    TRACE: org.jberet JBERET000022: resume is not implemented for local transactions 
    DEBUG: org.jberet JBERET000017: Persisted [email protected] with id 6 
    DEBUG: org.jberet JBERET000017: Persisted [email protected] with id 6 
    INFO: App End of Batch 

Voici un code d'écouteur qui possède à la fois une instruction Sysout et une instruction Log. Les deux ne sont pas imprimés dans ma console Eclipse.

import java.util.logging.Logger; 

import javax.batch.api.listener.AbstractJobListener; 

public class PilotLibJobListener extends AbstractJobListener { 

    private final static Logger logger = Logger.getLogger("PilotLibJobListener"); 

    public void beforeJob() { 
     BatchListenerRecorder.batchListenersCountDownLatch.countDown(); 
     System.out.println("Before Job"); 
     logger.info("MyJobListener.beforeJob"); 
    } 

    @Override 
    public void afterJob() { 
     BatchListenerRecorder.batchListenersCountDownLatch.countDown(); 
     logger.info("MyJobListener.afterJob"); 
    } 

} 

Répondre

0

Pour requête de l'état d'exécution du travail, vous pouvez simplement appeler l'API appropriée sur JobOperator, par exemple, public JobExecution getJobExecution(long executionId). L'objet JobExecution renvoyé contient les dernières données.

Pour le référentiel de travaux, vous pouvez choisir le référentiel de travaux en mémoire si un référentiel de travaux jdbc est trop lourd pour votre application. Mais avec la base de données H2 par défaut, vous pouvez configurer une base de données H2 intégrée, ou basée sur des fichiers, au lieu du mode client-serveur, afin de limiter la consommation de ressources.

Pour les problèmes de consignation, pouvez-vous créer un JIRA issue ou github issue et joindre une application de test reproductible?

+0

mes propriétés jberet ont une DB H2 configurée comme job repo mais, mon problème est plus vers les instructions log dans mon programme batch java ne pas être imprimé. Je peux voir que les instructions log dans le programme principal sont imprimées mais pas celles des classes jsr352 (lecteur/writer/processor/listener) – yathirigan

+0

J'ai essayé de définir la propriété système org.jboss.logging.provider comme suggéré dans ce https : //developer.jboss.org/thread/272789 mais, ne fonctionne toujours pas. J'ai créé un problème de github https://github.com/jberet/jsr352/issues/102 avec ce problème – yathirigan