문제

I have some non-critical clean up operation that I want to perform inside my web-app. I'm hoping to hand it off to an asynchronous process, but I don't have any JMS provider available to me ( and I'm not likely to get one approved in the timescales ).

I like the idea of the Spring MDP, but all the examples that I have seen explicitly tie it in to a JMS implementation of some sort. Is it possible to tie it to a Queue implementation based on the java.util.Queue interface? I'm thinking that I could just push messages on to a queue and use a Spring MDP to process them.

Am I barking up the wrong tree?

도움이 되었습니까?

해결책

Maybe you could use asynchronous tasks to do the clean up. You could have a CleanUpcomponent that offers @Asnyc annotated methods. The TaskExecutors implicitly use a Queue for pending tasks (like plain Java's ExecutorService). There would also be the option to collect submitted clean up requests in a Queue and let them be processed by a scheduled task.

Another alternative may be Guava's EventBus. Setting one up wth spring should be straight forward and there is an AsynchronousEventBus available.

다른 팁

You can use RabbitMQ or ActiveMQ with Spring.

You can embed an ApacheMQ BrokerService in your application

<bean id="broker" class="org.apache.activemq.broker.BrokerService" init-method="start">
    <property name="transportConnectorURIs">
        <list>
            <value>tcp://localhost:61616</value>
        </list>
    </property>
</bean>

Now you can use it just as a regular ApacheMQ.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top