Java Code Examples for javax.jms.Session#DUPS_OK_ACKNOWLEDGE

The following examples show how to use javax.jms.Session#DUPS_OK_ACKNOWLEDGE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StandardJmsActivationSpecFactory.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Apply the specified acknowledge mode to the ActivationSpec object.
 * <p>This implementation applies the standard JCA 1.5 acknowledge modes
 * "Auto-acknowledge" and "Dups-ok-acknowledge". It throws an exception in
 * case of {@code CLIENT_ACKNOWLEDGE} or {@code SESSION_TRANSACTED}
 * having been requested.
 * @param bw the BeanWrapper wrapping the ActivationSpec object
 * @param ackMode the configured acknowledge mode
 * (according to the constants in {@link javax.jms.Session}
 * @see javax.jms.Session#AUTO_ACKNOWLEDGE
 * @see javax.jms.Session#DUPS_OK_ACKNOWLEDGE
 * @see javax.jms.Session#CLIENT_ACKNOWLEDGE
 * @see javax.jms.Session#SESSION_TRANSACTED
 */
protected void applyAcknowledgeMode(BeanWrapper bw, int ackMode) {
	if (ackMode == Session.SESSION_TRANSACTED) {
		throw new IllegalArgumentException("No support for SESSION_TRANSACTED: Only \"Auto-acknowledge\" " +
				"and \"Dups-ok-acknowledge\" supported in standard JCA 1.5");
	}
	else if (ackMode == Session.CLIENT_ACKNOWLEDGE) {
		throw new IllegalArgumentException("No support for CLIENT_ACKNOWLEDGE: Only \"Auto-acknowledge\" " +
				"and \"Dups-ok-acknowledge\" supported in standard JCA 1.5");
	}
	else if (bw.isWritableProperty("acknowledgeMode")) {
		bw.setPropertyValue("acknowledgeMode",
				ackMode == Session.DUPS_OK_ACKNOWLEDGE ? "Dups-ok-acknowledge" : "Auto-acknowledge");
	}
	else if (ackMode == Session.DUPS_OK_ACKNOWLEDGE) {
		// Standard JCA 1.5 "acknowledgeMode" apparently not supported (e.g. WebSphere MQ 6.0.2.1)
		throw new IllegalArgumentException("Dups-ok-acknowledge not supported by underlying provider");
	}
}
 
Example 2
Source File: AbstractListenerContainerParser.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Nullable
protected Integer parseAcknowledgeMode(Element ele, ParserContext parserContext) {
	String acknowledge = ele.getAttribute(ACKNOWLEDGE_ATTRIBUTE);
	if (StringUtils.hasText(acknowledge)) {
		int acknowledgeMode = Session.AUTO_ACKNOWLEDGE;
		if (ACKNOWLEDGE_TRANSACTED.equals(acknowledge)) {
			acknowledgeMode = Session.SESSION_TRANSACTED;
		}
		else if (ACKNOWLEDGE_DUPS_OK.equals(acknowledge)) {
			acknowledgeMode = Session.DUPS_OK_ACKNOWLEDGE;
		}
		else if (ACKNOWLEDGE_CLIENT.equals(acknowledge)) {
			acknowledgeMode = Session.CLIENT_ACKNOWLEDGE;
		}
		else if (!ACKNOWLEDGE_AUTO.equals(acknowledge)) {
			parserContext.getReaderContext().error("Invalid listener container 'acknowledge' setting [" +
					acknowledge + "]: only \"auto\", \"client\", \"dups-ok\" and \"transacted\" supported.", ele);
		}
		return acknowledgeMode;
	}
	else {
		return null;
	}
}
 
Example 3
Source File: StandardJmsActivationSpecFactory.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Apply the specified acknowledge mode to the ActivationSpec object.
 * <p>This implementation applies the standard JCA 1.5 acknowledge modes
 * "Auto-acknowledge" and "Dups-ok-acknowledge". It throws an exception in
 * case of {@code CLIENT_ACKNOWLEDGE} or {@code SESSION_TRANSACTED}
 * having been requested.
 * @param bw the BeanWrapper wrapping the ActivationSpec object
 * @param ackMode the configured acknowledge mode
 * (according to the constants in {@link javax.jms.Session}
 * @see javax.jms.Session#AUTO_ACKNOWLEDGE
 * @see javax.jms.Session#DUPS_OK_ACKNOWLEDGE
 * @see javax.jms.Session#CLIENT_ACKNOWLEDGE
 * @see javax.jms.Session#SESSION_TRANSACTED
 */
protected void applyAcknowledgeMode(BeanWrapper bw, int ackMode) {
	if (ackMode == Session.SESSION_TRANSACTED) {
		throw new IllegalArgumentException("No support for SESSION_TRANSACTED: Only \"Auto-acknowledge\" " +
				"and \"Dups-ok-acknowledge\" supported in standard JCA 1.5");
	}
	else if (ackMode == Session.CLIENT_ACKNOWLEDGE) {
		throw new IllegalArgumentException("No support for CLIENT_ACKNOWLEDGE: Only \"Auto-acknowledge\" " +
				"and \"Dups-ok-acknowledge\" supported in standard JCA 1.5");
	}
	else if (bw.isWritableProperty("acknowledgeMode")) {
		bw.setPropertyValue("acknowledgeMode",
				ackMode == Session.DUPS_OK_ACKNOWLEDGE ? "Dups-ok-acknowledge" : "Auto-acknowledge");
	}
	else if (ackMode == Session.DUPS_OK_ACKNOWLEDGE) {
		// Standard JCA 1.5 "acknowledgeMode" apparently not supported (e.g. WebSphere MQ 6.0.2.1)
		throw new IllegalArgumentException("Dups-ok-acknowledge not supported by underlying provider");
	}
}
 
Example 4
Source File: AbstractListenerContainerParser.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Nullable
protected Integer parseAcknowledgeMode(Element ele, ParserContext parserContext) {
	String acknowledge = ele.getAttribute(ACKNOWLEDGE_ATTRIBUTE);
	if (StringUtils.hasText(acknowledge)) {
		int acknowledgeMode = Session.AUTO_ACKNOWLEDGE;
		if (ACKNOWLEDGE_TRANSACTED.equals(acknowledge)) {
			acknowledgeMode = Session.SESSION_TRANSACTED;
		}
		else if (ACKNOWLEDGE_DUPS_OK.equals(acknowledge)) {
			acknowledgeMode = Session.DUPS_OK_ACKNOWLEDGE;
		}
		else if (ACKNOWLEDGE_CLIENT.equals(acknowledge)) {
			acknowledgeMode = Session.CLIENT_ACKNOWLEDGE;
		}
		else if (!ACKNOWLEDGE_AUTO.equals(acknowledge)) {
			parserContext.getReaderContext().error("Invalid listener container 'acknowledge' setting [" +
					acknowledge + "]: only \"auto\", \"client\", \"dups-ok\" and \"transacted\" supported.", ele);
		}
		return acknowledgeMode;
	}
	else {
		return null;
	}
}
 
Example 5
Source File: IfsaFacade.java    From iaf with Apache License 2.0 6 votes vote down vote up
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 {
					// ignore all ack modes, to test no acking
					log.warn("["+name+"] invalid acknowledgemode:[" + acknowledgeMode + "] setting no acknowledge");
					ackMode = -1;
				}

	}
 
Example 6
Source File: JMSFacade.java    From iaf with Apache License 2.0 6 votes vote down vote up
/**
 * Convencience function to convert the numeric value of an (@link #setAckMode(int) acknowledgeMode} to a human-readable string.
 */
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;
}
 
