Hello,

Following the karaf-scheduler-example for a Runnable service (
https://github.com/apache/karaf/tree/main/examples/karaf-scheduler-example/karaf-scheduler-example-runnable)
i implemented a similar Job-based service. Please see attached the Job
itself and its pom.xml. I placed it in a module within the existing
examples project only for local testing purpose, so please don't mind the
official groupId/package..

Then the job was executed 5 times as expected, but each time if i tried to
read from the JobContext the configuration attribute, it is always null
(org.apache.karaf.scheduler.JobContext#getConfiguration). I tried to figure
out by looking at the scheduler sources
(org.apache.karaf.scheduler.core.QuartzScheduler) how the job is scheduled,
but couldn't find that there is any configuration set there in any case.
Please tell me if i missed something, if such configuration would be
available to the job implementor at all in any case, and what to expect
there ?



Hope you got my question..

Thank you,

Regards,

Vassil Zorev

Attachment: SampleJob.java
Description: Binary data

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0";
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd";>
    <parent>
        <groupId>org.apache.karaf.examples</groupId>
        <artifactId>karaf-scheduler-example</artifactId>
        <version>4.2.12-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>karaf-scheduler-example-job</artifactId>
    <name>Apache Karaf :: Examples :: Scheduler :: Job</name>

    <dependencies>
        <dependency>
            <groupId>org.apache.karaf.scheduler</groupId>
            <artifactId>org.apache.karaf.scheduler.core</artifactId>
            <!--<version>4.2.12-SNAPSHOT</version>-->
            <version>4.3.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>osgi.cmpn</artifactId>
            <version>6.0.0</version>
        </dependency>
    </dependencies>

    <packaging>bundle</packaging>
    <modelVersion>4.0.0</modelVersion>

    <properties>
        <maven.compiler.source>9</maven.compiler.source>
        <maven.compiler.target>9</maven.compiler.target>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

Reply via email to