0

I am doing seedstack ibm mq configuration through yaml file

But i am not able to find any paramter related message commit

Because ibm mq needs to commit it.

As it is message is pending

@JmsMessageListener(connection = "connection1", destinationName = "${queue.myqueue}", destinationType = DestinationType.QUEUE)
public class MyMessageListener implements javax.jms.MessageListener {
    private static final Logger LOGGER = LogManager.getLogger();

    @Override
    @Transactional
    public void onMessage(Message message) {
        try {
            if (message instanceof TextMessage) {
                try {
                    TextMessage textMessage = (TextMessage) message;        
                    final String messageInXML = textMessage.getText();
user432843
  • 83
  • 1
  • 9

1 Answers1

1

I am not sure how much the yaml configuration is doing for you, but if the messages are pending then the connection is transactional and a commit or rollback needs to happen.

You don't share any yaml or java code, but what ever you have isn't performing neither a commit nor a rollback by default, which is odd. I would expect a rollback should an uncaught exception be thrown, with a default action of commit on connection close.

Looking at Seedstack documentation it seems that a normal pattern is for a session to be injected, and neither connection nor session ever closed. Which in turn indicates that you may need to perform a commit in your code.

If you have code that looks like:

    @Inject
    private Session session;

    @Override
    @Transactional
    @JmsConnection("connection1")
    public void sendMessage() {
        Destination queue = session.createQueue("queue1");
        MessageProducer producer = session.createProducer(queue);
        TextMessage message = session.createTextMessage();
        message.setText(stringMessage);
        producer.send(message);
    }

My initial thoughts are that the annotation @Transactional should run a commit by default on exit of the method, but if it isn't then the commit needs to be on the session:

    @Inject
    private Session session;

    @Override
    @Transactional
    @JmsConnection("connection1")
    public void sendMessage() {
        Destination queue = session.createQueue("queue1");
        MessageProducer producer = session.createProducer(queue);
        TextMessage message = session.createTextMessage();
        message.setText(stringMessage);
        producer.send(message);
        session.commit();
    }
chughts
  • 4,210
  • 2
  • 14
  • 27