Example 7
Source File: AbstractListenerContainerParser.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
protected Integer parseAcknowledgeMode(Element ele, ParserContext parserContext) {
	String acknowledge = ele.getAttribute(ACKNOWLEDGE_ATTRIBUTE);
	if (StringUtils.hasText(acknowledge)) {
		int acknowledgeMode = Session.AUTO_ACKNOWLEDGE;
		if (ACKNOWLEDGE_TRANSACTED.equals(acknowledge)) {
			acknowledgeMode = Session.SESSION_TRANSACTED;
		}
		else if (ACKNOWLEDGE_DUPS_OK.equals(acknowledge)) {
			acknowledgeMode = Session.DUPS_OK_ACKNOWLEDGE;
		}
		else if (ACKNOWLEDGE_CLIENT.equals(acknowledge)) {
			acknowledgeMode = Session.CLIENT_ACKNOWLEDGE;
		}
		else if (!ACKNOWLEDGE_AUTO.equals(acknowledge)) {
			parserContext.getReaderContext().error("Invalid listener container 'acknowledge' setting [" +
					acknowledge + "]: only \"auto\", \"client\", \"dups-ok\" and \"transacted\" supported.", ele);
		}
		return acknowledgeMode;
	}
	else {
		return null;
	}
}
 
Example 8
Source File: JMSProxy.java    From flex-blazeds with Apache License 2.0 6 votes vote down vote up
/**
 * Initialize with settings from the JMS adapter.
 *
 * @param settings JMS settings to use for initialization.
 */
