3
votes

I set up a connection with Weblogic IBM Webpsphere MQ through JMS with using a secure channel using SSL. My application on Weblogic received message from MQ. Sending answer to reply queue. The response header is present MQMD, it fills java. In parameter Persistence JMS send value "1". Other system need to received value "0" at Persistence. How to set this parameter to java? I guess that parameter is javax.jms.deliverymode. But how to set it i don't know.

Anyway thank you for help.

3

3 Answers

2
votes

The corresponding property on JMS is the delivery mode (Int parameter to be set) to set Persistent and non persistent messages.

You can refer this URL from IBM for details

2
votes

You should try like this:

public String sendMessage(ConnectionFactory connectionFactory,
                      Destination destination,
                      Destination jmsReplyTo,
                      CorrelationType correlationType,
                      CallOptions<String> callOptions,
                      String rqUid,
                      JMSAbstract transport) throws JMSException {
Connection connection = null;
Session session = null;
MessageProducer producer = null;

try {

    connection = connectionFactory.createConnection();
    session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

    producer = session.createProducer(destination);

    // Set JMS DeliverMode (1/2)
    producer.setDeliveryMode(1);

    // create message
    Message message = createTextMessage(session, jmsReplyTo, correlationType, callOptions, rqUid, transport);

    // send message
    producer.send(message);

    return correlationType.getCorrelationId(message);

    } finally {
        closeResource(connection, session, null, producer, rqUid);
    }
}

It`s just a java example. Also you can set persistence flag in Queue configuration in IBM WebSphere. I mean MQQueue have method setPersistence. If you using IBM java objects in your project, you can set persistence by calling that method:

MQQueue mqQueue = new MQQueue("QueueName");
mqQueue.setPersistence(1);
2
votes

I The answer of 0x5a4d is ok but better to use this like IBM best practices

//Persistentmode = 1 
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
//Persistentmode = 2 
producer.setDeliveryMode(DeliveryMode.PERSISTENT);