1

I have a requirement as :

Messages in a queue, say A, needs to be consumed by two different applications. I am trying to implement a MDB to listen to that queue and publish that msg to another topic from where applications can consume.

  1. Is it possible?
  2. Is it available readily as some config in jboss..am I reinventing the wheel?
  3. Any help on this to achieve..

Code:

@MessageDriven(activationConfig = {
    @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "queue/test.queue"),
    @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue") })
public class MyListener implements MessageListener {

private JmsTemplate jmsTemplate;

public MyListener(JmsTemplate jmsTemplate) {
    this.jmsTemplate = jmsTemplate;
}

public void onMessage(Message message) {
    System.out.println("Message received");
    // TextMessage textMessage = (TextMessage) message;
    publishMessage(message);
    System.out.println("Message re-published");
}

Thanks in advance.

Anitha.R
  • 344
  • 2
  • 15
  • 1. Yes, possible. I have implemented it. But facing an issue: Msg received via MDB and it is not publishing to topic. But no errors. Any help would be much appreciated. Code updated. – Anitha.R Aug 28 '19 at 10:40
  • How are you confirming that no message was published to the topic? Is there a subscriber on the topic when the message is sent? – Justin Bertram Aug 29 '19 at 13:17
  • what's your source code for publishMessage ? And what is your JMS provider ? Many JMS implementations have a configuration option to 'bridge' queues and topics to other topics. For example TIBCO, Solace, IBM MQ, ... – Axel Podehl Sep 03 '19 at 07:51

1 Answers1

0

If the same message needs to be consumed by 2 different applications then both applications should subscribe to the same topic and the message should be sent to that topic. That way both applications will get the message and you won't need to waste your time resending the message yourself.

Justin Bertram
  • 29,372
  • 4
  • 21
  • 43