public void initialize(JMSSettings settings)
{
    String ackString = settings.getAcknowledgeMode();
    if (ackString.equals(JMSConfigConstants.AUTO_ACKNOWLEDGE))
        acknowledgeMode = Session.AUTO_ACKNOWLEDGE;
    else if (ackString.equals(JMSConfigConstants.CLIENT_ACKNOWLEDGE))
        acknowledgeMode = Session.CLIENT_ACKNOWLEDGE;
    else if (ackString.equals(JMSConfigConstants.DUPS_OK_ACKNOWLEDGE))
        acknowledgeMode = Session.DUPS_OK_ACKNOWLEDGE;

    connectionFactoryName = settings.getConnectionFactory();
    String username = settings.getConnectionUsername();
    String password = settings.getConnectionPassword();
    if (username != null || password != null)
    {
        connectionCredentials = new ConnectionCredentials(username, password);
    }
    destinationJndiName = settings.getDestinationJNDIName();
    initialContextEnvironment = settings.getInitialContextEnvironment();
}
 
Example 9
Source File: JMSFacade.java    From iaf with Apache License 2.0 6 votes vote down vote up
/**
 * String-version of {@link #setAckMode(int)}
 */
@IbisDoc({"", "auto_acknowledge"})
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 {
				// ignore all ack modes, to test no acking
				log.warn("["+name+"] invalid acknowledgemode:[" + acknowledgeMode + "] setting no acknowledge");
				ackMode = -1;
			}

}
 
Example 10
Source File: ActiveMQConnectionForContextImpl.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
public JMSContext createContext(int sessionMode) {
   switch (sessionMode) {
      case Session.AUTO_ACKNOWLEDGE:
      case Session.CLIENT_ACKNOWLEDGE:
      case Session.DUPS_OK_ACKNOWLEDGE:
      case Session.SESSION_TRANSACTED:
      case ActiveMQJMSConstants.INDIVIDUAL_ACKNOWLEDGE:
      case ActiveMQJMSConstants.PRE_ACKNOWLEDGE:
         break;
      default:
         throw new JMSRuntimeException("Invalid ackmode: " + sessionMode);
   }
   refCounter.increment();

   return new ActiveMQJMSContext(this, sessionMode, threadAwareContext);
}
 
Example 11
Source File: JMSTaskManagerFactory.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
/**
 * Get the session acknowledge type
 *
 * @param svcMap JNDI context properties and other general property map
 * @param cfMap  properties defined on the JMS CF
 * @return value for the specific acknowledge type
 */
private static int getSessionAck(Map<String, String> svcMap, Map<String, String> cfMap) {

    String key = JMSConstants.PARAM_SESSION_ACK;
    String val = svcMap.get(key);
    if (val == null) {
        val = cfMap.get(key);
    }

    if (val == null || "AUTO_ACKNOWLEDGE".equalsIgnoreCase(val)) {
        return Session.AUTO_ACKNOWLEDGE;
    } else if ("CLIENT_ACKNOWLEDGE".equalsIgnoreCase(val)) {
        return Session.CLIENT_ACKNOWLEDGE;
    } else if ("DUPS_OK_ACKNOWLEDGE".equals(val)) {
        return Session.DUPS_OK_ACKNOWLEDGE;
    } else if ("SESSION_TRANSACTED".equals(val)) {
        return 0; //Session.SESSION_TRANSACTED;
    } else {
        try {
            return Integer.parseInt(val);
        } catch (NumberFormatException ignore) {
            throw new ThrottlingRunTimeException("Invalid session acknowledgement mode : " + val);
            //TODO remove this
            //return 0;
        }
    }
}
 
Example 12
Source File: SQSConnection.java    From amazon-sqs-java-messaging-lib with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a <code>Session</code>
 * 
 * @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;
}
 
Example 13
Source File: ActiveMQActivationValidationUtils.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
public static int validateAcknowledgeMode(final String value) {
   if ("DUPS_OK_ACKNOWLEDGE".equalsIgnoreCase(value) || "Dups-ok-acknowledge".equalsIgnoreCase(value)) {
      return Session.DUPS_OK_ACKNOWLEDGE;
   } else if ("AUTO_ACKNOWLEDGE".equalsIgnoreCase(value) || "Auto-acknowledge".equalsIgnoreCase(value)) {
      return Session.AUTO_ACKNOWLEDGE;
   } else {
      throw new IllegalArgumentException(value);
   }
}
 
Example 14
Source File: ActiveMQActivationSpec.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
/**
 * Get the acknowledge mode
 *
 * @return The value
 */
