Comments (6)
@simllll Simon, I'm sure that the problem is related to the MongoDB connection because the job doesn't run at the given time, But as soon as i start my server it runs the job
from agenda.
@simllll @harisvsulaiman @koresar Is there anyone who can help me with this Please?
from agenda.
Unfortuantely we cannot help everyone to solve their problems on-hand.
What you can do:
1.) Write a mini repo script that reproduces the issue to track it down, without any other magic.
2.) Debug the timestamps and activate the debug log of agenda (e.g. run your script with DEBUG=agenda:* node yourScript.ts
)
from agenda.
@simllll i provided my code to you by email please check.
from agenda.
@simllll My code:
import express from 'express';
const router = express.Router();
import { MongoDBConnection } from './db.js'
import { Agenda } from '@hokify/agenda';
const connection = await MongoDBConnection();
const agenda = new Agenda({ mongo: connection });
function GetTime() {
const currentTime = new Date();
const newTime = new Date(currentTime.getTime() + 10000);
return newTime;
}
agenda.define('ScheduleUserExpiration', async job => {
await AgendaWorking(job.attrs.data.email);
});
(async function () {
agenda
.on('ready', () => console.log("Agenda started!"))
.on('error', () => console.log("Agenda connection error!"));
await agenda.start();
})();
router.post('/callagenda', async (req, res) => {
const { email } = req.body;
console.log(email)
ScheduleUserExpiration(email);
res.send("He")
})
agenda.on('start', job => {
console.log(`Job ${job.attrs.name} started`);
});
agenda.on('complete', job => {
console.log(`Job ${job.attrs.name} completed`);
});
agenda.on('fail', (err, job) => {
console.log(`Job ${job.attrs.name} failed with error: ${err.message}`);
});
const ScheduleUserExpiration = async (email) => {
const expirationTime = await GetTime();
const jobData = {
email: email,
};
const jobOptions = {
maxAttempts: 3,
backoff: '1s',
};
await agenda.schedule(expirationTime, 'ScheduleUserExpiration', jobData, jobOptions);
};
const AgendaWorking = async (email) => {
console.log("Agenda Working", email)
}
export { router as Agenda };
db.js:
import mongoose from 'mongoose';
mongoose.set('strictQuery', false);
export const MongoDBConnection = async () => {
try {
await mongoose.connect('mongodb://localhost:27017/')
console.log('Connected to database');
return mongoose.connection;
} catch (err) {
console.log('Error connecting to database: ' + err);
}
};
from agenda.
@xts-bit like @simllll said, we can't offer one on one support.
This is not a problem with the library. You should not be spamming us via email and issues.
You could ask in stack overflow or use this as a learning exercise or ask any one familiar with agenda for paid support.
That said you forgot an await
in
ScheduleUserExpiration(email)
.
Locking this thread.
from agenda.
Related Issues (20)
- lockLifetime not updatable when job is running HOT 1
- Some feature not work in version 6.X?
- TypeError: Cannot read properties of undefined (reading 'collection') HOT 4
- MongoDB connections are getting increased gradually
- Is npm agenda deprecated? Am I supposed to start using @hokify/agenda? HOT 3
- Agenda repeatEvery('10 seconds') fails processing remaining jobs
- Longer schedule time (more than one hour from current date or next hour) not triggering
- TimeoutOverflowWarning: 2428508862 does not fit into a 32-bit signed integer.
- Agenda sometimes dont restart the job execution
- Canceling jobs HOT 2
- It seems agenda doesn't connect with mongoose 7.x. Any plans to make it compatible with newer versions of mongoose? HOT 1
- Is there a way to update a job's original payload?
- Questions: REST API - safe to instantiate a new Agenda at each received request? Every can handle only a single job at a time? HOT 1
- With pm2 lots of connections are always open HOT 1
- "mongoose": "^8.0.4" and "agenda": "^5.0.0", getting error HOT 2
- RIP HOT 9
- Scheduled job runs multiple times HOT 2
- Unable to build typescript project with Agenda HOT 2
- Agenda 5.0.0 not compatible with Mongoose 8.2.1 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from agenda.