1
votes

I have a situation where I need to read a(on going) messages from a topic and put them on another Queue . I have doubts do I need jms Queue or I can be satisfied with an in memory java Queue . I will do the reading from the Queue by other thread(s) in same jvm and will do client acknowledge of the message to the topic after reading the message from the (in memory) queue and process it as necessary (send it to remote IBM MQ) .So if my client crash the messages that were exist in the in memory queue will be lost but will still exist on topic and will be redeliver to me . Am I right ?

2

2 Answers

1
votes

Some of this depends on how you have set up the queue/topic and the connection string you are using to read from IBM's MQ but if you are using the defaults you WILL lose messages if you're reading it to an in-memory queue.

I'd use ActiveMQ, either in the same JVM as a library so you have it taking care of receipt, delivery and persistence.

Also if you are listening to a topic you're not going to be sent missed messages after a crash even if you reconnect afterwards unless you've

  1. configured your client as a durable subscriber
  2. reconnect in the time (before the expireMessagesPeriod is reached)

The ActiveMQ library is not large and worth using if ensure delivery of every message is important, especially in an asynchronous environment.

0
votes

Main difference is that in-memory loses data when the application goes down; JMS queue loses data when the server goes down IF the topic/queue is not persistent. The former is much more likely than the latter, so I'd also say go with JMS.