Comments (4)
Ok, I found the issue; First the TestAction class must be in separate file or declared static, as at ReflectionUtils @ findConstructor()
the candidate.getParameterTypes()
returns a +1 length to the arguments.
I think the issue can be closed.
from jesque.
Yup, Java implicitly adds a parameter for the surrounding type to the constructors of non-static inner classes! This article explains it well.
from jesque.
What if you want to create a shared BlockingQueue reference with in run() method where queue.offer() should be performed with string value that the class is constructed with?
from jesque.
public abstract class AbstractDelayedMessageSource<T> extends IntegrationObjectSupport implements MessageSource, DisposableBean {
private final Worker jesqueWorker;
private final SynchronousQueue<T> queue = new SynchronousQueue<>();
private final ObjectMapper objectMapper;
protected AbstractDelayedMessageSource(Config config, ObjectMapper mapper) {
this.jesqueWorker = new WorkerImpl(config, Arrays.asList("foo"),
new MapBasedJobFactory(map(entry("MessageDispatcher", MessageDispatcher.class))));
this.objectMapper = mapper;
}
@Override
protected void onInit() throws Exception {
super.onInit();
Thread workerThread = new Thread(jesqueWorker);
workerThread.start();
}
public void destroy() throws Exception {
jesqueWorker.end(true);
}
@Override
public Message<T> receive() {
T payload = null;
try {
payload = queue.take();
} catch (InterruptedException e) {
e.printStackTrace();
}
return this.getMessageBuilderFactory().withPayload(payload).build();
}
private T deserializeJsonString(String jsonString) {
try {
Class<T> type =(Class<T>) GenericTypeResolver.resolveTypeArgument(getClass(), AbstractDelayedMessageSource.class);
return objectMapper.readerFor(type).readValue(jsonString);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public class MessageDispatcher implements Runnable {
private final String jsonString;
public MessageDispatcher(String jsonString) {
this.jsonString = jsonString;
}
@Override
public void run() {
T object = deserializeJsonString(jsonString);
queue.offer(object);
}
}
}
Can this be done?
from jesque.
Related Issues (20)
- java.net.UnknownHostException thrown when `ip-#-#-#-#` pattern has no reverse lookup HOT 2
- No worker running when facing `Terminating in response to exception`
- jackson 2.9 incompatibility
- jackson databind 2.9 includes a breaking change HOT 5
- successful job is re-enqueued during shutdown HOT 1
- Worker queue in redis not reset when restarting?
- client.enqueue() error `java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.DeserializationConfig.with` HOT 1
- Throw JedisDataException when enqueue a job HOT 1
- Requesting new public release. HOT 1
- Version 2.1.3 breaks API compatibility from 2.1.2 HOT 1
- why does jesque not use namespace as prefix for recurring jobs? HOT 2
- RESET_TO_HIGHEST_PRIORITY Strategy not work for recurring job
- Implement a way to set FailQueueStrategy on WorkerImplFactory
- Jedis 3.X compatibility HOT 9
- NoSuchConstructorException HOT 1
- 通过jesque的延时任务实现支持cron表达式的调度任务 HOT 1
- Redis Cluster Issue
- ETA on current master release HOT 1
- Job moved from inflight queue to comma-joined queue on worker shutdown in RESET_TO_HIGHEST_PRIORITY strategy.
- Worker existing on uncaught exception after 10 minutes of no connection
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 jesque.