Example usage for javax.jms Session DUPS_OK_ACKNOWLEDGE

List of usage examples for javax.jms Session DUPS_OK_ACKNOWLEDGE

Introduction

In this page you can find the example usage for javax.jms Session DUPS_OK_ACKNOWLEDGE.

Prototype

int DUPS_OK_ACKNOWLEDGE

To view the source code for javax.jms Session DUPS_OK_ACKNOWLEDGE.

Click Source Link

Document

This acknowledgment mode instructs the session to lazily acknowledge the delivery of messages.

Usage

From source file:com.alibaba.napoli.client.async.impl.DefaultAsyncReceiver.java

public void setAcknownedgeMode(int acknownedgeMode) {
    if (acknownedgeMode == Session.AUTO_ACKNOWLEDGE || acknownedgeMode == Session.CLIENT_ACKNOWLEDGE
            || acknownedgeMode == Session.DUPS_OK_ACKNOWLEDGE) {
        if (connectionParam != null) {
            connectionParam.setAcknowledgeMode(acknownedgeMode);
        }// w ww .j ava  2s. c  om
    }
}

From source file:com.amazon.sqs.javamessaging.SQSConnection.java

/**
 * Creates a <code>Session</code>
 * /*from   ww w.  ja v  a2 s .c o m*/
 * @param transacted
 *            Only false is supported.
 * @param acknowledgeMode
 *            Legal values are <code>Session.AUTO_ACKNOWLEDGE</code>,
 *            <code>Session.CLIENT_ACKNOWLEDGE</code>,
 *            <code>Session.DUPS_OK_ACKNOWLEDGE</code>, and
 *            <code>SQSSession.UNORDERED_ACKNOWLEDGE</code>
 * @return a new session.
 * @throws JMSException
 *             If the QueueConnection object fails to create a session due
 *             to some internal error or lack of support for the specific
 *             transaction and acknowledge mode.
 */
@Override
public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException {
    checkClosed();
    actionOnConnectionTaken = true;
    if (transacted || acknowledgeMode == Session.SESSION_TRANSACTED)
        throw new JMSException("SQSSession does not support transacted");

    SQSSession sqsSession;
    if (acknowledgeMode == Session.AUTO_ACKNOWLEDGE) {
        sqsSession = new SQSSession(this,
                AcknowledgeMode.ACK_AUTO.withOriginalAcknowledgeMode(acknowledgeMode));
    } else if (acknowledgeMode == Session.CLIENT_ACKNOWLEDGE
            || acknowledgeMode == Session.DUPS_OK_ACKNOWLEDGE) {
        sqsSession = new SQSSession(this,
                AcknowledgeMode.ACK_RANGE.withOriginalAcknowledgeMode(acknowledgeMode));
    } else if (acknowledgeMode == SQSSession.UNORDERED_ACKNOWLEDGE) {
        sqsSession = new SQSSession(this,
                AcknowledgeMode.ACK_UNORDERED.withOriginalAcknowledgeMode(acknowledgeMode));
    } else {
        LOG.error("Unrecognized acknowledgeMode. Cannot create Session.");
        throw new JMSException("Unrecognized acknowledgeMode. Cannot create Session.");
    }
    synchronized (stateLock) {
        checkClosing();
        sessions.add(sqsSession);

        /**
         * Any new sessions created on a started connection should be
         * started on creation
         */
        if (running) {
            sqsSession.start();
        }
    }

    return sqsSession;
}

From source file:com.datatorrent.lib.io.jms.ActiveMQBase.java

/**
 *  Get session acknowledge.//from   w  w  w .j  ava2  s.co  m
 *  Converts acknowledge string into JMS Session variable.
 */
public int getSessionAckMode(String ackMode) {
    if ("CLIENT_ACKNOWLEDGE".equals(ackMode)) {
        return Session.CLIENT_ACKNOWLEDGE;
    } else if ("AUTO_ACKNOWLEDGE".equals(ackMode)) {
        return Session.AUTO_ACKNOWLEDGE;
    } else if ("DUPS_OK_ACKNOWLEDGE".equals(ackMode)) {
        return Session.DUPS_OK_ACKNOWLEDGE;
    } else if ("SESSION_TRANSACTED".equals(ackMode)) {
        return Session.SESSION_TRANSACTED;
    } else {
        return Session.CLIENT_ACKNOWLEDGE; // default
    }
}

From source file:ConsumerTool.java

public void setAckMode(String ackMode) {
    if ("CLIENT_ACKNOWLEDGE".equals(ackMode)) {
        this.ackMode = Session.CLIENT_ACKNOWLEDGE;
    }//from w  w w  .  j  a  va 2 s  . c  om
    if ("AUTO_ACKNOWLEDGE".equals(ackMode)) {
        this.ackMode = Session.AUTO_ACKNOWLEDGE;
    }
    if ("DUPS_OK_ACKNOWLEDGE".equals(ackMode)) {
        this.ackMode = Session.DUPS_OK_ACKNOWLEDGE;
    }
    if ("SESSION_TRANSACTED".equals(ackMode)) {
        this.ackMode = Session.SESSION_TRANSACTED;
    }
}

