0

I'm using a JMS topic (with non-durable subscribers) to report the progress of server-side processing to the clients. The application server itself is WildFly 8.2, the client(s) is a JavaFX application.

At every specific milestone (let's say: every tenths of the work done) of the server-side processing a JMS message is sent to the topic, to which clients are subscribed. The idea is, when a JMS message is received, it can be used to drive a "progress bar" forward.

My problem is, that some kind of buffering (?) happens somewhere in the system, presumably on the server-side. The processing itself is a longer one, 10 to 30 seconds, and the messages are sent to queue -according to the logs- roughly evenly, one in 1-3 sec.

However, on the client side the whole bunch of messages are received within a very short time frame, typically under 0.5 sec, usually at the end of the whole processing.

How could I use JMS messaging to represent real-time progress?

austurist
  • 124
  • 8
  • 1
    Could the messages be sent in the same transactional context as the business process ? If so, they won't be dispatched to subscribers until the transaction commits. – Nicholas Apr 10 '15 at 12:53
  • Both my processing bean and the messaging bean (which is responsible for sending the progress messages) have default transactional annotations (they aren't annotated). Should I use REQUIRES_NEW for the messaging bean? – austurist Apr 10 '15 at 19:48
  • Yeah, sounds like it. If they're both running the default, REQUIRES, then assuming the processing bean is initiated first, the messaging bean is probably enrolled in the same transaction, so the messages will not by made available to the consumer until the transaction commits. By annotating the messaging bean with REQUIRES_NEW, you'll flush the messages out right away. – Nicholas Apr 10 '15 at 21:00
  • Try setting jms to be non transactional and auto ack – Will Tatam Apr 10 '15 at 22:53
  • If only one client needs to see the progress, then use a queue not a topic – Will Tatam Apr 10 '15 at 22:55
  • Nicholas, you were right. Setting the transaction attribute to REQUIRES_NEW was the solution. – austurist Apr 15 '15 at 14:06

1 Answers1

0

As I've written in a comment, Nicholas was right. The transaction attribute had to be set to TransactionAttributeType.REQUIRES_NEW. This way the messaging bean can send the JMS message instantly, without waiting for the processing bean.

austurist
  • 124
  • 8