java websphere MQ

前端 未结 3 746
逝去的感伤
逝去的感伤 2021-02-06 13:15

My aim is to put n number of messages in a for loop to a WebSphere MQ queue using WebSphere MQ java programming.

My java program will run as a standalone program.

3条回答
  •  生来不讨喜
    2021-02-06 13:33

    you only need to create a session with transaction enabled.

    Session session;
    // ...
    boolean transacted = true;
    session = connection.createSession(transacted, Session.AUTO_ACKNOWLEDGE);
    try {
        // ...do things...
        session.commit();
    } catch (Exception e) {
        session.rollback();
    }
    // ...
    

    WARN-NOTE: Sessions are not thread-safe ;-)

    • Doc Websphere MQ/JMS

提交回复
热议问题