Question

I have a requirement where I want to trigger an event based on some action, and this functionality is to be implemented as a jar file.

Lets explain this with an example.

There is a web application WAR_FILE. There is a rest client named REST_CLIENT. There is a jar file that has api methods for client REST_CLIENT named as MY_JAR.

Now WAR_FILE will be using MY_JAR to post data to REST_CLIENT.

But WAR_FILE does not want to wait for its response.Its like post data and do not care for response. MY_JAR will take all inputs from WAR_FILE and store it in a queue as cache.I am using redis to maintain this queue as cache.

The main problem is MY_JAR has to check every time that if there is any request in that queue to act upon.

Sol 1: use quartz in MY_JAR to check after every n seconds,if there is any new request to act upon.

problem1 : The WAR_FILE may itself be using some quartz.

problem2 : If one thread is executing a list of tasks from queue and other thread comes and start executing the same request.

Sol 2: use cron job

problem : problem2 in sol 1

Sol 3 : RabitMQ / ActiveMQ (just heard of it)

problem : does not know how to use it and how it could be helping me.

Please help me.

Was it helpful?

Solution

I found various solutions to this problem.Actually this is JMS.(Previously I was not aware of this technology)

(1)Using Redis pub/sub event publication

http://redis.io/topics/pubsub

for simple java : http://www.basrikahveci.com/a-simple-jedis-publish-subscribe-example/

for Spring : http://java.dzone.com/articles/redis-pubsub-using-spring

(2)Using RabbitMQ

RabbitMQ installation : https://www.rabbitmq.com/install-debian.html

Java example : http://www.rabbitmq.com/tutorials/tutorial-one-java.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top