public String getAcknowledgeMode() {
   if (logger.isTraceEnabled()) {
      logger.trace("getAcknowledgeMode()");
   }

   if (Session.DUPS_OK_ACKNOWLEDGE == acknowledgeMode) {
      return "Dups-ok-acknowledge";
   } else {
      return "Auto-acknowledge";
   }
}
 
Example 15
Source File: ActiveMQRASessionFactoryImpl.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
public JMSContext createContext(int sessionMode) {
   boolean inJtaTx = inJtaTransaction();
   int sessionModeToUse;
   switch (sessionMode) {
      case Session.AUTO_ACKNOWLEDGE:
      case Session.DUPS_OK_ACKNOWLEDGE:
      case ActiveMQJMSConstants.INDIVIDUAL_ACKNOWLEDGE:
      case ActiveMQJMSConstants.PRE_ACKNOWLEDGE:
         sessionModeToUse = sessionMode;
         break;
      //these are prohibited in JEE unless not in a JTA tx where they should be ignored and auto_ack used
      case Session.CLIENT_ACKNOWLEDGE:
         if (!inJtaTx) {
            throw ActiveMQRABundle.BUNDLE.invalidSessionTransactedModeRuntime();
         }
         sessionModeToUse = Session.AUTO_ACKNOWLEDGE;
         break;
      case Session.SESSION_TRANSACTED:
         if (!inJtaTx) {
            throw ActiveMQRABundle.BUNDLE.invalidClientAcknowledgeModeRuntime();
         }
         sessionModeToUse = Session.AUTO_ACKNOWLEDGE;
         break;
      default:
         throw ActiveMQRABundle.BUNDLE.invalidAcknowledgeMode(sessionMode);
   }
   incrementRefCounter();

   return new ActiveMQRAJMSContext(this, sessionModeToUse, threadAwareContext);
}
 
Example 16
Source File: JMSBase.java    From attic-apex-malhar with Apache License 2.0 5 votes vote down vote up
/**
 *  Get session acknowledge.
 *  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
  }
}
 
Example 17
Source File: AbstractJMSProvider.java    From perf-harness with MIT License 5 votes vote down vote up
/**
 * Register our presence and look up any required parameters for this class.
 * 
 * The current implementation does not fully differentiate between the
 * different modes it may be used in and will therefore allow many
 * combinations of arguments which are nonsensical (most of them are simply
 * ignored in the current configuration).
 * 
 * @see Config#registerSelf(Class).
 */
public static void registerConfig() {
	// static validation of parameters

	Config.registerSelf( AbstractJMSProvider.class );

	if ( ! Config.isInvalid() ) {
		int timeOut = Config.parms.getInt("to");
		if ( timeOut<0 ) {
			Config.logger.log(Level.WARNING,"Time out (to={0}) must be at least 0", timeOut);
		}
			
		int am = Config.parms.getInt("am");
		if ((am != Session.AUTO_ACKNOWLEDGE) && (am != Session.DUPS_OK_ACKNOWLEDGE) && (am != Session.CLIENT_ACKNOWLEDGE)) {
			Config.logger.log(Level.WARNING, "Acknowledgement (am={0}) must be one of \n{1} for Auto\n{2} for DupsOK\n{3} for Client\n", new Object[] {am, Session.AUTO_ACKNOWLEDGE, Session.DUPS_OK_ACKNOWLEDGE, Session.CLIENT_ACKNOWLEDGE} );
		}
		
		if ( Config.parms.getString("pw").length()!=0 && Config.parms.getString("us").length()==0 ) {
			Config.logger.warning("Cannot specify -pw without -us");
		}

		durable = Config.parms.getBoolean( "du" );
		
		int commit = Config.parms.getInt("cc");
		if ( commit<1 ) {
			Config.logger.log( Level.WARNING, "Commit count (cc={0}) must be greater than 0", commit);
		}
		
		/*
		 * TODO: Java 8 supports target type inference, so when moving to Java8 can
		 * change following line to:
		 * Config.registerAnother( Config.parms.<JMSProvider>getClazz("pc") );
		 */
		Config.registerAnother( Config.parms.getClazz("pc") );
	}
	
}
 