From source file:edu.psu.citeseerx.messaging.MsgService.java

/**
 * Utility for translating String representations of acknowledgement
 * modes into their int encoding.  Default is CLIENT_ACKNOWLEDGE, so
 * any string that is not understood will result in a CLIENT_ACKNOWLEDGE
 * mode./*from ww  w .  j ava  2 s .co  m*/
 * @param modeStr
 * @return int representation of string acknowledgement
 */
protected int getAckMode(String modeStr) {
    int mode = Session.CLIENT_ACKNOWLEDGE;
    if (modeStr.equalsIgnoreCase("AUTO_ACKNOWLEDGE")) {
        mode = Session.AUTO_ACKNOWLEDGE;
    }
    if (modeStr.equalsIgnoreCase("DUPS_OK_ACKNOWLEDGE")) {
        mode = Session.DUPS_OK_ACKNOWLEDGE;
    }
    return mode;

}

From source file:com.chinamobile.bcbsp.comm.ConsumerTool.java

/** Set ackMode state. */
public void setAckMode(String ackMode) {
    if ("CLIENT_ACKNOWLEDGE".equals(ackMode)) {
        this.ackMode = Session.CLIENT_ACKNOWLEDGE;
    }/*from  w w w  .  j  a v a  2  s  . c  o  m*/
    if ("AUTO_ACKNOWLEDGE".equals(ackMode)) {
        this.ackMode = Session.AUTO_ACKNOWLEDGE;
    }
    if ("DUPS_OK_ACKNOWLEDGE".equals(ackMode)) {
        this.ackMode = Session.DUPS_OK_ACKNOWLEDGE;
    }
    if ("SESSION_TRANSACTED".equals(ackMode)) {
        this.ackMode = Session.SESSION_TRANSACTED;
    }
}

From source file:net.timewalker.ffmq4.common.session.AbstractMessageConsumer.java

/**
 * Constructor/*  ww  w  .  jav  a 2  s . co m*/
 */
public AbstractMessageConsumer(AbstractSession session, Destination destination, String messageSelector,
        boolean noLocal, IntegerID consumerId) throws JMSException {
    super(session, destination, consumerId);
    this.messageSelector = messageSelector;
    this.noLocal = noLocal;
    this.autoAcknowledge = (session.getAcknowledgeMode() == Session.AUTO_ACKNOWLEDGE
            || session.getAcknowledgeMode() == Session.DUPS_OK_ACKNOWLEDGE);

    if (destination == null)
        throw new FFMQException("Message consumer destination cannot be null", "INVALID_DESTINATION");
}

From source file:net.timewalker.ffmq4.remote.session.RemoteSession.java

/**
 * Add a delivered message ID//from ww w .j  av  a 2s  .co m
 * @param deliveredMessageID
 */
public final void notifyDeliveredMessage(String deliveredMessageID) {
    externalAccessLock.readLock().lock();
    try {
        if (closed)
            return;

        if (debugEnabled)
            log.debug(this + " Adding delivered message ID : " + deliveredMessageID);

        this.deliveredMessageIDs.add(deliveredMessageID);
        if (!transacted && acknowledgeMode != Session.DUPS_OK_ACKNOWLEDGE)
            synchronousAckRequired = true;
    } finally {
        externalAccessLock.readLock().unlock();
    }
}

From source file:nl.nn.adapterframework.extensions.ifsa.jms.IfsaFacade.java

public void setAcknowledgeMode(String acknowledgeMode) {

    if (acknowledgeMode.equalsIgnoreCase("auto") || acknowledgeMode.equalsIgnoreCase("AUTO_ACKNOWLEDGE")) {
        ackMode = Session.AUTO_ACKNOWLEDGE;
    } else if (acknowledgeMode.equalsIgnoreCase("dups")
            || acknowledgeMode.equalsIgnoreCase("DUPS_OK_ACKNOWLEDGE")) {
        ackMode = Session.DUPS_OK_ACKNOWLEDGE;
    } else if (acknowledgeMode.equalsIgnoreCase("client")
            || acknowledgeMode.equalsIgnoreCase("CLIENT_ACKNOWLEDGE")) {
        ackMode = Session.CLIENT_ACKNOWLEDGE;
    } else {/*from  w  w w .  jav  a2s .  co m*/
        // ignore all ack modes, to test no acking
        log.warn("[" + name + "] invalid acknowledgemode:[" + acknowledgeMode + "] setting no acknowledge");
        ackMode = -1;
    }

}

From source file:nl.nn.adapterframework.jms.JMSFacade.java

/**
 * Convencience function to convert the numeric value of an (@link #setAckMode(int) acknowledgeMode} to a human-readable string.
 *//*from www.j a  v  a 2 s .co  m*/
public static String getAcknowledgeModeAsString(int ackMode) {
    String ackString;
    if (Session.AUTO_ACKNOWLEDGE == ackMode) {
        ackString = "Auto";
    } else if (Session.CLIENT_ACKNOWLEDGE == ackMode) {
        ackString = "Client";
    } else if (Session.DUPS_OK_ACKNOWLEDGE == ackMode) {
        ackString = "Dups";
    } else {
        ackString = "none";
    }

    return ackString;
}