-1

I want know how to publish JMS message concurrently to different topic.


Example: 1 thread to publish JMS message to topic X, 1 thread to publish JMS message to topic Y periodically (let say every 5 seconds)

How can achieve that?

Currently using Wildfly 8.3 (Hornetq) as JMS provider.

syamsi
  • 19
  • 4

1 Answers1

0

One simple solution would be to use Java's ScheduledExecutorService, e.g.:

ScheduledExecutorService ses = new ScheduledThreadPoolExecutor(2);
ses.scheduleWithFixedDelay(() -> sendJmsMessage(topicX), 0, 5, TimeUnit.SECONDS);
ses.scheduleWithFixedDelay(() -> sendJmsMessage(topicY), 0, 5, TimeUnit.SECONDS);
Justin Bertram
  • 29,372
  • 4
  • 21
  • 43