Example 18
Source File: ActiveMQResourceAdapter.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
public ClientSession createSession(final ClientSessionFactory parameterFactory,
                                   final int ackMode,
                                   final String user,
                                   final String pass,
                                   final Boolean preAck,
                                   final Integer dupsOkBatchSize,
                                   final Integer transactionBatchSize,
                                   final boolean deliveryTransacted,
                                   final boolean useLocalTx,
                                   final Integer txTimeout) throws Exception {

   ClientSession result;

   // if we are CMP or BMP using local tx we ignore the ack mode as we are transactional
   if (deliveryTransacted || useLocalTx) {
      // JBPAPP-8845
      // If transacted we need to send the ack flush as soon as possible
      // as if any transaction times out, we need the ack on the server already
      if (useLocalTx) {
         result = parameterFactory.createSession(user, pass, false, false, false, false, 0);
      } else {
         result = parameterFactory.createSession(user, pass, true, false, false, false, 0);
      }
   } else {
      if (preAck != null && preAck) {
         result = parameterFactory.createSession(user, pass, false, true, true, true, -1);
      } else {
         // only auto ack and dups ok are supported
         switch (ackMode) {
            case Session.AUTO_ACKNOWLEDGE:
               result = parameterFactory.createSession(user, pass, false, true, true, false, 0);
               break;
            case Session.DUPS_OK_ACKNOWLEDGE:
               int actDupsOkBatchSize = dupsOkBatchSize != null ? dupsOkBatchSize : ActiveMQClient.DEFAULT_ACK_BATCH_SIZE;
               result = parameterFactory.createSession(user, pass, false, true, true, false, actDupsOkBatchSize);
               break;
            default:
               throw new IllegalArgumentException("Invalid ackmode: " + ackMode);
         }
      }
   }

   ActiveMQRALogger.LOGGER.debug("Using queue connection " + result);

   return result;

}
 
Example 19
Source File: MessageConsumerTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Override
public void onMessage(final Message m) {
   TextMessage tm = (TextMessage) m;
   count++;

   try {
      if (count == 1) {
         if (!"a".equals(tm.getText())) {
            failed("Should be a but was " + tm.getText());
            latch.countDown();
         }
         throw new RuntimeException("Aardvark");
      } else if (count == 2) {
         if (sess.getAcknowledgeMode() == Session.AUTO_ACKNOWLEDGE || sess.getAcknowledgeMode() == Session.DUPS_OK_ACKNOWLEDGE) {
            // Message should be immediately redelivered
            if (!"a".equals(tm.getText())) {
               failed("Should be a but was " + tm.getText());
               latch.countDown();
            }
            if (!tm.getJMSRedelivered()) {
               failed("Message was supposed to be a redelivery");
               latch.countDown();
            }
         } else {
            // Transacted or CLIENT_ACKNOWLEDGE - next message should be delivered
            if (!"b".equals(tm.getText())) {
               failed("Should be b but was " + tm.getText());
               latch.countDown();
            }
         }
      } else if (count == 3) {
         if (sess.getAcknowledgeMode() == Session.AUTO_ACKNOWLEDGE || sess.getAcknowledgeMode() == Session.DUPS_OK_ACKNOWLEDGE) {
            if (!"b".equals(tm.getText())) {
               failed("Should be b but was " + tm.getText());
               latch.countDown();
            }
         } else {
            if (!"c".equals(tm.getText())) {
               failed("Should be c but was " + tm.getText());
               latch.countDown();
            }
            latch.countDown();
         }
      } else if (count == 4) {
         if (sess.getAcknowledgeMode() == Session.AUTO_ACKNOWLEDGE || sess.getAcknowledgeMode() == Session.DUPS_OK_ACKNOWLEDGE) {
            if (!"c".equals(tm.getText())) {
               failed("Should be c but was " + tm.getText());
               latch.countDown();
            }
            latch.countDown();
         } else {
            // Shouldn't get a 4th message
            failed("Shouldn't get a 4th message");
            latch.countDown();
         }
      }
   } catch (JMSException e) {
      log.error(e.getMessage(), e);
      failed("Got a JMSException " + e.toString());
      latch.countDown();
   }
}
 
Example 20
Source File: JMSProxy.java    From flex-blazeds with Apache License 2.0 3 votes vote down vote up
/**
 * Sets the acknowledge mode used by the <code>JMSProxy</code>. Valid values
 * are javax.jms.Session.AUTO_ACKNOWLEDGE, javax.jms.Session.CLIENT_ACKNOWLEDGE,
 * javax.jms.Session.DUPS_OK_ACNOWLEDGE. This property is optional and
 * defaults to javax.jms.Session.AUTO_ACKNOWLEDGE.
 *
 * @param acknowledgeMode An int representing the acknowledge mode used.
 */
public void setAcknowledgeMode(int acknowledgeMode)
{
    if (acknowledgeMode == Session.AUTO_ACKNOWLEDGE
            || acknowledgeMode == Session.CLIENT_ACKNOWLEDGE
            || acknowledgeMode == Session.DUPS_OK_ACKNOWLEDGE)
        this.acknowledgeMode = acknowledgeMode;
}